[llvm] [llvm][MC][ARM][Assembly] Emit relocations for ADRs and big-endian targets (PR #73834)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 12 05:47:37 PST 2024


smithp35 wrote:

Looking at the compiler explorer clang for this target is passing the linker -pie by default. I think this may be the root cause of the CI failures as it looks like some position dependent code is now being linked into a position independent executable. 

The recent changes to the assembler don't affect any of these relocations I can reproduce this with clang-10 and lld-10 from ubuntu 20.04.

If your CI code is kernel code that isn't position independent then you'll need to pass -no-pie to the compiler.

>From compiler explorer adding -v to the command line (see -pie)
```
/opt/compiler-explorer/clang-trunk/bin/ld.lld" --sysroot=/opt/compiler-explorer/arm/gcc-12.2.0/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot -EL -X --hash-style=gnu --eh-frame-hdr -m armelf_linux_eabi -pie -dynamic-linker /lib/ld-linux.so.3 -o /app/output.s -L./lib /tmp/example-9aab2b.o -rpath ./lib -rpath /opt/compiler-explorer/arm/gcc-12.2.0/arm-unknown-linux-gnueabi/lib64 -rpath /opt/compiler-explorer/arm/gcc-12.2.0/arm-unknown-linux-gnueabi/lib32
```

The example you have there is not PIE. There is a non-relative relocation in the .text segment (R_ARM_ABS32 is put the absolute address of the symbol into the .word) in the example. By default LLD will accept R_ARM_ABS32 in .data and .data.rel.ro but not .text (it will with -z notext)

R_ARM_THM_MOVW_ABS_NC and R_ARM_THM_MOVT_ABS are also non-relative relocations that can't be used in -pie or -pic. There are PC-relative equivalents R_ARM_MOVW_PREL_NC and R_ARM_THM_MOVT_PREL that can be used instead.

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


More information about the llvm-commits mailing list