More questions about _GLOBAL

Anthony Green green@redhat.com
Tue Jan 29 13:55:00 GMT 2002


On Tue, 2002-01-29 at 13:30, Adam Megacz wrote:
> So the GNU ld knows that .jcr is a "magic" section which should
> recieve special handling?

Only in that the ELF linker scripts mention the .jcr section.  The
linker always pulls the contents of a named section together into one
blob, and crtbegin/crtend are used to stick labels at the beginning and
end of the .jcr section. 

> The optimization I'm trying to do is this: if none of a class's
> constructors are reachable, I prune foo.bar.baz.class$ from the
> output. Unfortunately, the __GLOBAL_foo.bar.baz symbol will call
> _Jv_RegisterClass(foo.bar.baz.class$), which then SEGV's.
> 
> I guess that if _Jv_RegisterClass is responsible for doing the work of
> <clinit>, I can't really do this. Crud.

I can imagine hacks for working around this problem.  

Each object file contains one of these constructor functions for
registering each class defined in the .o.  One idea is to create a
special "ignored" class which _Jv_RegisterClass is taught to ignore, and
then use linker tricks to alias foo.bar.baz.class$ to the ignored class.

If Windows used the .jcr mechanism you would simply strip the class
reference from the .jcr section.

AG




More information about the Java mailing list