[hjl@gnu-6 pr14590]$ cat x.c #include <stdio.h> int foo; int main () { foo = getchar (); return foo != 0; } [hjl@gnu-6 pr14590]$ cat y.c void alt (void) { } void foo (void); void * foo_ifunc (void) __asm__ ("foo"); //__asm__(".type foo, %gnu_indirect_function"); __asm__(".weak foo"); void * foo_ifunc (void) { return alt; } [hjl@gnu-6 pr14590]$ make gcc -B./ -g -c -o x.o x.c gcc -B./ -g -c -o y.o y.c gcc -B./ -static -o x x.o y.o readelf -s --wide x | grep foo 1793: 00000000006b4f70 4 FUNC GLOBAL DEFAULT 26 foo echo 0 | ./x make: *** [all] Error 1 [hjl@gnu-6 pr14590]$ "foo" should be marked as OBJECT, not FUNC.
*** Bug 14590 has been marked as a duplicate of this bug. ***
A patch is posted at: http://sourceware.org/ml/binutils/2012-09/msg00219.html
CVSROOT: /cvs/src Module name: src Changes by: hjl@sourceware.org 2012-09-19 00:53:31 Modified files: bfd : ChangeLog elf-bfd.h elf32-sh-symbian.c elflink.c ld/testsuite : ChangeLog ld/testsuite/ld-elf: comm-data.exp ld/testsuite/ld-ifunc: ifunc.exp Added files: ld/testsuite/ld-elf: comm-data3.sd comm-data3a.s comm-data3b.s ld/testsuite/ld-ifunc: ifunc-17a-i386.d ifunc-17a-x86-64.d ifunc-17a.s ifunc-17b-i386.d ifunc-17b-x86-64.d ifunc-17b.s ifunc-common-1.out ifunc-common-1a.c ifunc-common-1b.c Log message: Properly handle common symbol and weak function bfd/ PR ld/14591 * elf-bfd.h (_bfd_elf_merge_symbol): Add an argument to return if the old symbol is weak. * elf32-sh-symbian.c (sh_symbian_relocate_section): Update _bfd_elf_merge_symbol call. * elflink.c (_bfd_elf_merge_symbol): Add an argument to return if the old symbol is weak. (_bfd_elf_add_default_symbol): Update _bfd_elf_merge_symbol call. (elf_link_add_object_symbols): Don't update symbol type from a weak definition. Update symbol type from a common symbol when overriding a weak symbol. ld/testsuite/ PR ld/14591 * ld-elf/comm-data.exp (run_ld_link_tests): Add comm-data3a and comm-data3b tests. * ld-ifunc/ifunc.exp (run_ld_link_exec_tests): New. * ld-elf/comm-data3.sd: New file. * ld-elf/comm-data3a.s: Likewise. * ld-elf/comm-data3b.s: Likewise. * ld-ifunc/ifunc-17a-i386.d: Likewise. * ld-ifunc/ifunc-17a-x86-64.d: Likewise. * ld-ifunc/ifunc-17a.s: Likewise. * ld-ifunc/ifunc-17b-i386.d: Likewise. * ld-ifunc/ifunc-17b-x86-64.d: Likewise. * ld-ifunc/ifunc-17b.s: Likewise. * ld-ifunc/ifunc-common-1.out: Likewise. * ld-ifunc/ifunc-common-1a.c: Likewise. * ld-ifunc/ifunc-common-1b.c: Likewise. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.5809&r2=1.5810 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf-bfd.h.diff?cvsroot=src&r1=1.346&r2=1.347 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-sh-symbian.c.diff?cvsroot=src&r1=1.15&r2=1.16 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elflink.c.diff?cvsroot=src&r1=1.453&r2=1.454 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1605&r2=1.1606 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/comm-data3.sd.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/comm-data3a.s.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/comm-data3b.s.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/comm-data.exp.diff?cvsroot=src&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-17a-i386.d.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-17a-x86-64.d.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-17a.s.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-17b-i386.d.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-17b-x86-64.d.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-17b.s.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-common-1.out.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-common-1a.c.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-common-1b.c.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc.exp.diff?cvsroot=src&r1=1.13&r2=1.14
CVSROOT: /cvs/src Module name: src Branch: binutils-2_23-branch Changes by: gingold@sourceware.org 2012-09-24 12:22:49 Modified files: bfd : ChangeLog elf-bfd.h elf32-sh-symbian.c elflink.c ld/testsuite : ChangeLog ld/testsuite/ld-elf: comm-data.exp ld/testsuite/ld-ifunc: ifunc.exp Added files: ld/testsuite/ld-elf: comm-data3.sd comm-data3a.s comm-data3b.s ld/testsuite/ld-ifunc: ifunc-17a-i386.d ifunc-17a-x86-64.d ifunc-17a.s ifunc-17b-i386.d ifunc-17b-x86-64.d ifunc-17b.s ifunc-common-1.out ifunc-common-1a.c ifunc-common-1b.c Log message: bfd/ 2012-09-18 H.J. Lu <hongjiu.lu@intel.com> PR ld/14591 * elf-bfd.h (_bfd_elf_merge_symbol): Add an argument to return if the old symbol is weak. * elf32-sh-symbian.c (sh_symbian_relocate_section): Update _bfd_elf_merge_symbol call. * elflink.c (_bfd_elf_merge_symbol): Add an argument to return if the old symbol is weak. (_bfd_elf_add_default_symbol): Update _bfd_elf_merge_symbol call. (elf_link_add_object_symbols): Don't update symbol type from a weak definition. Update symbol type from a common symbol when overriding a weak symbol. ld/testsuite/ 2012-09-18 H.J. Lu <hongjiu.lu@intel.com> PR ld/14591 * ld-elf/comm-data.exp (run_ld_link_tests): Add comm-data3a and comm-data3b tests. * ld-ifunc/ifunc.exp (run_ld_link_exec_tests): New. * ld-elf/comm-data3.sd: New file. * ld-elf/comm-data3a.s: Likewise. * ld-elf/comm-data3b.s: Likewise. * ld-ifunc/ifunc-17a-i386.d: Likewise. * ld-ifunc/ifunc-17a-x86-64.d: Likewise. * ld-ifunc/ifunc-17a.s: Likewise. * ld-ifunc/ifunc-17b-i386.d: Likewise. * ld-ifunc/ifunc-17b-x86-64.d: Likewise. * ld-ifunc/ifunc-17b.s: Likewise. * ld-ifunc/ifunc-common-1.out: Likewise. * ld-ifunc/ifunc-common-1a.c: Likewise. * ld-ifunc/ifunc-common-1b.c: Likewise. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_23-branch&r1=1.5758.2.17&r2=1.5758.2.18 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf-bfd.h.diff?cvsroot=src&only_with_tag=binutils-2_23-branch&r1=1.343.2.1&r2=1.343.2.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-sh-symbian.c.diff?cvsroot=src&only_with_tag=binutils-2_23-branch&r1=1.15&r2=1.15.12.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elflink.c.diff?cvsroot=src&only_with_tag=binutils-2_23-branch&r1=1.450.4.1&r2=1.450.4.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_23-branch&r1=1.1579.2.5&r2=1.1579.2.6 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/comm-data3.sd.diff?cvsroot=src&only_with_tag=binutils-2_23-branch&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/comm-data3a.s.diff?cvsroot=src&only_with_tag=binutils-2_23-branch&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/comm-data3b.s.diff?cvsroot=src&only_with_tag=binutils-2_23-branch&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/comm-data.exp.diff?cvsroot=src&only_with_tag=binutils-2_23-branch&r1=1.3&r2=1.3.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-17a-i386.d.diff?cvsroot=src&only_with_tag=binutils-2_23-branch&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-17a-x86-64.d.diff?cvsroot=src&only_with_tag=binutils-2_23-branch&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-17a.s.diff?cvsroot=src&only_with_tag=binutils-2_23-branch&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-17b-i386.d.diff?cvsroot=src&only_with_tag=binutils-2_23-branch&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-17b-x86-64.d.diff?cvsroot=src&only_with_tag=binutils-2_23-branch&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-17b.s.diff?cvsroot=src&only_with_tag=binutils-2_23-branch&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-common-1.out.diff?cvsroot=src&only_with_tag=binutils-2_23-branch&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-common-1a.c.diff?cvsroot=src&only_with_tag=binutils-2_23-branch&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-common-1b.c.diff?cvsroot=src&only_with_tag=binutils-2_23-branch&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc.exp.diff?cvsroot=src&only_with_tag=binutils-2_23-branch&r1=1.13&r2=1.13.2.1
Fixed in 2.23.