This is an archive of the discontinued LLVM Phabricator instance.

[ELF] --emit-relocs: fix st_value of STT_SECTION in the presence of a gap before the first input section
ClosedPublic

Authored by MaskRay on Oct 30 2020, 9:59 PM.

Details

Summary

In the presence of a gap, the st_value field of a STT_SECTION symbol is the
address of the first input section (incorrect if there is a gap). Set it to the output section
address instead.

In -r mode, this bug can cause an incorrect non-zero st_value of a STT_SECTION symbol
(while output sections have zero addresses, input sections may have non-zero outSecOff).
The non-zero st_value can cause the final link to have incorrect relocation computation
(both GNU ld and LLD add st_value of the STT_SECTION symbol to the output section address).

Diff Detail

Event Timeline

MaskRay created this revision.Oct 30 2020, 9:59 PM
MaskRay requested review of this revision.Oct 30 2020, 9:59 PM
grimar accepted this revision.Nov 2 2020, 12:50 AM

LGTM I think.

This revision is now accepted and ready to land.Nov 2 2020, 12:50 AM
MaskRay edited the summary of this revision. (Show Details)Nov 2 2020, 8:32 AM
MaskRay edited the summary of this revision. (Show Details)
This revision was landed with ongoing or failed builds.Nov 2 2020, 8:37 AM
This revision was automatically updated to reflect the committed changes.