我有一个简单的测试程序,调用 pthread_cond_broadcast
。
当与 ld
链接时,会显示以下内容:
情况1:
$ nm ld-test | grep cond_broadcast
U pthread_cond_broadcast@@GLIBC_2.3.2
当与
gold
链接器链接时,它会显示:情况2:
$ nm gold-test | grep cond_broadcast
U pthread_cond_broadcast
pthread/libc 包含多个 pthread_cond_broadcast 符号,这些符号具有不同的版本符号,可能是因为 ABI 已经更改。
$ nm /lib64/libc.so.6 |grep cond_broadca
00000036b84f7d30 t __pthread_cond_broadcast
00000036b85278f0 t __pthread_cond_broadcast_2_0
00000036b84f7d30 T pthread_cond_broadcast@@GLIBC_2.3.2
00000036b85278f0 T pthread_cond_broadcast@GLIBC_2.2.5
$ nm /lib64/libpthread.so.0 |grep cond_broadcast
00000036b880bee0 t __pthread_cond_broadcast
00000036b880c250 t __pthread_cond_broadcast_2_0
00000036b880bee0 T pthread_cond_broadcast@@GLIBC_2.3.2
00000036b880c250 T pthread_cond_broadcast@GLIBC_2.2.5
所以问题是:
gold
与旧版/普通版的ld
之间为什么有不同的行为。- 在Case 2中,当二进制文件链接到未版本化的
pthread_cond_broadcast
符号时,使用了哪个pthread_cond_broadcast
符号?最新实现的pthread_cond_broadcast
?还是最老的?