[ELF] Add two new virtual functions to the `OutputELFWriter` class to control
authorSimon Atanasyan <simon@atanasyan.com>
Wed, 25 Jun 2014 07:55:55 +0000 (07:55 +0000)
committerSimon Atanasyan <simon@atanasyan.com>
Wed, 25 Jun 2014 07:55:55 +0000 (07:55 +0000)
commitd449fc867126f69db3f280414713774de6b351d7
tree8b63cb474011d857697e75cc021fbab8bec17237
parent10280dac1dad5f182ef8a2bde0ee543b246b1599
[ELF] Add 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.

llvm-svn: 211674
lld/lib/ReaderWriter/ELF/Mips/MipsDynamicLibraryWriter.h
lld/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h
lld/lib/ReaderWriter/ELF/Mips/MipsExecutableWriter.h
lld/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h
lld/lib/ReaderWriter/ELF/OutputELFWriter.h
lld/test/elf/Mips/dynsym-table-1.test [new file with mode: 0644]
lld/test/elf/Mips/dynsym-table-2.test [new file with mode: 0644]
lld/test/elf/Mips/rel-copy.test
lld/test/elf/Mips/rel-dynamic-01.test