Support dead-stripping in ELF objects

Nick Kledzik kledzik at apple.com
Fri Apr 5 16:02:27 PDT 2013


On Apr 5, 2013, at 3:41 PM, "Robinson, Paul" <Paul_Robinson at playstation.sony.com> wrote:
>>> 
>>> Symbol flags (which we'll have to find a place to embed, probably
>>> st_other
>>> which has 6 free bits):
>>> * STF_NO_DEADSTRIP - Never remove this symbol or symbols it references
>>> even
>>> if it is in a SHF_SUBSECTION_VIA_SYMBOLS or SHF_DEADSTRIP section
> 
> Michael, you propose that we could have symbols that are never referenced,
> that the linker doesn't know about a-priori, that aren't special in some
> way such as the image entrypoint symbols, and that the compiler will
> identify as one that it does not want to be eliminated?  Like what?
> I'm happy to concede my ignorance but if you're just enumerating all the
> possibilities then I think maybe a little YAGNI is appropriate.

Well, mach-o has the N_NO_DEAD_STRIP bit on any symbol in the symbol table.
If you add __attribute__((used)) on any function or global variable, the compiler
adds that bit the the symbol entry.

It means the linker does not need to know about special symbols that should
always be kept.  Whoever created the symbol sets that bit if they want
it never dead stripped away.

-Nick




More information about the llvm-commits mailing list