2_23-branch'.
Cherrypick from master 2012-09-19 00:53:30 UTC H.J. Lu <hjl.tools@gmail.com> 'Properly handle common symbol and weak function':
ld/testsuite/ld-elf/comm-data3.sd
ld/testsuite/ld-elf/comm-data3a.s
ld/testsuite/ld-elf/comm-data3b.s
ld/testsuite/ld-ifunc/ifunc-17a-i386.d
ld/testsuite/ld-ifunc/ifunc-17a-x86-64.d
ld/testsuite/ld-ifunc/ifunc-17a.s
ld/testsuite/ld-ifunc/ifunc-17b-i386.d
ld/testsuite/ld-ifunc/ifunc-17b-x86-64.d
ld/testsuite/ld-ifunc/ifunc-17b.s
ld/testsuite/ld-ifunc/ifunc-common-1.out
ld/testsuite/ld-ifunc/ifunc-common-1a.c
ld/testsuite/ld-ifunc/ifunc-common-1b.c
12 files changed:
--- /dev/null
+#...
+ +[0-9]+: +[0-9a-f]+ +4 +OBJECT +GLOBAL +DEFAULT +[1-9] foo
+#pass
--- /dev/null
+ .globl main
+ .globl start
+ .globl _start
+ .globl __start
+ .text
+main:
+start:
+_start:
+__start:
+ .byte 0
+ .common foo,4,4
--- /dev/null
+ .weak foo
+ .type foo,%function
+ .size foo,1
+ .text
+foo:
+ .byte 1
--- /dev/null
+#source: ifunc-17a.s
+#source: ifunc-17b.s
+#ld: -static -m elf_i386
+#as: --32
+#readelf: -s --wide
+#target: x86_64-*-* i?86-*-*
+
+#...
+ +[0-9]+: +[0-9a-f]+ +4 +OBJECT +GLOBAL +DEFAULT +[1-9] foo
+#pass
--- /dev/null
+#source: ifunc-17a.s
+#source: ifunc-17b.s
+#ld: -static -m elf_x86_64
+#as: --64
+#readelf: -s --wide
+#target: x86_64-*-*
+
+#...
+ +[0-9]+: +[0-9a-f]+ +4 +OBJECT +GLOBAL +DEFAULT +[1-9] foo
+#pass
--- /dev/null
+ .globl main
+ .globl start
+ .globl _start
+ .globl __start
+ .text
+main:
+start:
+_start:
+__start:
+ .byte 0
+ .common foo,4,4
--- /dev/null
+#source: ifunc-17b.s
+#source: ifunc-17a.s
+#ld: -static -m elf_i386
+#as: --32
+#readelf: -s --wide
+#target: x86_64-*-* i?86-*-*
+
+#...
+ +[0-9]+: +[0-9a-f]+ +4 +OBJECT +GLOBAL +DEFAULT +[1-9] foo
+#pass
--- /dev/null
+#source: ifunc-17b.s
+#source: ifunc-17a.s
+#ld: -static -m elf_x86_64
+#as: --64
+#readelf: -s --wide
+#target: x86_64-*-*
+
+#...
+ +[0-9]+: +[0-9a-f]+ +4 +OBJECT +GLOBAL +DEFAULT +[1-9] foo
+#pass
--- /dev/null
+ .weak foo
+ .type foo, %gnu_indirect_function
+ .size foo,1
+ .text
+foo:
+ .byte 1
--- /dev/null
+#include <stdio.h>
+
+int foo;
+int
+main ()
+{
+ printf ("PASSED: %d\n", foo);
+ return 0;
+}
--- /dev/null
+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;
+}