This is an archive of the discontinued LLVM Phabricator instance.

[LLD][ELF] - Do not produce an invalid dynamic relocation order with --shuffle-sections.
ClosedPublic

Authored by grimar on Aug 10 2020, 7:05 AM.

Details

Summary

Normally (when not on android with android relocation packing enabled),
we put IRelative relocations to ".rel[a].dyn", after other relocations,
to ensure that IRelatives are processed last by the dynamic loader.

To achieve that we add the in.relaIplt after the part.relaDyn:
https://github.com/llvm/llvm-project/blob/master/lld/ELF/Writer.cpp#L540

The problem is that --shuffle-sections might break the sections order.
This patch fixes it.

Fixes https://bugs.llvm.org/show_bug.cgi?id=47056.

Diff Detail

Event Timeline

grimar created this revision.Aug 10 2020, 7:05 AM
grimar requested review of this revision.Aug 10 2020, 7:05 AM
grimar edited the summary of this revision. (Show Details)Aug 10 2020, 7:10 AM
psmith accepted this revision.Aug 11 2020, 1:09 AM

Looks good to me. Will be worth seeing if MaskRay has any comments.

lld/ELF/Writer.cpp
1443

typo: "to an output section" should be "in an output section"

This revision is now accepted and ready to land.Aug 11 2020, 1:09 AM
grimar updated this revision to Diff 284670.Aug 11 2020, 5:22 AM
grimar marked an inline comment as done.
grimar edited the summary of this revision. (Show Details)
  • Addressed Peter's comment (fixed typo).
  • Rebased after landing parent revision.
lld/ELF/Writer.cpp
1443

Thanks!

MaskRay accepted this revision.Aug 14 2020, 9:02 AM

Looks great!

Herald added a project: Restricted Project. · View Herald TranscriptAug 17 2020, 4:47 AM