This is an archive of the discontinued LLVM Phabricator instance.

[lld] [ELF] Only mark as DT_NEEDED libs that are strictly necessary
ClosedPublic

Authored by rafaelauler on Oct 1 2014, 9:53 PM.

Details

Summary

This patch enhances the creation of an ELF dynamic executable by avoiding
recording unnecessary shared libraries as NEEDED to load this program.

To do this, we must keep track of not only symbols that were referenced but
also of COPY relocations, which steal the symbol from a shared library but does
not store from which lib this symbol came from. To fix this, this patch changes
ObjectSymbol to store the original library from which this symbol came. With
this information, we are able to build a list of the exact shared libraries that
must be marked as DT_NEEDED, instead of blindly marking all shared libraries as
needed.

This logic originally came from the MIPS backend with some adaptation.

Diff Detail

Event Timeline

rafaelauler updated this revision to Diff 14311.Oct 1 2014, 9:53 PM
rafaelauler retitled this revision from to [lld] [ELF] Only mark as DT_NEEDED libs that are strictly necessary.
rafaelauler updated this object.
rafaelauler edited the test plan for this revision. (Show Details)
rafaelauler added reviewers: Bigcheese, shankarke.
rafaelauler added a subscriber: Unknown Object (MLST).
atanasyan accepted this revision.Oct 1 2014, 10:04 PM
atanasyan added a reviewer: atanasyan.
atanasyan added a subscriber: atanasyan.

LGTM

This revision is now accepted and ready to land.Oct 1 2014, 10:04 PM
emaste added a subscriber: emaste.Oct 2 2014, 4:54 AM
rafaelauler closed this revision.Oct 8 2014, 4:04 PM

Committed r219353.