This is an archive of the discontinued LLVM Phabricator instance.

ELF: Move Visibility, IsUsedInRegularObj and MustBeInDynSym flags to Symbol.
ClosedPublic

Authored by pcc on Apr 21 2016, 7:43 PM.

Details

Summary

These are properties of a symbol name, rather than a particular instance
of a symbol in an object file. We can simplify the code by collecting these
properties in Symbol.

The MustBeInDynSym flag has been renamed ExportDynamic, as its semantics
have been changed to be the same as those of --dynamic-list and
--export-dynamic-symbol, which do not cause hidden symbols to be exported.

Diff Detail

Repository
rL LLVM

Event Timeline

pcc updated this revision to Diff 54604.Apr 21 2016, 7:43 PM
pcc retitled this revision from to ELF: Move Visibility, IsUsedInRegularObj and MustBeInDynSym flags to Symbol..
pcc updated this object.
pcc added reviewers: rafael, ruiu, davide.
pcc added a subscriber: llvm-commits.
ruiu edited edge metadata.Apr 21 2016, 8:09 PM

This is a very interesting idea. I have never thought of adding new fields to Symbol, but it seems to make sense because the argument that some properties belongs to names rather than to symbol instances is convincing. One concern would be that now you have to memorize which class have a certain property, Symbol or SymbolBody, but that's probably not a big issue.

There are a few minor comments.

ELF/LTO.cpp
79 ↗(On Diff #54604)

Maybe we should make Backref member public then use that member directly and remove getSymbol accessor?

ELF/MarkLive.cpp
116–121 ↗(On Diff #54604)

You can remove all curly braces.

ELF/SymbolTable.cpp
290 ↗(On Diff #54604)

Please add a newline before this line.

294–302 ↗(On Diff #54604)

Can you move this code to a new static function (say, shouldExport) so that you can write

Sym->ExportDynamic ||= shouldExport(New);
303 ↗(On Diff #54604)

s/K/SymbolBody::Kind/

ELF/Symbols.cpp
327 ↗(On Diff #54604)

V is used only in this line, so probably

if (Visibility != STV_DEFAULT && Visibility != STV_PROTECTED)

is better.

pcc updated this revision to Diff 54609.Apr 21 2016, 9:16 PM
pcc marked 2 inline comments as done.
pcc edited edge metadata.

Address review comments

pcc marked 4 inline comments as done.Apr 21 2016, 9:17 PM
pcc updated this revision to Diff 54687.Apr 22 2016, 11:40 AM
  • No need to set export dynamic flag on copy relocation aliases; they will be exported anyway
ruiu accepted this revision.Apr 22 2016, 11:42 AM
ruiu edited edge metadata.

LGTM with a nit.

ELF/SymbolTable.cpp
281 ↗(On Diff #54609)

Remove else after return.

This revision is now accepted and ready to land.Apr 22 2016, 11:42 AM
This revision was automatically updated to reflect the committed changes.