This is an archive of the discontinued LLVM Phabricator instance.

[LLD][ELF][ARM] Do not create .ARM.exidx sections for out of range inputs
ClosedPublic

Authored by psmith on May 2 2020, 5:01 AM.

Details

Summary

A linker will create .ARM.exidx sections for InputSections that don't have them. This can cause a relocation out of range error If the InputSection happens to be extremely far away from the other sections. This is often the case for the vector table on older ARM CPUs as the only two places that the table can be placed is 0 or 0xffff0000. We fix this by removing InputSections that need a linker generated .ARM.exidx section if that would cause an error.

Fixes part of pr44824 (https://bugs.llvm.org/show_bug.cgi?id=44824)

Diff Detail

Event Timeline

psmith created this revision.May 2 2020, 5:01 AM
MaskRay added inline comments.May 2 2020, 10:18 AM
lld/ELF/SyntheticSections.cpp
3377

int64_t off = isec->getVA() - getVA();

Even better: add an explicit cast.

lld/test/ELF/arm-exidx-range.s
2

// REQUIRES: arm

6

AT(...) can be omitted.

11

The .vectors at 0xffff0000 (...) in earlier Arm CPUs.

This sentence lacks a verb.

20

Add CHECK-NOT: 0x to make sure there is the last line ("Expect only .ARM.exidx from _start and sentinel")

psmith marked 5 inline comments as done.May 4 2020, 6:30 AM

Thanks for the comments, will update diff shortly.

psmith updated this revision to Diff 261800.May 4 2020, 6:31 AM

Applied previous review comments. Added missing REQUIRES, added CHECK-NOT and simplified range checking code.

MaskRay accepted this revision.May 4 2020, 8:10 AM

LGTM.

This revision is now accepted and ready to land.May 4 2020, 8:10 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMay 5 2020, 2:06 AM