See https://bugzilla.redhat.com/show_bug.cgi?id=512937 No SHN_UNDEF symbols should ever have STT_GNU_IFUNC type, they should be STT_FUNC instead. Whether a symbol in the shared library some other shared library or binary is linked dynamically against is STT_GNU_IFUNC or not doesn't say anything about whether it will be actually indirect or direct function call at runtime. IFUNC is always only a property of a symbol definition. Especially for PLT SHN_UNDEF symbols with non-zero st_value this is fatal problem, see e.g. https://bugzilla.redhat.com/show_bug.cgi?id=512078
Testcase: BINUTILS_OBJ=/usr/src/binutils/obj BINUTILS_SRC=/usr/src/binutils gcc -B$BINUTILS_OBJ/ld/tmpdir/gas/ -I$BINUTILS_SRC/ld/testsuite/ld-ifunc -g -O2 \ -c -fPIC -DWITH_IFUNC -c $BINUTILS_SRC/ld/testsuite/ld-ifunc/lib.c \ -o shared_ifunc.o $BINUTILS_OBJ/ld/ld-new -o libshared_ifunc.so -shared shared_ifunc.o echo 'extern int library_func2 (void);' > test.c echo 'int main (void) { library_func2 (); return 0; }' >> test.c gcc -B $BINUTILS_OBJ/ld/tmpdir/ld/ -o test test.c ./libshared_ifunc.so $BINUTILS_OBJ/binutils/readelf -Ws test | grep IFUNC.*UND echo 'extern int library_func2 (void);' > test2.c echo 'int (*fn) (void) = library_func2;' >> test2.c echo 'int main (void) { fn (); return 0; }' >> test2.c gcc -B $BINUTILS_OBJ/ld/tmpdir/ld/ -o test2 test2.c ./libshared_ifunc.so $BINUTILS_OBJ/binutils/readelf -Ws test2 | grep IFUNC.*UND Should print nothing, prints: 1: 0000000000000000 0 IFUNC GLOBAL DEFAULT UND library_func2 49: 0000000000000000 0 IFUNC GLOBAL DEFAULT UND library_func2 5: 0000000000400458 0 IFUNC GLOBAL DEFAULT UND library_func2 49: 0000000000400458 0 IFUNC GLOBAL DEFAULT UND library_func2 with CVS trunk. -- Summary: ld incorrectly creates STT_GNU_IFUNC SHN_UNDEF symbols Product: binutils Version: 2.20 (HEAD) Status: NEW Severity: normal Priority: P2 Component: ld AssignedTo: unassigned at sources dot redhat dot com ReportedBy: jakub at redhat dot com CC: bug-binutils at gnu dot org,hjl dot tools at gmail dot com http://sourceware.org/bugzilla/show_bug.cgi?id=10426 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils