[PATCH] [ELF] Add two new virtual functions to the `OutputELFWriter` class to control dynamic symbol table populating and DT_NEEDED tag creation

Simon Atanasyan simon at atanasyan.com
Mon Jun 23 06:05:11 PDT 2014


Hi Bigcheese, shankarke, ruiu,

The patch adds two new virtual functions to the `OutputELFWriter` class to control dynamic symbol table populating and DT_NEEDED tag creation. The `isDynSymEntryRequired` function returns true if the specified shared library atom requires a dynamic symbol table entry. The `isNeededTagRequired` function returns true if we need to create DT_NEEDED tag for the shared library defined specified shared atom.

By default the both functions return true. So there is no functional changes for all targets except MIPS. Probably we need to spread the same modifications on other ELF targets but I want to implement and fully tested complete set of changes for MIPS target first.

For MIPS we create a dynamic symbol table entry for a shared library atom iif this atom is referenced by a regular defined atom. For example, if library L1 defines symbol T1, library L2 defines symbol T2 and uses symbol T1 and executable file E1 uses symbol T2 but does not use symbol T1 we create an entry in the E1 dynamic symbol table for symbol T2 and do not create an entry for T1.

The patch creates DT_NEEDED tags for shared libraries contain shared library atoms which a) referenced by regular defined atoms; b) have corresponding copy dynamic relocations (R_MIPS_COPY).

Now the patch does not take in account --as-needed / --no-as-needed command line options. So it is too restrictive and create DT_NEEDED tags for really needed shared libraries only. I plan to fix that by subsequent patches.

http://reviews.llvm.org/D4255

Files:
  lib/ReaderWriter/ELF/Mips/MipsDynamicLibraryWriter.h
  lib/ReaderWriter/ELF/Mips/MipsELFWriters.h
  lib/ReaderWriter/ELF/Mips/MipsExecutableWriter.h
  lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h
  lib/ReaderWriter/ELF/OutputELFWriter.h
  test/elf/Mips/dynsym-table-1.test
  test/elf/Mips/dynsym-table-2.test
  test/elf/Mips/rel-copy.test
  test/elf/Mips/rel-dynamic-01.test
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4255.10748.patch
Type: text/x-patch
Size: 18548 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140623/5853a070/attachment.bin>


More information about the llvm-commits mailing list