Page MenuHomePhabricator

[MC][ELF][ARM] Add relocations for Thumb pc-relative fixups
ClosedPublic

Authored by psmith on Feb 24 2020, 4:47 AM.

Details

Summary

Add ELF relocations for the following Thumb fixups:

  • fixup_thumb_adr_pcrel_10 -> R_ARM_THM_PC8
  • fixup_thumb_cp -> R_ARM_THM_PC8
  • fixup_t2_adr_pcrel_12 -> R_ARM_THM_PREL_11_0
  • fixup_t2_ldst_pcrel_12 -> R_ARM_THM_PC12

While these relocations are short-ranged there is support in the open source ELF linker's in binutils and soon to be in LLD. MC (D72197) will no longer resolve pc-relative fixups to global symbols due to interpositioning concerns, which results in an error message. I have a patch implementing these three relocations in LLD ready to submit.

TODO: Connect up the ARM state relocations for the pc-relative adr and ldr fixups. These will come in a follow-up patch when I have LLD support ready.

Part of the long term fix for pr44929 https://bugs.llvm.org/show_bug.cgi?id=44929

Diff Detail

Event Timeline

psmith created this revision.Feb 24 2020, 4:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 24 2020, 4:47 AM

I can't imagine any realistic use-case for the Thumb1 relocations, but I guess it isn't very hard to support them.

llvm/test/MC/ARM/thumb1-relax-adr.s
3–4

Missing Thumb1 testcase?

MaskRay added inline comments.Feb 24 2020, 4:31 PM
llvm/test/MC/ARM/thumb1-relax-adr.s
10–11

LGTM once R_ARM_THM_PC8 (as requested by @efriedma IIUC) is added.

In the description,

fixup_thumb_cp -> R_ARM_THM_PC8

fixup_arm_thumb_cp?

R_ARM_THM_ALU_PREL_11_0 is missing.

psmith updated this revision to Diff 246448.Feb 25 2020, 7:20 AM
psmith edited the summary of this revision. (Show Details)

Thanks for the comments, I've added the missing test, and updated the description with the mapping from fixup_t2_adr_pcrel_12 -> R_ARM_THM_PREL_11_0

MaskRay edited reviewers, added: efriedma; removed: eli.friedman.Feb 25 2020, 9:02 AM
MaskRay accepted this revision.Feb 25 2020, 9:04 AM

LGTM, but I hope @ostannard or @efriedma can confirm.

This revision is now accepted and ready to land.Feb 25 2020, 9:04 AM

Thanks, I'll wait for the LLD review that implements the relocations (D75042) before committing.

psmith updated this revision to Diff 247202.Feb 28 2020, 3:18 AM

Rebased after D72892 landed for the benefit of the 10.0 release as discussed in pr44929. This effectively reverts the Thumb side of that patch as well as enabling the relocations. The ARM side of D72892 is still there as LLD hasn't implemented the relocations yet. Will post patch for that shortly.

This revision was automatically updated to reflect the committed changes.