[llvm] [clang] [JITLink][AArch32] Implement Armv5 ldr-pc stubs and use them for all pre-v7 targets (PR #79082)

Peter Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 23 07:15:21 PST 2024


Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/79082 at github.com>


smithp35 wrote:

> Thanks for your notes @smithp35. This worked out nicely! A test for Thumb B to Arm interworking is todo, because we need support for `R_ARM_THM_JUMP11` first. I will work on it now. I think it's quite rare though and anyway, this is more than RuntimeDyld ever supported. So, I think we could land it already.

Thanks I'll try and take a look later today, but as I mentioned I'm probably not familiar enough with JITLink to add much value to the code-changes so feel free to land this as an improvement on what is already there.

Just in case you weren't aware. The ABI does not require a stub for R_ARM_THM_JUMP11 for either range extension or interworking, the range is so small it would be quite a challenge to place a stub close enough to it. In practice this makes the 2-byte Thumb B instruction restricted to targets within the same section (or even same function), which a code-generator won't change-state. An assembly programmer might, but if they do then they have to do the interworking manually.

It is possible in Thumb-1 to have a 4-byte B instruction that uses R_ARM_THM_JUMP24 that will need a stub from Thumb to Arm.

This is in Call and Jump Relocations https://github.com/ARM-software/abi-aa/blob/main/aaelf32/aaelf32.rst
```
A linker may use a veneer (a sequence of instructions) to implement the
relocated branch if the relocation is one of R_ARM_PC24, R_ARM_CALL,
R_ARM_JUMP24, (or, in Thumb state, R_ARM_THM_CALL, R_ARM_THM_JUMP24, or
R_ARM_THM_JUMP19) and:
```

https://github.com/llvm/llvm-project/pull/79082


More information about the cfe-commits mailing list