diff options
-rw-r--r-- | bfd/ChangeLog | 5 | ||||
-rw-r--r-- | bfd/elflink.c | 13 | ||||
-rw-r--r-- | ld/ChangeLog | 13 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/elf.exp | 12 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr21703-1.s | 6 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr21703-2.s | 6 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr21703-3.s | 15 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr21703-4.s | 15 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr21703-r.sd | 9 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr21703-shared.sd | 8 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr21703.sd | 4 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr21703.ver | 4 |
12 files changed, 110 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 73d1f4b..a534b21 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2017-10-24 Renlin Li <renlin.li@arm.com> + + PR ld/21703 + * elflink.c (_bfd_elf_merge_symbol): Handle multiple definition case. + 2017-10-23 Nick Clifton <nickc@redhat.com> PR 22319 diff --git a/bfd/elflink.c b/bfd/elflink.c index de13d04..20057f5 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -1036,6 +1036,7 @@ _bfd_elf_merge_symbol (bfd *abfd, bfd_boolean newweak, oldweak, newfunc, oldfunc; const struct elf_backend_data *bed; char *new_version; + bfd_boolean default_sym = *matched; *skip = FALSE; *override = FALSE; @@ -1557,6 +1558,18 @@ _bfd_elf_merge_symbol (bfd *abfd, sec = *psec; } + /* There are multiple definitions of a normal symbol. + Skip the default symbol as well. */ + if (olddef && !olddyn && !oldweak && newdef && !newdyn && !newweak + && !default_sym && h->def_regular) + { + /* Handle a multiple definition. */ + (*info->callbacks->multiple_definition) (info, &h->root, + abfd, sec, *pvalue); + *skip = TRUE; + return TRUE; + } + /* If both the old and the new symbols look like common symbols in a dynamic object, set the size of the symbol to the larger of the two. */ diff --git a/ld/ChangeLog b/ld/ChangeLog index ac96579..7319d72 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,16 @@ +2017-10-24 Renlin Li <renlin.li@arm.com> + + PR ld/21703 + * testsuite/ld-elf/elf.exp: Run new tests. + * testsuite/ld-elf/pr21703-1.s: New. + * testsuite/ld-elf/pr21703-2.s: New. + * testsuite/ld-elf/pr21703-3.s: New. + * testsuite/ld-elf/pr21703-4.s: New. + * testsuite/ld-elf/pr21703-r.sd: New. + * testsuite/ld-elf/pr21703-shared.sd: New. + * testsuite/ld-elf/pr21703.sd: New. + * testsuite/ld-elf/pr21703.ver: New. + 2017-10-23 H.J. Lu <hongjiu.lu@intel.com> * configure.tgt (i[3-7]86-*-linux-*): Move elf32_x86_64 from diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp index 655f0da..eac29e0 100644 --- a/ld/testsuite/ld-elf/elf.exp +++ b/ld/testsuite/ld-elf/elf.exp @@ -70,6 +70,18 @@ run_ld_link_tests [list \ {symbol3w.s} {} "symbol3w.a" ] \ ] +run_ld_link_tests [list \ + [list "PR ld/21703" \ + "--allow-multiple-definition tmpdir/pr21703-1.o tmpdir/pr21703-2.o" "" "" \ + {pr21703-1.s pr21703-2.s} {{readelf {-s} pr21703.sd}} "pr21703" ] \ + [list "PR ld/21703 -r" \ + "-r --allow-multiple-definition tmpdir/pr21703-3.o tmpdir/pr21703-4.o" "" "" \ + {pr21703-3.s pr21703-4.s} {{readelf {-s} pr21703-r.sd}} "pr21703.o" ] \ + [list "PR ld/21703 shared" \ + "-shared --allow-multiple-definition --version-script pr21703.ver tmpdir/pr21703-3.o tmpdir/pr21703-4.o" "" "" \ + {pr21703-3.s pr21703-4.s} {{readelf {--dyn-syms} pr21703-shared.sd}} "pr21703.so" ] \ +] + if { [check_shared_lib_support] } then { run_ld_link_tests { {"Build pr14170a.o" "" "" "" {pr14170a.s} {} "pr14170.a" } diff --git a/ld/testsuite/ld-elf/pr21703-1.s b/ld/testsuite/ld-elf/pr21703-1.s new file mode 100644 index 0000000..92a4718 --- /dev/null +++ b/ld/testsuite/ld-elf/pr21703-1.s @@ -0,0 +1,6 @@ + .text + .globl foo + .type foo, %function +foo: + .space 4 + .size foo, 4 diff --git a/ld/testsuite/ld-elf/pr21703-2.s b/ld/testsuite/ld-elf/pr21703-2.s new file mode 100644 index 0000000..1d65304 --- /dev/null +++ b/ld/testsuite/ld-elf/pr21703-2.s @@ -0,0 +1,6 @@ + .text + .globl foo + .type foo, %function +foo: + .space 16 + .size foo, 16 diff --git a/ld/testsuite/ld-elf/pr21703-3.s b/ld/testsuite/ld-elf/pr21703-3.s new file mode 100644 index 0000000..6da6de8 --- /dev/null +++ b/ld/testsuite/ld-elf/pr21703-3.s @@ -0,0 +1,15 @@ + .text + .global foo + .type foo, %function +foo: + .space 4 + .size foo, 4 + + .global foo1 + .type foo1, %function +foo1: + .space 32 + .size foo1, 32 + + .symver foo, foo@FOO + .symver foo1, foo@@FOO1 diff --git a/ld/testsuite/ld-elf/pr21703-4.s b/ld/testsuite/ld-elf/pr21703-4.s new file mode 100644 index 0000000..9390e94 --- /dev/null +++ b/ld/testsuite/ld-elf/pr21703-4.s @@ -0,0 +1,15 @@ + .text + .global bar + .type bar, %function +bar: + .space 16 + .size bar, 16 + + .global bar1 + .type bar1, %function +bar1: + .space 8 + .size bar1, 8 + + .symver bar, foo@FOO + .symver bar1, foo@@FOO1 diff --git a/ld/testsuite/ld-elf/pr21703-r.sd b/ld/testsuite/ld-elf/pr21703-r.sd new file mode 100644 index 0000000..6758088 --- /dev/null +++ b/ld/testsuite/ld-elf/pr21703-r.sd @@ -0,0 +1,9 @@ +Symbol table '.symtab' contains .* entries: +#... +.*: [0-9a-fA-F]* +4 +FUNC +GLOBAL +DEFAULT +. foo@FOO +.*: [0-9a-fA-F]* +32 +FUNC +GLOBAL +DEFAULT +. foo1 +.*: [0-9a-fA-F]* +32 +FUNC +GLOBAL +DEFAULT +. foo@@FOO1 +.*: [0-9a-fA-F]* +8 +FUNC +GLOBAL +DEFAULT +. bar1 +.*: [0-9a-fA-F]* +4 +FUNC +GLOBAL +DEFAULT +. foo +.*: [0-9a-fA-F]* +16 +FUNC +GLOBAL +DEFAULT +. bar +#pass diff --git a/ld/testsuite/ld-elf/pr21703-shared.sd b/ld/testsuite/ld-elf/pr21703-shared.sd new file mode 100644 index 0000000..9b6b1b9 --- /dev/null +++ b/ld/testsuite/ld-elf/pr21703-shared.sd @@ -0,0 +1,8 @@ +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name +#... + +[0-9]+: +[0-9a-f]+ +4 +FUNC +GLOBAL +DEFAULT +[0-9] +foo@FOO + +[0-9]+: +[0-9a-f]+ +0 +OBJECT +GLOBAL +DEFAULT +ABS +FOO1 + +[0-9]+: +[0-9a-f]+ +32 +FUNC +GLOBAL +DEFAULT +[0-9] +foo@@FOO1 + +[0-9]+: +[0-9a-f]+ +0 +OBJECT +GLOBAL +DEFAULT +ABS +FOO +#... diff --git a/ld/testsuite/ld-elf/pr21703.sd b/ld/testsuite/ld-elf/pr21703.sd new file mode 100644 index 0000000..955cf17 --- /dev/null +++ b/ld/testsuite/ld-elf/pr21703.sd @@ -0,0 +1,4 @@ +Symbol table '.symtab' contains .* entries: +#... +.*: [0-9a-fA-F]* +4 +FUNC +GLOBAL +DEFAULT +. foo +#pass diff --git a/ld/testsuite/ld-elf/pr21703.ver b/ld/testsuite/ld-elf/pr21703.ver new file mode 100644 index 0000000..c36f292 --- /dev/null +++ b/ld/testsuite/ld-elf/pr21703.ver @@ -0,0 +1,4 @@ +FOO +{ global: foo; local: *; }; +FOO1 +{ global: foo; local: *; }; |