[Bug target/12020] undefined reference in libgcc2.c to __do_global_ctors when testing C compiler
wilson at specifixinc dot com
gcc-bugzilla@gcc.gnu.org
Tue Oct 14 02:22:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12020
------- Additional Comments From wilson at specifixinc dot com 2003-10-14 02:22 -------
Subject: Re: undefined reference in libgcc2.c to __do_global_ctors
when testing C compiler
pinskia at gcc dot gnu dot org wrote:
> Looks like HAS_INIT_SECTION is defined but INVOKE__main is also defined but the file format is not
> elf aka OBJECT_FORMAT_ELF is not defined. Could any one comment on what is going on here?
The d30v port has no maintainer, and no known users. It is likely to be
obsoleted the next time we go through that process. I see no point in
trying to make it work.
Using ambiguous targets like d30v is a bad idea. You will match the
default d30v target for each tool, which could be different, resulting
in a toolchain that won't work. I'm guessing that d30v was used as the
target because config.gcc has "d30v-*-*". That doesn't mean that it is
OK to use d30v as the target. That means that we want all targets to
use the same gcc configuration. However, this can't possibly work for
targets like d30v-coff. This should be fixed, but since I expect the
d30v port to be obsoleted, it probably isn't worth fixing.
The file format is ELF. OBJECT_FORMAT_ELF comes from config/elfos.h.
The problem here seems to be that when the port was written, it didn't
use the standard ELF conventions for running static constructors. Some
embedded ports used the coff conventions because they were simpler to
get working. If you look at the libgloss d30v/crt0.S file, you will see
that there is no support for running code in init/fini sections.
Rather, we rely on __main to call the function addresses in the
.ctor/.dtor sections. Thus the need to define INVOKE__main which is
normally not used for an ELF target. This must have worked fine in 1997
or so when the code was written. Since then, there have been a lot of
structural changes, and it happens not to work anymore. This went
unnoticed, because there are no users for the d30v port. The proper fix
for this is to use ELF style static constructors instead of COFF style,
which means getting rid of the INVOKE__main definition in gcc, and in
newlib fixing the libgloss d30v/crt0.S to run code in .init and .fini
sections. But since I expect the port to be deprecated soon, I don't
see the point of doing this work.
More information about the Gcc-bugs
mailing list