+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
}
# ELF specific tests
+set elf64 ""
if [is_elf_format] {
objcopy_test_symbol_manipulation
objcopy_test_elf_common_symbols
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"
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"
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*-*"] } {
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] } {
#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...)
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
}
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.
#