[PATCH 2/2] binutils/testsuite: Fix a crash with STN_UNDEF in relocation
Maciej W. Rozycki
macro@mips.com
Fri Apr 6 14:47:00 GMT 2018
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.
---
Hi,
No issues in regression testing. OK to apply?
Maciej
---
binutils/testsuite/binutils-all/objcopy.exp | 5 ++++
binutils/testsuite/binutils-all/strip-15.d | 8 ++++++
binutils/testsuite/binutils-all/strip-15mips64.s | 14 +++++++++++
binutils/testsuite/binutils-all/strip-15rel.s | 23 +++++++++++++++++++
binutils/testsuite/binutils-all/strip-15rela.s | 27 +++++++++++++++++++++++
5 files changed, 77 insertions(+)
binutils-strip-15-test.diff
Index: binutils/binutils/testsuite/binutils-all/objcopy.exp
===================================================================
--- binutils.orig/binutils/testsuite/binutils-all/objcopy.exp 2018-04-06 02:46:51.553113142 +0100
+++ binutils/binutils/testsuite/binutils-all/objcopy.exp 2018-04-06 02:59:07.007174246 +0100
@@ -1121,6 +1121,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] } {
Index: binutils/binutils/testsuite/binutils-all/strip-15.d
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/binutils/testsuite/binutils-all/strip-15.d 2018-04-06 02:55:59.844905122 +0100
@@ -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
Index: binutils/binutils/testsuite/binutils-all/strip-15mips64.s
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/binutils/testsuite/binutils-all/strip-15mips64.s 2018-04-06 02:54:20.095143876 +0100
@@ -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
Index: binutils/binutils/testsuite/binutils-all/strip-15rel.s
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/binutils/testsuite/binutils-all/strip-15rel.s 2018-04-06 02:53:56.696393004 +0100
@@ -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
Index: binutils/binutils/testsuite/binutils-all/strip-15rela.s
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/binutils/testsuite/binutils-all/strip-15rela.s 2018-04-06 02:54:11.658915653 +0100
@@ -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
More information about the Binutils
mailing list