summaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@mips.com>2018-04-09 13:42:01 +0100
committerMaciej W. Rozycki <macro@mips.com>2018-04-09 13:42:01 +0100
commitd52e3d06e5db7041913278caace3389504c0478c (patch)
tree1480a5d003446c1f36261e9439f9291adb23647a /binutils
parentaec2e0d252342aa7575aff608e999a36f27a9147 (diff)
downloadbinutils-gdb-d52e3d06e5db7041913278caace3389504c0478c.tar.gz
binutils/testsuite: Fix a crash with STN_UNDEF in relocation
Verify that `strip' completes successfully and a correct relocation entry is copied for a relocation encountered with the STN_UNDEF symbol index. binutils/ * testsuite/binutils-all/strip-15.d: New test. * testsuite/binutils-all/strip-15rel.s: New test source. * testsuite/binutils-all/strip-15rela.s: New test source. * testsuite/binutils-all/strip-15mips64.s: New test source. * testsuite/binutils-all/objcopy.exp: Run the new test.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog8
-rw-r--r--binutils/testsuite/binutils-all/objcopy.exp5
-rw-r--r--binutils/testsuite/binutils-all/strip-15.d8
-rw-r--r--binutils/testsuite/binutils-all/strip-15mips64.s14
-rw-r--r--binutils/testsuite/binutils-all/strip-15rel.s23
-rw-r--r--binutils/testsuite/binutils-all/strip-15rela.s27
6 files changed, 85 insertions, 0 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 0c1b95d21bc..c7a631aa821 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,5 +1,13 @@
2018-04-09 Maciej W. Rozycki <macro@mips.com>
+ * testsuite/binutils-all/strip-15.d: New test.
+ * testsuite/binutils-all/strip-15rel.s: New test source.
+ * testsuite/binutils-all/strip-15rela.s: New test source.
+ * testsuite/binutils-all/strip-15mips64.s: New test source.
+ * testsuite/binutils-all/objcopy.exp: Run the new test.
+
+2018-04-09 Maciej W. Rozycki <macro@mips.com>
+
* testsuite/binutils-all/strip-14.d: New test.
* testsuite/binutils-all/strip-14rel.s: New test source.
* testsuite/binutils-all/strip-14rela.s: New test source.
diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp
index 532bdc6ac76..366a4a34f89 100644
--- a/binutils/testsuite/binutils-all/objcopy.exp
+++ b/binutils/testsuite/binutils-all/objcopy.exp
@@ -1123,6 +1123,11 @@ if [is_elf_format] {
[list as "--defsym RELOC=${reloc}"] \
[list as [expr {[is_elf64 tmpdir/bintest.o] \
? "--defsym ELF64=1" : ""}]]]
+ run_dump_test "strip-15" [list \
+ [list source strip-15${reloc_format}.s] \
+ [list as "--defsym RELOC=${reloc}"] \
+ [list as [expr {[is_elf64 tmpdir/bintest.o] \
+ ? "--defsym ELF64=1" : ""}]]]
# This requires STB_GNU_UNIQUE support with OSABI set to GNU.
if { [supports_gnu_unique] } {
diff --git a/binutils/testsuite/binutils-all/strip-15.d b/binutils/testsuite/binutils-all/strip-15.d
new file mode 100644
index 00000000000..03d7d1a78d6
--- /dev/null
+++ b/binutils/testsuite/binutils-all/strip-15.d
@@ -0,0 +1,8 @@
+#PROG: strip
+#strip: -g
+#readelf: -r
+
+Relocation section '\.rela?\.text' at offset .* contains 2 entries:
+ *Offset * Info * Type * Sym\. *Value * Sym\. *Name(?: * \+ * Addend)?
+0+00 * 0+0(?:1|32|103) * R_[^ ]* *(?: * 55aa)?
+#pass
diff --git a/binutils/testsuite/binutils-all/strip-15mips64.s b/binutils/testsuite/binutils-all/strip-15mips64.s
new file mode 100644
index 00000000000..a15c3772ca6
--- /dev/null
+++ b/binutils/testsuite/binutils-all/strip-15mips64.s
@@ -0,0 +1,14 @@
+ .text
+foo:
+ .dc.l 0x12345678
+
+ .section .rela.text
+ .dc.a 0
+ .dc.l 0x00000000
+ .dc.b 0, 0, 0, RELOC
+ .dc.a 0x000055aa
+
+ .dc.a 0
+ .dc.l 0
+ .dc.b 0, 0, 0, 0
+ .dc.a 0
diff --git a/binutils/testsuite/binutils-all/strip-15rel.s b/binutils/testsuite/binutils-all/strip-15rel.s
new file mode 100644
index 00000000000..1819a539e17
--- /dev/null
+++ b/binutils/testsuite/binutils-all/strip-15rel.s
@@ -0,0 +1,23 @@
+ .text
+foo:
+ .dc.l 0x12345678
+
+ .section .rel.text
+ .ifdef ELF64
+
+ .dc.a 0
+ .dc.a RELOC
+
+ .dc.a 0
+ .dc.a 0
+ .else
+
+ # Some targets, such as `m68hc11-*', use 16-bit addresses.
+ # With them `.dc.a' emits 16-bit quantities, so we need to use
+ # `.dc.l' for 32-bit relocation data.
+ .dc.l 0
+ .dc.l RELOC
+
+ .dc.l 0
+ .dc.l 0
+ .endif
diff --git a/binutils/testsuite/binutils-all/strip-15rela.s b/binutils/testsuite/binutils-all/strip-15rela.s
new file mode 100644
index 00000000000..7bcd85e2836
--- /dev/null
+++ b/binutils/testsuite/binutils-all/strip-15rela.s
@@ -0,0 +1,27 @@
+ .text
+foo:
+ .dc.l 0x12345678
+
+ .section .rela.text
+ .ifdef ELF64
+
+ .dc.a 0
+ .dc.a RELOC
+ .dc.a 0x00000000000055aa
+
+ .dc.a 0
+ .dc.a 0
+ .dc.a 0
+ .else
+
+ # Some targets, such as `h8300-*' or `ip2k-*', use 16-bit addresses.
+ # With them `.dc.a' emits 16-bit quantities, so we need to use
+ # `.dc.l' for 32-bit relocation data.
+ .dc.l 0
+ .dc.l RELOC
+ .dc.l 0x000055aa
+
+ .dc.l 0
+ .dc.l 0
+ .dc.l 0
+ .endif