libgcc linker error: hidden symbol __aarch64_swp1_acq_rel in libgcc.a is referenced by DSO

771 views Asked by At

I am trying to link a shared library I have no control on. This library has an undefined symbol (nm output): U __aarch64_swp1_acq_rel

Which seems to be defined in libgcc.a:

[user@fedora ~]$ nm -a /usr/lib/gcc/aarch64-redhat-linux/12/libgcc.a | grep swp1_acq_rel
0000000000000000 T __aarch64_swp1_acq_rel
[user@fedora ~]$ objdump -t /usr/lib/gcc/aarch64-redhat-linux/12/libgcc.a | grep swp1_acq_rel
0000000000000000 g     F .text  000000000000002c .hidden __aarch64_swp1_acq_rel

But whenever I try to link, I get the error in the title of this question. I understand that this symbol is hidden for dynamic linking (please confirm if I am wrong). So my question is what is the right approach to link against this libgcc symbol when the shared library I am using (and linking against) does not define it.

I expected that it would be possible to resolve this symbol with the libgcc.a in my system. Why is it hidden?

1

There are 1 answers

0
Bill Cong On

Compile it with cflags "-mno-outline-atomics" can solve my problem. GCC 10.0 enables calls to out-of-line helpers to implement atomic operations. You can view the compile code to see the differences: https://godbolt.org/z/z8W7z1cqx