Unsupported SBREL32 relocation
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GNU Arm Embedded Toolchain |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
I'm compiling bare-metal relocatable binaries for Thumb using
the RWPI relocation model from LLVM (which is used by Rust in my case).
However, I'm unable to link this code since arm-none-eabi-ld is missing support for the ARM relocation type R_ARM_SBREL32 (relocation
type 9 in
http://
which is emitted by LLVM for the RWPI relocation model.
Below is a simple assembly regressions, which tries to dereference a global called `foo` in the `_start` procedure, using the SBREL_32 relocation:
.text
.syntax unified
.eabi_attribute 67, "2.09" @ Tag_conformance
.cpu arm7tdmi
.eabi_attribute 6, 2 @ Tag_CPU_arch
.eabi_attribute 8, 1 @ Tag_ARM_ISA_use
.eabi_attribute 15, 2 @ Tag_ABI_PCS_RW_data
.eabi_attribute 16, 1 @ Tag_ABI_PCS_RO_data
.eabi_attribute 17, 1 @ Tag_ABI_PCS_GOT_use
.eabi_attribute 20, 1 @ Tag_ABI_FP_denormal
.eabi_attribute 21, 1 @ Tag_ABI_
.eabi_attribute 23, 3 @ Tag_ABI_
.eabi_attribute 34, 0 @ Tag_CPU_
.eabi_attribute 24, 1 @ Tag_ABI_
.eabi_attribute 25, 1 @ Tag_ABI_
.eabi_attribute 38, 1 @ Tag_ABI_
.eabi_attribute 18, 4 @ Tag_ABI_PCS_wchar_t
.eabi_attribute 26, 2 @ Tag_ABI_enum_size
.eabi_attribute 14, 1 @ Tag_ABI_PCS_R9_use
.file "test.c"
.globl _start
.p2align 2
.type _start,%function
.code 32 @ @_start
_start:
.fnstart
@ BB#0:
ldr r0, .LCPI0_0
mov r1, r9
ldr r0, [r1, r0]
bx lr
.p2align 2
@ BB#4:
.LCPI0_0:
.long foo(sbrel)
Assembling this file works fine:
$ arm-none-eabi-as -o foo.o foo.s
But linking fails due to an "unsupported relocation":
$ arm-none-eabi-ld -o foo foo.o
foo.o: In function `_start':
test.c:
test.c:
There _is_ support for this relocation in ARM's proprietary toolchain (which I believe is based on LLVM's LLD) and LLD now has support for it in tip: https:/
Changed in gcc-arm-embedded: | |
status: | New → Confirmed |
information type: | Public → Public Security |
information type: | Public Security → Public |
For a complete example, compile with clang >= 4.0:
```
static volatile int foo = 0;
void _start() {
while (foo != 1) {
asm volatile ("nop");
}
}
```
$ clang -fropi -frwpi --target= thumbv7- eabi -c -o test.o test.c (.text+ 0x28): dangerous relocation: unsupported relocation
$ arm-none-eabi-ld test.o -o test
test.o: In function `_start':
test.c:
I believe the fix would be somewhere in
static bfd_reloc_ status_ type elf32_arm_ final_link_ relocate
starting on line 9872 in `bfd/elf32-arm.c`