[(questionable but useful) patch] Let codegen write the filename for translation unit initializer functions

John McCall rjmccall at apple.com
Mon May 5 23:13:58 PDT 2014


On May 5, 2014, at 10:11 PM, Nico Weber <thakis at chromium.org> wrote:
> Here's a patch which replaces everything not in [a-zA-Z0-9._] with _.
> It also adds a "sub_" to the symbol, because a) that's what gcc does
> (with -fPIC) b) that way, constructors with priority are
> lexicographically in front of constructors without priority.
> 
> John, do you think this is ok? This patch adds a filename to global
> constructor symbols without priority, i.e. instead of always being
> called _GLOBAL__I_a they're now called _GLOBAL__sub_I_my_file.cc. I'm
> asking because there are tests for _destructors_ for -fapple-kext, so
> maybe kexts care about these symbol names in some way.

I don’t believe the symbol name is relevant for kexts, but if it is, that’ll
be something we’ve learned.

You’ll need to look at binutils (I guess?) to find the exact schema,
but if it’s specific to looking around the “_I_” symbol, you may be able
to avoid potential confusion with an init_priority just by adding
an extra underscore or something.

Also, you should really find out what the “sub" means before blindly
changing to it.  If it’s being emitted only under -fPIC, it might mean
something like the functions being relatively addressed.  If it’s all
handled magically by ld, then great, but you need to find out.

John.



More information about the cfe-commits mailing list