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

Rafael Auler rafaelauler at gmail.com
Wed Oct 1 21:54:02 PDT 2014


Hi Bigcheese, shankarke,

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.

http://reviews.llvm.org/D5574

Files:
  include/lld/ReaderWriter/ELFLinkingContext.h
  lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.h
  lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp
  lib/ReaderWriter/ELF/Atoms.h
  lib/ReaderWriter/ELF/DefaultLayout.h
  lib/ReaderWriter/ELF/Mips/MipsDynamicLibraryWriter.h
  lib/ReaderWriter/ELF/Mips/MipsELFWriters.h
  lib/ReaderWriter/ELF/Mips/MipsExecutableWriter.h
  lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp
  lib/ReaderWriter/ELF/Mips/MipsLinkingContext.h
  lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp
  lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h
  lib/ReaderWriter/ELF/OutputELFWriter.h
  lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.h
  lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D5574.14311.patch
Type: text/x-patch
Size: 11683 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141002/4f30a1ec/attachment.bin>


More information about the llvm-commits mailing list