aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRenlin Li <renlin.li@arm.com>2017-10-24 12:42:30 +0100
committerRenlin Li <renlin.li@arm.com>2017-10-24 13:01:48 +0100
commit93f4de3929aeb3e21d57950bfa96539599a92f2a (patch)
tree0ff309d325abe18c23c96887731b1b0b5a2463e6 /ld/testsuite/ld-elf
parentReindent gdb.threads/attach-into-signal.exp (diff)
downloadbinutils-gdb-93f4de3929aeb3e21d57950bfa96539599a92f2a.tar.gz
binutils-gdb-93f4de3929aeb3e21d57950bfa96539599a92f2a.tar.bz2
binutils-gdb-93f4de3929aeb3e21d57950bfa96539599a92f2a.zip
[BFD][PR21703]Override the new defined symbol with the old normal symbol when --allow-multiple-definition is provided.
The behavior of _bfd_elf_merge_symbol and _bfd_generic_link_add_one_symbol is inconsistent. In multiple definition case, _bfd_elf_merge_symbol decided to override the old symbol definition with the new defintion, (size, type, target data) In _bfd_generic_link_add_one_symbol, it simply return without doing anything because of allow-multiple-definition is provided. This leaves the symbol in a wrong state. Here, following the documentation, I made this patch to force the old definition override the new definition if the old symbol is not dynamic or weak. Because, in those two cases, it's expected to do some merge. I have checked that, those two cases are properly handled. bfd/ PR ld/21703 * elflink.c (_bfd_elf_merge_symbol): Handle multiple definition case. ld/ 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.
Diffstat (limited to 'ld/testsuite/ld-elf')
-rw-r--r--ld/testsuite/ld-elf/elf.exp12
-rw-r--r--ld/testsuite/ld-elf/pr21703-1.s6
-rw-r--r--ld/testsuite/ld-elf/pr21703-2.s6
-rw-r--r--ld/testsuite/ld-elf/pr21703-3.s15
-rw-r--r--ld/testsuite/ld-elf/pr21703-4.s15
-rw-r--r--ld/testsuite/ld-elf/pr21703-r.sd9
-rw-r--r--ld/testsuite/ld-elf/pr21703-shared.sd8
-rw-r--r--ld/testsuite/ld-elf/pr21703.sd4
-rw-r--r--ld/testsuite/ld-elf/pr21703.ver4
9 files changed, 79 insertions, 0 deletions
diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp
index 655f0daf230..eac29e03902 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 00000000000..92a47184029
--- /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 00000000000..1d65304470d
--- /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 00000000000..6da6de8cfd1
--- /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 00000000000..9390e9444e1
--- /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 00000000000..6758088179d
--- /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 00000000000..9b6b1b928dd
--- /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 00000000000..955cf172e2f
--- /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 00000000000..c36f2928891
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21703.ver
@@ -0,0 +1,4 @@
+FOO
+{ global: foo; local: *; };
+FOO1
+{ global: foo; local: *; };