[llvm] [ARM] Use .reloc for weak symbols in PIC mode instead of GOT indirection (PR #208372)
dong jianqiang via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 11 21:22:37 PDT 2026
dongjianqiang2 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.
@petrhosek Sorry for the breakage — I missed the shared library case. Your analysis is spot on. I'll put up a fix.
https://github.com/llvm/llvm-project/pull/208372
More information about the llvm-commits
mailing list