aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2018-08-13 13:41:18 +0930
committerAlan Modra <amodra@gmail.com>2018-08-18 13:46:32 +0930
commit506b86a4f5fe2aff90e62940a07c9e275d406cd4 (patch)
tree8fb1c7ac2d4073b8d5ad46f07d16e2900c83a160 /binutils
parent503c367dc237e6fec46d0b8ccf3e74f7406b3260 (diff)
downloadgdb-506b86a4f5fe2aff90e62940a07c9e275d406cd4.zip
gdb-506b86a4f5fe2aff90e62940a07c9e275d406cd4.tar.gz
gdb-506b86a4f5fe2aff90e62940a07c9e275d406cd4.tar.bz2
binutils testsuite strip-13 test
The strip-13 test runs into difficulty using dc.a on some targets. dc.a writes a power of 2 number of bytes large enough to contain a target address. On some targets, eg. avr-elf, this can be 2 bytes but the ELF format used require words of 4 bytes to make up a relocation entry. There was a hack in the test, duplicating the reloc type into what is normally the addend to make the test work when little-endian, but that hack fails for similar big-endian targets. This patch fixes that problem by arranging to emit 32-bit and 64-bit ELF relocs using .4byte and .8byte directives, chosen as appropriate for the ELF size. I've also bumped the reloc number tested to a higher unused value, and made the number more easily parameterised by target should that be necessary in the future. Whether REL or RELA relocs are used is now chosen by a new is_rela readelf test of an object file, rather than by lists of targets. * testsuite/lib/binutils-common.exp (is_elf64): Use directory of input file for readelf.out. (is_rela): New proc. * testsuite/binutils-all/objcopy.exp (elf64): Set new variable from first result of is_elf64 test. (reloc_format): Set using is_rela. (strip-13): Pass RELOC and ELF64 to assembler. (strip-14, strip-15): Use elf64 rather than calling is_elf64 again. * testsuite/binutils-all/strip-13.d: Run for more targets. * testsuite/binutils-all/strip-13mips64.s: Use RELOC and set addend to zero. * testsuite/binutils-all/strip-13rel.s: Use RELOC and ELF64. Don't add _NONE reloc. * testsuite/binutils-all/strip-13rela.s: Likewise.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog17
-rw-r--r--binutils/testsuite/binutils-all/objcopy.exp45
-rw-r--r--binutils/testsuite/binutils-all/strip-13.d6
-rw-r--r--binutils/testsuite/binutils-all/strip-13mips64.s4
-rw-r--r--binutils/testsuite/binutils-all/strip-13rel.s12
-rw-r--r--binutils/testsuite/binutils-all/strip-13rela.s16
-rw-r--r--binutils/testsuite/lib/binutils-common.exp25
7 files changed, 77 insertions, 48 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 071a005..265bd68 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,20 @@
+2018-08-18 Alan Modra <amodra@gmail.com>
+
+ * testsuite/lib/binutils-common.exp (is_elf64): Use directory of
+ input file for readelf.out.
+ (is_rela): New proc.
+ * testsuite/binutils-all/objcopy.exp (elf64): Set new variable
+ from first result of is_elf64 test.
+ (reloc_format): Set using is_rela.
+ (strip-13): Pass RELOC and ELF64 to assembler.
+ (strip-14, strip-15): Use elf64 rather than calling is_elf64 again.
+ * testsuite/binutils-all/strip-13.d: Run for more targets.
+ * testsuite/binutils-all/strip-13mips64.s: Use RELOC and set
+ addend to zero.
+ * testsuite/binutils-all/strip-13rel.s: Use RELOC and ELF64.
+ Don't add _NONE reloc.
+ * testsuite/binutils-all/strip-13rela.s: Likewise.
+
2018-08-10 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/23494
diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp
index 8d8b399..342585f 100644
--- a/binutils/testsuite/binutils-all/objcopy.exp
+++ b/binutils/testsuite/binutils-all/objcopy.exp
@@ -1033,6 +1033,7 @@ if { ([istarget "ia64-*-elf*"]
}
# ELF specific tests
+set elf64 ""
if [is_elf_format] {
objcopy_test_symbol_manipulation
objcopy_test_elf_common_symbols
@@ -1049,7 +1050,9 @@ if [is_elf_format] {
run_dump_test "group-7c"
run_dump_test "copy-1"
run_dump_test "note-1"
+ # Use bintest.o from the note-1 test to determine ELF32 or ELF64
if [is_elf64 tmpdir/bintest.o] {
+ set elf64 "--defsym ELF64=1"
run_dump_test "note-2-64"
run_dump_test "note-3-64"
run_dump_test "note-4-64"
@@ -1064,6 +1067,11 @@ if [is_elf_format] {
run_dump_test "copy-2"
run_dump_test "copy-3"
run_dump_test "copy-4"
+# Use bintest.o from the copy-4 test to determine ELF reloc type
+set reloc_format rel
+if { [is_elf_format] && [is_rela tmpdir/bintest.o] } {
+ set reloc_format rela
+}
run_dump_test "pr19020a"
run_dump_test "pr19020b"
@@ -1081,27 +1089,12 @@ if [is_elf_format] {
if { [istarget "mips64*-*-openbsd*"] } {
set reloc_format mips64
- } elseif { ([istarget "arm*-*"] \
- && ![istarget "*-*-vxworks"] \
- && ![istarget "*-*-windiss"]) \
- || [istarget "d10v-*"] \
- || [istarget "dlx-*"] \
- || [istarget "i*86-*"] \
- || [istarget "m681*-*"] \
- || [istarget "m68hc1*-*"] \
- || ([istarget "mips*-*"] \
- && ![istarget "mips64*-ps2-elf*"] \
- && ![istarget "*-*-irix6*"] \
- && ![istarget "mips64*-*-freebsd*"] \
- && ![istarget "mips64*-*-kfreebsd*-gnu"] \
- && ![istarget "mips64*-*-linux*"]) \
- || [istarget "score*-*"] \
- || [istarget "xgate-*"] } {
- set reloc_format rel
- } else {
- set reloc_format rela
}
- run_dump_test "strip-13" [list [list source strip-13${reloc_format}.s]]
+ # A relocation type not supported by any target
+ set reloc 215
+ run_dump_test "strip-13" [list \
+ [list source strip-13${reloc_format}.s] \
+ [list as "${elf64} --defsym RELOC=${reloc}"]]
# Select a relocation number that corresponds to one actually
# supported by the target and ABI being tested.
if { [istarget "aarch64*-*"] } {
@@ -1117,15 +1110,11 @@ if [is_elf_format] {
set reloc 1
}
run_dump_test "strip-14" [list \
- [list source strip-14${reloc_format}.s] \
- [list as "--defsym RELOC=${reloc}"] \
- [list as [expr {[is_elf64 tmpdir/bintest.o] \
- ? "--defsym ELF64=1" : ""}]]]
+ [list source strip-14${reloc_format}.s] \
+ [list as "${elf64} --defsym RELOC=${reloc}"]]
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" : ""}]]]
+ [list source strip-15${reloc_format}.s] \
+ [list as "${elf64} --defsym RELOC=${reloc}"]]
# This requires STB_GNU_UNIQUE support with OSABI set to GNU.
if { [supports_gnu_unique] } {
diff --git a/binutils/testsuite/binutils-all/strip-13.d b/binutils/testsuite/binutils-all/strip-13.d
index 0ccb73e..05d21ec 100644
--- a/binutils/testsuite/binutils-all/strip-13.d
+++ b/binutils/testsuite/binutils-all/strip-13.d
@@ -1,10 +1,8 @@
#PROG: strip
#strip: -g
-#error: \A[^\n]*: unsupported relocation type 0x8f\n
+#error: \A[^\n]*: unsupported relocation type 0x[0-9a-f]+\n
#error: [^\n]*: bad value\Z
-#not-target: h8300-* ip2k-* m6811-* m68hc11-* rx-*
-# The H8300-*, IP2K and 68HC11 targets use 16-bit addressing, so `.dc.a'
-# does not work for manual relocation data construction.
+#not-target: rx-*
# The RX targets do not complain about unrecognised relocs, unless they
# are actually used
# (which is what should really happen with the other targets...)
diff --git a/binutils/testsuite/binutils-all/strip-13mips64.s b/binutils/testsuite/binutils-all/strip-13mips64.s
index cee9c75..ea652a4 100644
--- a/binutils/testsuite/binutils-all/strip-13mips64.s
+++ b/binutils/testsuite/binutils-all/strip-13mips64.s
@@ -5,8 +5,8 @@ foo:
.section .rela.text
.dc.a 0
.dc.l 0
- .dc.b 0, 0, 0, 0x8f
- .dc.a 0x0000008f
+ .dc.b 0, 0, 0, RELOC
+ .dc.a 0
.dc.a 0
.dc.l 0
diff --git a/binutils/testsuite/binutils-all/strip-13rel.s b/binutils/testsuite/binutils-all/strip-13rel.s
index de7eae1..f708f6f 100644
--- a/binutils/testsuite/binutils-all/strip-13rel.s
+++ b/binutils/testsuite/binutils-all/strip-13rel.s
@@ -3,8 +3,10 @@ foo:
.dc.l 0x12345678
.section .rel.text
- .dc.a 0
- .dc.a 0x0000008f
-
- .dc.a 0
- .dc.a 0
+ .ifdef ELF64
+ .8byte 0
+ .8byte RELOC
+ .else
+ .4byte 0
+ .4byte RELOC
+ .endif
diff --git a/binutils/testsuite/binutils-all/strip-13rela.s b/binutils/testsuite/binutils-all/strip-13rela.s
index 886c0ee..2c01ab2 100644
--- a/binutils/testsuite/binutils-all/strip-13rela.s
+++ b/binutils/testsuite/binutils-all/strip-13rela.s
@@ -3,10 +3,12 @@ foo:
.dc.l 0x12345678
.section .rela.text
- .dc.a 0
- .dc.a 0x0000008f
- .dc.a 0x0000008f
-
- .dc.a 0
- .dc.a 0
- .dc.a 0
+ .ifdef ELF64
+ .8byte 0
+ .8byte RELOC
+ .8byte 0
+ .else
+ .4byte 0
+ .4byte RELOC
+ .4byte 0
+ .endif
diff --git a/binutils/testsuite/lib/binutils-common.exp b/binutils/testsuite/lib/binutils-common.exp
index 7de7d67..b1ede4c 100644
--- a/binutils/testsuite/lib/binutils-common.exp
+++ b/binutils/testsuite/lib/binutils-common.exp
@@ -111,15 +111,16 @@ proc is_elf64 { binary_file } {
global READELF
global READELFFLAGS
+ set tmpfile [file dirname $binary_file]/readelf.out
set readelf_size ""
- catch "exec $READELF $READELFFLAGS -h $binary_file > readelf.out" got
+ catch "exec $READELF $READELFFLAGS -h $binary_file > $tmpfile" got
if ![string match "" $got] then {
return 0
}
if { ![regexp "\n\[ \]*Class:\[ \]*ELF(\[0-9\]+)\n" \
- [file_contents readelf.out] nil readelf_size] } {
+ [file_contents $tmpfile] nil readelf_size] } {
return 0
}
@@ -130,6 +131,26 @@ proc is_elf64 { binary_file } {
return 0
}
+# True if the object format is known to use RELA relocations.
+#
+proc is_rela { binary_file } {
+ global READELF
+ global READELFFLAGS
+
+ set tmpfile [file dirname $binary_file]/readelf.out
+ catch "exec $READELF $READELFFLAGS -S $binary_file > $tmpfile" got
+
+ if ![string match "" $got] then {
+ return 0
+ }
+
+ if { ![regexp "RELA" [file_contents $tmpfile]] } {
+ return 0
+ }
+
+ return 1
+}
+
# True if the target matches TARGET, specified as a TCL procedure if
# in square brackets or as machine triplet otherwise.
#