[LLVMdev] Modeling ELF linker with lld/Chunks.

Nick Kledzik kledzik at apple.com
Mon Jun 8 17:45:57 PDT 2015


On Jun 5, 2015, at 6:45 PM, Rui Ueyama <ruiu at google.com> wrote:
> 
> - Dont halt the linker operation if there are undefined symbols but they are not called from the root set (Do garbage collection and then report whether symbols are really undefined)
> 
> Dead-stripping is done after eliminating duplicate COMDAT symbols. Unreferenced symbols are naturally ignored.

Global symbols that did not make it into the final symbol table (because of coalescing or group COMDAT), are easy to discard.

But, darwin supports “dead code stripping”.  The way it works is you start with atoms (symbols) that must be preserved (for an executable program, that would be “main”), mark them live then start recursively marking live the atoms they reference.  In order to do this, you must parse the relocations to and figure out: 1) which function/data each relocation applies to, and 2) what function/data each relocation references.  

A couple interesting points:
a) The master symbol table does not help with dead code stripping because often functions/data are static or anonymous and thus are not in the master symbol table.
b) It is ok for dead code to reference undefined symbols, since the dead code will be stripped away.  The resolver phase normally ends when there are no undefined symbols remaining or with an error about undefined symbols.  But with dead stripping, it is not an error to end with undefined symbols.
c) Once the dead code is identified, any symbols the dead code added to the master symbol table need to be removed.

-Nick

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150608/e5a1a4ff/attachment.html>


More information about the llvm-dev mailing list