This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Add missing dynamic tags when producing output with IRelative relocations only.

Authored by grimar on Dec 27 2017, 2:52 AM.



This is "Bug 35751 - .dynamic relocation entries omitted if output
contains only IFUNC relocations"

We have InX::RelaPlt and InX::RelaIPlt synthetic sections for PLT relocations.
They are usually live in rela.plt section. Problem appears when InX::RelaPlt
section is empty. In that case we did not produce normal set of dynamic tags
required, because logic was written in the way assuming we always have
non-IRelative relocations in rela.plt.

Patch fixes the issue.

Diff Detail


Event Timeline

grimar created this revision.Dec 27 2017, 2:52 AM
grimar updated this revision to Diff 128278.Dec 28 2017, 2:49 AM
  • Reimplemented in according to review suggestions.
emaste added inline comments.Dec 29 2017, 10:13 AM
1090 ↗(On Diff #128278)

The previous code checked that getParent() was not null; why is it no longer necessary?

grimar added inline comments.Dec 29 2017, 10:34 AM
1090 ↗(On Diff #128278)

I believe it was not necessary.
We always add this section to output for non-scripted case (and then remove as it is empty synthetic in removeUnusedSyntheticSections).
For scripted case we disallow discarding rel[a] sections ( and so
I believe always add it as orphan and then, again, remove it in removeUnusedSyntheticSections.
So I believe it is always have parent set.

I am not sure we have testcase showing we ignore discarding .rela.plt. I can double check above (just in case) and add this testcase,
if it is missing, tomorrow.

With this patch applied Kostik's original testcase passes.

grimar added inline comments.Dec 30 2017, 12:51 AM
1090 ↗(On Diff #128278)

I committed NFC change removing checking for null:

Also can confirm we silently ignore scripts like:

/DISCARD/ : { *(.rela.plt)
/DISCARD/ : { *(.rela.dyn)

Patch for that is D41640

This revision was not accepted when it landed; it landed in state Needs Review.Dec 30 2017, 11:43 PM
This revision was automatically updated to reflect the committed changes.