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

Reid Kleckner rnk at google.com
Fri Apr 25 16:33:38 PDT 2014


This might give some assemblers heartburn.  Does gcc sanitize the filename
in any way?

What happens if the main source file is stdin?


On Fri, Apr 25, 2014 at 4:17 PM, Nico Weber <thakis at chromium.org> wrote:

> Hi,
>
> gcc calls the static initialization function for file foo.cc
> _GLOBAL__sub_i_foo.cc, while clang always uses _GLOBAL__I_a . Having the
> filename in the symbol is useful for finding where static initializers are
> from; we use this information in chromium on linux. (On Mac, we look at the
> dSYM file instead.)
>
> The attached patch makes clang behave like gcc for initializers. (It
> doesn't change the behavior for __D_ functions, not sure if anyone wants
> that.)
>
> Opinions? Is this useful for anyone else?
>
> (Drawbacks: slightly longer symbols, which has a (small) binary size cost,
> and it looks like __attribute__ ((init_priority(101))) works by naming the
> _GLOBAL__ functions _GLOBAL__I_000101 etc, so if you call your source file
> 000101.cc it might interfere with this patch.
>
> Nico
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140425/7f73c1dd/attachment.html>


More information about the cfe-commits mailing list