This is an archive of the discontinued LLVM Phabricator instance.

[yaml2obj] - Lookup relocation symbols in dynamic symbol when .dynsym referenced.
ClosedPublic

Authored by grimar on Aug 21 2019, 6:50 AM.

Details

Summary

This fixes https://bugs.llvm.org/show_bug.cgi?id=40337.

Previously, it was always assumed that relocations referenced symbols in the static symbol table.
Now, if the Link field references a section called ".dynsym" it will look up these symbols
in the dynamic symbol table.

This patch is heavily based on D59097 by James Henderson

Diff Detail

Repository
rL LLVM

Event Timeline

grimar created this revision.Aug 21 2019, 6:50 AM
grimar marked an inline comment as done.Aug 21 2019, 6:54 AM
grimar added inline comments.
lib/ObjectYAML/ELFEmitter.cpp
1001 ↗(On Diff #216389)

btw, since this code is now used for dynamic symbols and yaml2obj is
generally a tool that makes possible to produce the broken binaries,
perhaps I'd try to remove this restriction logic for both regular and dynamic symbols
in a follow up.

jhenderson accepted this revision.Aug 22 2019, 3:41 AM

LGTM, with my suggested changes. Thanks for picking this up. I've been too busy doing other things to get back around to it.

lib/ObjectYAML/ELFEmitter.cpp
1001 ↗(On Diff #216389)

Seems like a reasonable plan to me.

1015 ↗(On Diff #216389)

Maybe rename this to buildSymbolIndexes, since there are more than one.

test/tools/yaml2obj/dynamic-relocations.yaml
62 ↗(On Diff #216389)

Minor point, but it might make sense to have both first in one of the two tables so that it doesn't have the same index. If I'm not mistaken, in the currents situation, the unpatched yaml2obj would actually generate the right thing as things stand for both.

This revision is now accepted and ready to land.Aug 22 2019, 3:41 AM
grimar marked 5 inline comments as done.Aug 22 2019, 5:38 AM
grimar added inline comments.
test/tools/yaml2obj/dynamic-relocations.yaml
62 ↗(On Diff #216389)

Good point, I did that, thanks!

This revision was automatically updated to reflect the committed changes.
grimar marked an inline comment as done.
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2019, 5:42 AM