[PATCH] D72892: [MC][ARM] Resolve some pcrel fixups at assembly time

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 21 03:50:25 PST 2020


psmith accepted this revision.
psmith added a comment.
This revision is now accepted and ready to land.

In D72892#1885906 <https://reviews.llvm.org/D72892#1885906>, @MaskRay wrote:

> Rebase.
>
> In case someone needs this workaround before we implement these relocations.


Given how close we are to 10.0 and pr44929 is on the 10.0 release blocker list. I think this is workaround is closer than emitting the relocations and updating the linkers. Will be worth waiting to see if there are any objections.

I think that at least a subset of this will be beneficial as there are some fixups that don't have relocations defined. Checking the Arm ARM https://developer.arm.com/docs/ddi0487/latest/arm-architecture-reference-manual-armv8-for-armv8-a-architecture-profile and https://static.docs.arm.com/ihi0044/g/aaelf32.pdf as well as the binutils implementations it looks like we have relocations defined for:

Arm state

| instruction      | fixup                 | relocation         | gold | bfd |
| adr r0, bar      | arm_adr_pcrel_12      | R_ARM_ALU_PC_G0_NC | yes  | yes |
| ldr r0, foo      | arm_ldst_pcrel_12     | R_ARM_LDR_PC_G0    | yes  | yes |
| ldrd r0, r1, foo | arm_pcrel_10_unscaled | R_ARM_LDRS_PC_G0   | *no* | yes |
|

There are G1, G2 and G3 relocations as well as the add and ldr have a modified immediate form that shifts the immediate. In GNU as these can be accessed via modifiers such as :pc_g1: symbol.

Thumb state

| instruction   | fixup                    | relocation              | gold | bfd |
| adr r0, bar   | fixup_thumb_adr_pcrel_10 | R_ARM_THM_PC8           | yes  | yes |
| adr.w r0, bar | t2_adr_pcrel_12          | R_ARM_THM_ALU_PREL_11_0 | yes  | yes |
| ldr r0, foo   | fixup_arm_thumb_cp       | R_ARM_THM_PC8           | yes  | yes |
| ldr.w r0, foo | t2_ldst_pcrel_12         | R_ARM_THM_PC12          | yes  | yes |
|

I'm not aware of any relocations for vldr or the thumb state ldrd. I'm not sure I've ever seen these written in assembly though.

I'll start implementing these in LLD, will take a little time as I can't work full time on it. When that is done we can emit relocations for these cases. We'll then have to decide whether to support vldr or ldrd to a global. These may be sufficiently rare to ask for code to be changed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72892/new/

https://reviews.llvm.org/D72892





More information about the llvm-commits mailing list