This is an archive of the discontinued LLVM Phabricator instance.

[ELF] -r: fix crash when processing a SHT_REL[A] that relocates a SHF_MERGE after D67504/r372734
ClosedPublic

Authored by MaskRay on Oct 23 2019, 11:07 PM.

Details

Summary

Fix PR43767

In -r mode, when processing a SHT_REL[A] that relocates a SHF_MERGE, sec->getRelocatedSection() is a
MergeInputSection and its parent is an OutputSection but is asserted to
be a SyntheticSection (MergeSyntheticSection) in LinkerScript.cpp:addInputSec().

The code path is not exercised in non -r mode because the relocated
section changed from MergeInputSection to InputSection.

Reorder the code to make the non -r logic apply to -r as well, thus fix
the crash.

Diff Detail

Event Timeline

MaskRay created this revision.Oct 23 2019, 11:07 PM
MaskRay edited the summary of this revision. (Show Details)Oct 23 2019, 11:10 PM
MaskRay retitled this revision from [ELF] Fix crash when processing a SHT_REL[A] that relocates a SHF_MERGE after D67504/r372734 to [ELF] -r: fix crash when processing a SHT_REL[A] that relocates a SHF_MERGE after D67504/r372734.Oct 23 2019, 11:14 PM
peter.smith accepted this revision.Oct 24 2019, 3:35 AM

Agreed, I think that change makes sense.

This revision is now accepted and ready to land.Oct 24 2019, 3:35 AM
MaskRay updated this revision to Diff 226289.Oct 24 2019, 10:29 AM
MaskRay edited the summary of this revision. (Show Details)

Update description

This revision was automatically updated to reflect the committed changes.