More questions about _GLOBAL
Anthony Green
green@redhat.com
Tue Jan 29 12:34:00 GMT 2002
On Tue, 2002年01月29日 at 09:54, Adam Megacz wrote:
> 1. Since we don't know which _GLOBAL symbols should be invoked on
> startup until the link phase, does this mean that the linker
> actually generates the code for __main()?
I think the linker puts together data which is used by __main. BTW, the
static initializer you're seeing (which calls the register class
function) isn't used on ELF systems. We use a special section called
.jcr which contains a list of pointers to classes which need
registration. Try compiling to a .s and looking for references to the
_GLOBAL* symbol.
> 2. How does the linker know which symbols should be invoked on startup
> and which shouldn't? Is "_GLOBAL" a "magic prefix"?
I can only speak for ELF systems, in which case a list of pointers to
these functions is placed in a special section, and the linker pulls
them together into one list which is traversed at program startup.
> 3. Is there any way for me to remove one of these _GLOBAL__ sections
> from a .o after compilation, without causing __main() to jump to an
> undefined/invalid address? If I simply remove the section (strip
> -R), __main() seems to call some other randomly-chosen section
> instead, which, of course, causes my program to barf all over the
> place.
Hmm... I'm not sure I understand what you're asking. You need these
_GLOBAL__ functions to implement static initializers.
AG
More information about the Java
mailing list