[llvm] [ARM] Use .reloc for weak symbols in PIC mode instead of GOT indirection (PR #208372)
Petr Hosek via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 11 12:21:54 PDT 2026
petrhosek wrote:
We started seeing building failure on our bots when linking `libclang_rt.atomic.so` after this change was merged:
```
FAILED: /b/s/w/ir/x/w/llvm_build/lib/clang/23/lib/armv7-unknown-linux-gnueabihf/libclang_rt.atomic.so
: && /b/s/w/ir/x/w/llvm_build/./bin/clang --target=armv7-unknown-linux-gnueabihf --sysroot=/b/s/w/ir/x/w/cipd/linux -fPIC --target=armv7-unknown-linux-gnueabihf -O2 -g -DNDEBUG -fuse-ld=lld -nodefaultlibs -shared -Wl,-soname,libclang_rt.atomic.so -o /b/s/w/ir/x/w/llvm_build/lib/clang/23/lib/armv7-unknown-linux-gnueabihf/libclang_rt.atomic.so CMakeFiles/clang_rt.atomic-dynamic-armv7.dir/atomic.c.o /b/s/w/ir/x/w/llvm_build/lib/clang/23/lib/armv7-unknown-linux-gnueabihf/libclang_rt.builtins.a && :
ld.lld: error: relocation R_ARM_REL32 cannot be used against symbol '__register_frame_info'; recompile with -fPIC
>>> defined in /b/s/w/ir/x/w/llvm_build/lib/clang/23/lib/armv7-unknown-linux-gnueabihf/clang_rt.crtbegin.o
>>> referenced by crtbegin.c
>>> /b/s/w/ir/x/w/llvm_build/lib/clang/23/lib/armv7-unknown-linux-gnueabihf/clang_rt.crtbegin.o:(__do_init)
ld.lld: error: relocation R_ARM_REL32 cannot be used against symbol '__cxa_finalize'; recompile with -fPIC
>>> defined in /b/s/w/ir/x/w/llvm_build/lib/clang/23/lib/armv7-unknown-linux-gnueabihf/clang_rt.crtbegin.o
>>> referenced by crtbegin.c
>>> /b/s/w/ir/x/w/llvm_build/lib/clang/23/lib/armv7-unknown-linux-gnueabihf/clang_rt.crtbegin.o:(__do_fini)
ld.lld: error: relocation R_ARM_REL32 cannot be used against symbol '__deregister_frame_info'; recompile with -fPIC
>>> defined in /b/s/w/ir/x/w/llvm_build/lib/clang/23/lib/armv7-unknown-linux-gnueabihf/clang_rt.crtbegin.o
>>> referenced by crtbegin.c
>>> /b/s/w/ir/x/w/llvm_build/lib/clang/23/lib/armv7-unknown-linux-gnueabihf/clang_rt.crtbegin.o:(__do_fini)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```
I believe the issue is that `R_ARM_REL32` cannot be used against preemptible symbols in a shared library.
https://github.com/llvm/llvm-project/pull/208372
More information about the llvm-commits
mailing list