diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2012-09-19 00:53:30 +0000 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2012-09-19 00:53:30 +0000 |
commit | 37a9e49a286b6c0b9e34387921b90c0ffa731516 (patch) | |
tree | 065d205cdcf4f3fd4e8b37d51a479eebde2e6a7f /ld | |
parent | 91b96a45e3265661c6f686ae9050100b8df2794f (diff) | |
download | gdb-37a9e49a286b6c0b9e34387921b90c0ffa731516.zip gdb-37a9e49a286b6c0b9e34387921b90c0ffa731516.tar.gz gdb-37a9e49a286b6c0b9e34387921b90c0ffa731516.tar.bz2 |
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.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/testsuite/ChangeLog | 21 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/comm-data.exp | 20 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/comm-data3.sd | 3 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/comm-data3a.s | 11 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/comm-data3b.s | 6 | ||||
-rw-r--r-- | ld/testsuite/ld-ifunc/ifunc-17a-i386.d | 10 | ||||
-rw-r--r-- | ld/testsuite/ld-ifunc/ifunc-17a-x86-64.d | 10 | ||||
-rw-r--r-- | ld/testsuite/ld-ifunc/ifunc-17a.s | 11 | ||||
-rw-r--r-- | ld/testsuite/ld-ifunc/ifunc-17b-i386.d | 10 | ||||
-rw-r--r-- | ld/testsuite/ld-ifunc/ifunc-17b-x86-64.d | 10 | ||||
-rw-r--r-- | ld/testsuite/ld-ifunc/ifunc-17b.s | 6 | ||||
-rw-r--r-- | ld/testsuite/ld-ifunc/ifunc-common-1.out | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-ifunc/ifunc-common-1a.c | 9 | ||||
-rw-r--r-- | ld/testsuite/ld-ifunc/ifunc-common-1b.c | 12 | ||||
-rw-r--r-- | ld/testsuite/ld-ifunc/ifunc.exp | 21 |
15 files changed, 161 insertions, 0 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index c969379..bca8bbb 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,24 @@ +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. + 2012-09-17 H.J. Lu <hongjiu.lu@intel.com> * ld-elf/shared.exp (build_cxx_tests): Move out the commented out diff --git a/ld/testsuite/ld-elf/comm-data.exp b/ld/testsuite/ld-elf/comm-data.exp index 2258afb..1c75f55 100644 --- a/ld/testsuite/ld-elf/comm-data.exp +++ b/ld/testsuite/ld-elf/comm-data.exp @@ -75,4 +75,24 @@ run_ld_link_tests [list \ } \ "comm-data" \ ] \ + [list \ + "$testname 3a" \ + "-static" \ + "" \ + { comm-data3a.s comm-data3b.s } \ + { \ + { readelf -s comm-data3.sd } \ + } \ + "comm-data3a" \ + ] \ + [list \ + "$testname 3b" \ + "-static" \ + "" \ + { comm-data3b.s comm-data3a.s } \ + { \ + { readelf -s comm-data3.sd } \ + } \ + "comm-data3b" \ + ] \ ] diff --git a/ld/testsuite/ld-elf/comm-data3.sd b/ld/testsuite/ld-elf/comm-data3.sd new file mode 100644 index 0000000..5a96ed7 --- /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 0000000..e0bde49 --- /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 0000000..837a099 --- /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 0000000..303b54e --- /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 0000000..965ef63 --- /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 0000000..e0bde49 --- /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 0000000..82ccac2 --- /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 0000000..7527eae --- /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 0000000..66abe04 --- /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 0000000..31a3ce2 --- /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 0000000..794ca45 --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-common-1a.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +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 0000000..1235942 --- /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; +} diff --git a/ld/testsuite/ld-ifunc/ifunc.exp b/ld/testsuite/ld-ifunc/ifunc.exp index 3eef3a9..df913d8 100644 --- a/ld/testsuite/ld-ifunc/ifunc.exp +++ b/ld/testsuite/ld-ifunc/ifunc.exp @@ -347,6 +347,27 @@ if { $verbose < 1 } { remote_file host delete "tmpdir/static_nonifunc_prog" } +run_ld_link_exec_tests [] [list \ + [list \ + "Common symbol override ifunc test 1a" \ + "-static" \ + "" \ + { ifunc-common-1a.c ifunc-common-1b.c } \ + "ifunc-common-1a" \ + "ifunc-common-1.out" \ + "-g" \ + ] \ + [list \ + "Common symbol override ifunc test 1b" \ + "-static" \ + "" \ + { ifunc-common-1b.c ifunc-common-1a.c } \ + "ifunc-common-1b" \ + "ifunc-common-1.out" \ + "-g" \ + ] \ +] + set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]] foreach t $test_list { # We need to strip the ".d", but can leave the dirname. |