From: nobody <> Date: Wed, 19 Sep 2012 00:53:31 +0000 (+0000) Subject: This commit was manufactured by cvs2svn to create branch 'binutils- X-Git-Tag: binutils-2_23~39 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3bc079a79eb8922ca8c812af67f55b25d07b866e;p=thirdparty%2Fbinutils-gdb.git This commit was manufactured by cvs2svn to create branch 'binutils- 2_23-branch'. Cherrypick from master 2012-09-19 00:53:30 UTC H.J. Lu '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 --- diff --git a/ld/testsuite/ld-elf/comm-data3.sd b/ld/testsuite/ld-elf/comm-data3.sd new file mode 100644 index 00000000000..5a96ed7f871 --- /dev/null +++ b/ld/testsuite/ld-elf/comm-data3.sd @@ -0,0 +1,3 @@ +#... + +[0-9]+: +[0-9a-f]+ +4 +OBJECT +GLOBAL +DEFAULT +[1-9] foo +#pass diff --git a/ld/testsuite/ld-elf/comm-data3a.s b/ld/testsuite/ld-elf/comm-data3a.s new file mode 100644 index 00000000000..e0bde49c894 --- /dev/null +++ b/ld/testsuite/ld-elf/comm-data3a.s @@ -0,0 +1,11 @@ + .globl main + .globl start + .globl _start + .globl __start + .text +main: +start: +_start: +__start: + .byte 0 + .common foo,4,4 diff --git a/ld/testsuite/ld-elf/comm-data3b.s b/ld/testsuite/ld-elf/comm-data3b.s new file mode 100644 index 00000000000..837a0998f26 --- /dev/null +++ b/ld/testsuite/ld-elf/comm-data3b.s @@ -0,0 +1,6 @@ + .weak foo + .type foo,%function + .size foo,1 + .text +foo: + .byte 1 diff --git a/ld/testsuite/ld-ifunc/ifunc-17a-i386.d b/ld/testsuite/ld-ifunc/ifunc-17a-i386.d new file mode 100644 index 00000000000..303b54eb50b --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-17a-i386.d @@ -0,0 +1,10 @@ +#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 diff --git a/ld/testsuite/ld-ifunc/ifunc-17a-x86-64.d b/ld/testsuite/ld-ifunc/ifunc-17a-x86-64.d new file mode 100644 index 00000000000..965ef6343dc --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-17a-x86-64.d @@ -0,0 +1,10 @@ +#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 diff --git a/ld/testsuite/ld-ifunc/ifunc-17a.s b/ld/testsuite/ld-ifunc/ifunc-17a.s new file mode 100644 index 00000000000..e0bde49c894 --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-17a.s @@ -0,0 +1,11 @@ + .globl main + .globl start + .globl _start + .globl __start + .text +main: +start: +_start: +__start: + .byte 0 + .common foo,4,4 diff --git a/ld/testsuite/ld-ifunc/ifunc-17b-i386.d b/ld/testsuite/ld-ifunc/ifunc-17b-i386.d new file mode 100644 index 00000000000..82ccac2feaf --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-17b-i386.d @@ -0,0 +1,10 @@ +#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 diff --git a/ld/testsuite/ld-ifunc/ifunc-17b-x86-64.d b/ld/testsuite/ld-ifunc/ifunc-17b-x86-64.d new file mode 100644 index 00000000000..7527eae9be7 --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-17b-x86-64.d @@ -0,0 +1,10 @@ +#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 diff --git a/ld/testsuite/ld-ifunc/ifunc-17b.s b/ld/testsuite/ld-ifunc/ifunc-17b.s new file mode 100644 index 00000000000..66abe04559e --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-17b.s @@ -0,0 +1,6 @@ + .weak foo + .type foo, %gnu_indirect_function + .size foo,1 + .text +foo: + .byte 1 diff --git a/ld/testsuite/ld-ifunc/ifunc-common-1.out b/ld/testsuite/ld-ifunc/ifunc-common-1.out new file mode 100644 index 00000000000..31a3ce2e544 --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-common-1.out @@ -0,0 +1 @@ +PASSED: 0 diff --git a/ld/testsuite/ld-ifunc/ifunc-common-1a.c b/ld/testsuite/ld-ifunc/ifunc-common-1a.c new file mode 100644 index 00000000000..794ca452bcd --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-common-1a.c @@ -0,0 +1,9 @@ +#include + +int foo; +int +main () +{ + printf ("PASSED: %d\n", foo); + return 0; +} diff --git a/ld/testsuite/ld-ifunc/ifunc-common-1b.c b/ld/testsuite/ld-ifunc/ifunc-common-1b.c new file mode 100644 index 00000000000..12359425755 --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-common-1b.c @@ -0,0 +1,12 @@ +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; +}