This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by atanasyan on Jun 23 2014, 6:05 AM.

Details

Summary

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.

Diff Detail

Event Timeline

atanasyan updated this revision to Diff 10748.Jun 23 2014, 6:05 AM
atanasyan retitled this revision from to [ELF] Add two new virtual functions to the `OutputELFWriter` class to control dynamic symbol table populating and DT_NEEDED tag creation.
atanasyan updated this object.
atanasyan edited the test plan for this revision. (Show Details)
atanasyan added reviewers: Bigcheese, shankarke, ruiu.
atanasyan added a subscriber: Unknown Object (MLST).
shankarke accepted this revision.Jun 23 2014, 7:16 AM
shankarke edited edge metadata.
This revision is now accepted and ready to land.Jun 23 2014, 7:16 AM
ruiu accepted this revision.Jun 23 2014, 12:46 PM
ruiu edited edge metadata.

LGTM with a nit.

lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h
70

nit: s/auto/Reference/

atanasyan closed this revision.Jun 25 2014, 1:11 AM

Thanks for review.

Closed by commit rL211674.