markus@x4 math % cat test.i extern double acos(double __x) __attribute__((__nothrow__)); typedef enum { _IEEE_ = -1, _SVID_, _XOPEN_, _POSIX_, _ISOC_ } _LIB_VERSION_TYPE; extern _LIB_VERSION_TYPE _LIB_VERSION; struct exception { int type; char *name; double arg1; double arg2; double retval; }; __asm__(".symver matherr,matherr@GLIBC_2.2.5"); __asm__(".symver _LIB_VERSION,_LIB_VERSION@GLIBC_2.2.5"); static int fail = 1; int matherr(struct exception *s) { __builtin_printf("matherr is working\n"); fail = 0; return 1; } int main() { _LIB_VERSION = _SVID_; acos(2.0); return fail; } markus@x4 math % gcc test.i -fuse-ld=bfd -lm markus@x4 math % ./a.out matherr is working markus@x4 math % gcc test.i -fuse-ld=gold -lm markus@x4 math % ./a.out acos: DOMAIN error
Dup. *** This bug has been marked as a duplicate of bug 21674 ***
Not sure it is a dup. The math/test-matherr and math/test-matherr-2 are the only failures that I see. Everything else works just fine when building glibc with gold.
I can't recreate this. I get "matherr is working" from both gold and GNU ld. I tested with tip gold and "Ubuntu EGLIBC 2.19-0ubuntu6.13". That said, I can see the difference. With GNU ld, readelf -s --wide run on the linked executable shows 8: 0000000000601050 4 OBJECT WEAK DEFAULT 26 _LIB_VERSION@GLIBC_2.2.5 (3) 10: 00000000004006fd 39 FUNC GLOBAL DEFAULT 14 matherr@GLIBC_2.2.5 With gold it shows 8: 00000000004006ad 39 FUNC GLOBAL DEFAULT 13 matherr 9: 0000000000402040 4 OBJECT GLOBAL DEFAULT 26 _LIB_VERSION@GLIBC_2.2.5 (2) I'm not sure, but it may be that gold is doing this because in my libm.so matherr shows up as 358: 0000000000008430 3 FUNC WEAK DEFAULT 13 matherr@@GLIBC_2.2.5 which is to say that it is the default version. And, as mentioned above, everything works as expected. What are the readelf -s --wide outputs on your system?
% gcc test.i -fuse-ld=bfd -lm % readelf -s --wide ./a.out | grep matherr 7: 000000000040066a 39 FUNC GLOBAL DEFAULT 14 matherr@GLIBC_2.2.5 60: 000000000040066a 39 FUNC GLOBAL DEFAULT 14 matherr@GLIBC_2.2.5 % readelf -s --wide ./a.out | grep _LIB_VERSION 5: 0000000000601040 4 OBJECT GLOBAL DEFAULT 25 _LIB_VERSION@GLIBC_2.2.5 (4) 59: 0000000000601040 4 OBJECT GLOBAL DEFAULT 25 _LIB_VERSION@GLIBC_2.2.5 % gcc test.i -fuse-ld=gold -lm % readelf -s --wide ./a.out | grep matherr 7: 000000000040066a 39 FUNC GLOBAL DEFAULT 13 matherr 28: 000000000040066a 39 FUNC GLOBAL DEFAULT 13 matherr 38: 000000000040066a 39 FUNC GLOBAL DEFAULT 13 matherr % readelf -s --wide ./a.out | grep _LIB_VERSION 8: 0000000000402030 4 OBJECT GLOBAL DEFAULT 25 _LIB_VERSION 41: 0000000000402030 4 OBJECT GLOBAL DEFAULT 25 _LIB_VERSION % readelf -s --wide /lib64/libm-2.26.90.so | grep matherr 348: 0000000000008560 3 FUNC WEAK DEFAULT 14 matherr@GLIBC_2.2.5 11: 0000000000000000 0 FILE LOCAL DEFAULT ABS s_matherr.c 1143: 0000000000008560 3 FUNC LOCAL DEFAULT 14 __matherr 2435: 0000000000008560 3 FUNC WEAK DEFAULT 14 matherr % readelf -s --wide /lib64/libm-2.26.90.so | grep _LIB_VERSION 313: 00000000000dd008 4 OBJECT GLOBAL DEFAULT 24 _LIB_VERSION@GLIBC_2.2.5 1142: 00000000000dd008 4 OBJECT LOCAL DEFAULT 24 _LIB_VERSION_INTERNAL 2432: 00000000000dd008 4 OBJECT GLOBAL DEFAULT 24 _LIB_VERSION