This change implements support for R_ARM_THM_JUMP8 relocation in
addition to R_ARM_THM_JUMP11 which is already supported by LLD.
Details
- Reviewers
MaskRay mcgrathr peter.smith
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
There should be a regular test in arm-thumb-narrow-branch-check.s.
LGTM, but I am unfamiliar with ARM so it'd be good checked by Peter as well.
Code looks good to me.
Will probably need to use the .reloc directive in a regular test. Most assemblers don't emit the relocation for the Thumb conditional branch as it is so small in range that going out of the section usually means it will be out of range of its target. I think something like:
.text .thumb .global undefined .inst.n 0xd0fe .reloc 0, R_ARM_THM_JUMP8, undefined
Should work, this produces:
00000000 <$t.0>: 0: fe d0 beq 0x0 <$t.0> @ imm = #-4 00000000: R_ARM_THM_JUMP8 undefined
lld/test/ELF/arm-thumb-undefined-weak-narrow.test | ||||||||
---|---|---|---|---|---|---|---|---|
27 | The R_ARM_THM_JUMP8 is for the thumb conditional branch. I think that for a jump to a symbol this should be with little-endian fed0 for beq undefined_weak
Where the imm8 is -4 (Thumb PC-bias). |
I've added regular test in arm-thumb-narrow-branch-check.s, let me know if this makes sense.
Thanks for the updates LGTM. In theory we can now rewrite arm-thumb-narrow-branch-check.s using .reloc but that could be done in a future patch.
lld/test/ELF/Inputs/arm-thumb-narrow-branch.s | ||
---|---|---|
4 | R_ARM_THM_JUMP8 has an even smaller range of +- 256 bytes, but I don't think it is worth changing the comment as the point still stands. |
R_ARM_THM_JUMP8 has an even smaller range of +- 256 bytes, but I don't think it is worth changing the comment as the point still stands.