https://sourceware.org/bugzilla/show_bug.cgi?id=16457
Bug ID: 16457 Summary: Weak reference leads to bogus entry in .gnu.version_r section Product: binutils Version: 2.24 Status: NEW Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: ldv at altlinux dot org Weak reference may cause ld to generate an entry in .gnu.version_r section that would reference an object not present in the dynamic section. This actually happens with most of c++ objects that have weak references to versioned symbols from libpthread. Here is an artificial test case without c++ and foreign libraries: $ cat libb.c int fb(void){return 0;} $ cat libb.map FOO{global:fb;}; $ gcc -shared -Wl,-soname,libb.so,--version-script,libb.map -Wall -Werror -fPIC -o libb.so libb.c $ cat liba.c int fb(void); int fa(void){return fb();} $ gcc -shared -Wl,--no-undefined,-soname,liba.so -Wall -Werror -fPIC -o liba.so liba.c -L. -lb $ cat e.c int fa(void); int fb(void) __attribute__((weak)); int main(void){return fb?fb():fa();} $ gcc -Wall -Werror e.c -Wl,--rpath-link,. -L. -la -o e $ readelf -Wd e | grep -F NEEDED 0x0000000000000001 (NEEDED) Shared library: [liba.so] 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] $ readelf -WV e Version symbols section '.gnu.version' contains 13 entries: Addr: 00000000004004e8 Offset: 0x0004e8 Link: 5 (.dynsym) 000: 0 (*local*) 0 (*local*) 2 (GLIBC_2.2.5) 0 (*local*) 004: 0 (*local*) 0 (*local*) 0 (*local*) 1 (*global*) 008: 1 (*global*) 1 (*global*) 1 (*global*) 1 (*global*) 00c: 3 (FOO) Version needs section '.gnu.version_r' contains 2 entries: Addr: 0x0000000000400508 Offset: 0x000508 Link: 6 (.dynstr) 000000: Version: 1 File: libb.so Cnt: 1 0x0010: Name: FOO Flags: none Version: 3 0x0020: Version: 1 File: libc.so.6 Cnt: 1 0x0030: Name: GLIBC_2.2.5 Flags: none Version: 2 Note that there is no DT_NEEDED entry for libb.so, but the latter is referenced from .gnu.version_r section. Older ld versions used to add a DT_NEEDED entry in this case, see https://sourceware.org/bugzilla/show_bug.cgi?id=15149 -- You are receiving this mail because: You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils