aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-07-05 23:23:51 +0930
committerAlan Modra <amodra@gmail.com>2023-07-12 10:20:14 +0930
commite729325e2ba4507e3891e57aadc39e67b67377e2 (patch)
treeca322f37ac51afe93d62ba6f859614be2cb80225
parentld: Use run_host_cmd_yesno in indirect.exp instead of catch exec (diff)
downloadbinutils-gdb-e729325e2ba4507e3891e57aadc39e67b67377e2.tar.gz
binutils-gdb-e729325e2ba4507e3891e57aadc39e67b67377e2.tar.bz2
binutils-gdb-e729325e2ba4507e3891e57aadc39e67b67377e2.zip
Use run_host_cmd to run $CC and other no-section-header test fixes
We should be using run_host_cmd everywhere we invoke a compiler in the ld testsuite, if we want to use ld/ld-new just built. run_host_cmd properly inserts $gcc_B_opt in cases where a user wants to test binutils with a newly built compiler, ie. when $CC specifies -B itself. Also, it is not good practice to exclude tests when non-native except of course those tests that run a target binary. Compiling and linking often shows up problems. * testsuite/ld-elf/no-section-header.exp (binutils_run_test): Use run_host_cmd to invoke $CC_FOR_TARGET. Run all tests non-native too, except for attempting to run the binaries. Run tests for ELF in general, not just linux. * testsuite/ld-elf/pr25617-1-no-sec-hdr.rd: Allow localentry symbol decoration, and support either sorting of symbols. * testsuite/ld-elf/pr25617-1a-no-sec-hdr.rd: Likewise. * testsuite/ld-elf/pr25617-1a-sec-hdr.rd: Likewise. * testsuite/ld-elf/pr25617-1a-no-sec-hdr.nd: Accept D function syms. * testsuite/ld-elf/start-shared-noheader-sysv.rd: Accept mips-sgi-irix symbol output. * testsuite/ld-elf/start-shared-noheader.nd: Likewise. (cherry picked from commit 46f51ac38b81df4bf890e13824427c69285fdcaa)
-rw-r--r--ld/testsuite/ld-elf/no-section-header.exp74
-rw-r--r--ld/testsuite/ld-elf/pr25617-1-no-sec-hdr.rd4
-rw-r--r--ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.nd2
-rw-r--r--ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.rd4
-rw-r--r--ld/testsuite/ld-elf/pr25617-1a-sec-hdr.rd4
-rw-r--r--ld/testsuite/ld-elf/start-shared-noheader-sysv.rd10
-rw-r--r--ld/testsuite/ld-elf/start-shared-noheader.nd10
7 files changed, 54 insertions, 54 deletions
diff --git a/ld/testsuite/ld-elf/no-section-header.exp b/ld/testsuite/ld-elf/no-section-header.exp
index c010e572a32..bd4697ddd4c 100644
--- a/ld/testsuite/ld-elf/no-section-header.exp
+++ b/ld/testsuite/ld-elf/no-section-header.exp
@@ -21,9 +21,7 @@
# Written by H.J. Lu (hongjiu.lu@intel.com)
#
-# Make sure that binutils can correctly handle ld output in ELF.
-
-if { ![istarget *-*-linux*] } {
+if { ![is_elf_format] } {
return
}
@@ -129,14 +127,13 @@ binutils_test strip "--hash-style=gnu -shared" start \
binutils_test strip "--hash-style=sysv -shared" start \
start-shared-noheader-sysv.rd start-shared-noheader.nd
-# Skip non-native targets or -shared is not supported.
-if { ![isnative] || ![check_shared_lib_support] } {
+
+if { ![check_compiler_available] || ![check_shared_lib_support] } {
return
}
proc binutils_run_test { prog } {
- global CC
- global gcc_B_opt
+ global CC_FOR_TARGET
global READELF
global NM
global objcopy
@@ -286,20 +283,22 @@ proc binutils_run_test { prog } {
return
}
- send_log "tmpdir/pr25617-1-no-sec-hdr > tmpdir/pr25617-1.out\n"
- catch "exec tmpdir/pr25617-1-no-sec-hdr > tmpdir/pr25617-1.out" got
- if ![string match "" $got] then {
- send_log "$got\n"
- unresolved "Update pr25617-1a-no-sec-hdr.so ($prog_name)"
- return
- }
-
- send_log "diff tmpdir/pr25617-1.out $srcdir/$subdir/pass.out\n"
- catch "exec diff tmpdir/pr25617-1.out $srcdir/$subdir/pass.out" got
- if ![string match "" $got] then {
- send_log "$got\n"
- fail "Update pr25617-1a-no-sec-hdr.so ($prog_name)"
- return
+ if { [isnative] } {
+ send_log "tmpdir/pr25617-1-no-sec-hdr > tmpdir/pr25617-1.out\n"
+ catch "exec tmpdir/pr25617-1-no-sec-hdr > tmpdir/pr25617-1.out" got
+ if ![string match "" $got] then {
+ send_log "$got\n"
+ unresolved "Update pr25617-1a-no-sec-hdr.so ($prog_name)"
+ return
+ }
+
+ send_log "diff tmpdir/pr25617-1.out $srcdir/$subdir/pass.out\n"
+ catch "exec diff tmpdir/pr25617-1.out $srcdir/$subdir/pass.out" got
+ if ![string match "" $got] then {
+ send_log "$got\n"
+ fail "Update pr25617-1a-no-sec-hdr.so ($prog_name)"
+ return
+ }
}
pass "Update pr25617-1a-no-sec-hdr.so ($prog_name)"
@@ -338,24 +337,25 @@ proc binutils_run_test { prog } {
return
}
- send_log "tmpdir/pr25617-1-pie-no-sec-hdr > tmpdir/pr25617-1-pie.out\n"
- catch "exec tmpdir/pr25617-1-pie-no-sec-hdr > tmpdir/pr25617-1-pie.out" got
- if ![string match "" $got] then {
- send_log "$got\n"
- unresolved "Update pr25617-1a-now-no-sec-hdr.so ($prog_name)"
- return
- }
-
- send_log "diff tmpdir/pr25617-1-pie.out $srcdir/$subdir/pass.out\n"
- catch "exec diff tmpdir/pr25617-1-pie.out $srcdir/$subdir/pass.out" got
- if ![string match "" $got] then {
- send_log "$got\n"
- fail "Update pr25617-1a-now-no-sec-hdr.so ($prog_name)"
- return
+ if { [isnative] } {
+ send_log "tmpdir/pr25617-1-pie-no-sec-hdr > tmpdir/pr25617-1-pie.out\n"
+ catch "exec tmpdir/pr25617-1-pie-no-sec-hdr > tmpdir/pr25617-1-pie.out" got
+ if ![string match "" $got] then {
+ send_log "$got\n"
+ unresolved "Update pr25617-1a-now-no-sec-hdr.so ($prog_name)"
+ return
+ }
+
+ send_log "diff tmpdir/pr25617-1-pie.out $srcdir/$subdir/pass.out\n"
+ catch "exec diff tmpdir/pr25617-1-pie.out $srcdir/$subdir/pass.out" got
+ if ![string match "" $got] then {
+ send_log "$got\n"
+ fail "Update pr25617-1a-now-no-sec-hdr.so ($prog_name)"
+ return
+ }
}
- send_log "$CC $gcc_B_opt -o tmpdir/pr25617-1 tmpdir/pr25617-1b.o tmpdir/pr25617-1a-now-no-sec-hdr.so\n"
- catch "exec $CC $gcc_B_opt -o tmpdir/pr25617-1 tmpdir/pr25617-1b.o tmpdir/pr25617-1a-now-no-sec-hdr.so" got
+ set got [run_host_cmd $CC_FOR_TARGET "-o tmpdir/pr25617-1 tmpdir/pr25617-1b.o tmpdir/pr25617-1a-now-no-sec-hdr.so"]
if ![string match "*pr25617-1a-now-no-sec-hdr.so*file in wrong format*" $got] then {
send_log "$got\n"
fail "Update pr25617-1a-now-no-sec-hdr.so ($prog_name)"
diff --git a/ld/testsuite/ld-elf/pr25617-1-no-sec-hdr.rd b/ld/testsuite/ld-elf/pr25617-1-no-sec-hdr.rd
index be49dea32db..05957dc3e69 100644
--- a/ld/testsuite/ld-elf/pr25617-1-no-sec-hdr.rd
+++ b/ld/testsuite/ld-elf/pr25617-1-no-sec-hdr.rd
@@ -14,7 +14,7 @@ Program Headers:
+Num: +Value +Size Type +Bind +Vis +Ndx Name
+0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND +
#...
- +[0-9]+: +[a-f0-9]+ +0 +FUNC +GLOBAL +DEFAULT +UND +__libc_start_main(@.*|)
+.* FUNC +GLOBAL +DEFAULT.* UND +(__libc_start_main(@.*|)|_?test)
#...
- +[0-9]+: +[a-f0-9]+ +0+ +FUNC +GLOBAL +DEFAULT +UND +_?test
+.* FUNC +GLOBAL +DEFAULT.* UND +(__libc_start_main(@.*|)|_?test)
#pass
diff --git a/ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.nd b/ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.nd
index 2813ffc6652..2dc92a2ff50 100644
--- a/ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.nd
+++ b/ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.nd
@@ -1,3 +1,3 @@
#...
+ U _?puts(@.*|)
-[0-9a-z]+ T _?test
+[0-9a-z]+ [TD] _?test
diff --git a/ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.rd b/ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.rd
index f7a4eec7362..519ce15453e 100644
--- a/ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.rd
+++ b/ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.rd
@@ -14,7 +14,7 @@ Program Headers:
+Num: +Value +Size Type +Bind +Vis +Ndx Name
+0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND +
#...
- +[0-9]+: +[a-f0-9]+ +0 +FUNC +GLOBAL +DEFAULT +UND +_?puts(@.*|)
+.* FUNC +GLOBAL +DEFAULT.* (UND +_?puts(@.*|)|[0-9]+ +_?test)
#...
- +[0-9]+: +[a-f0-9]+ +[0-9]+ +FUNC +GLOBAL +DEFAULT +[0-9]+ +_?test
+.* FUNC +GLOBAL +DEFAULT.* (UND +_?puts(@.*|)|[0-9]+ +_?test)
#pass
diff --git a/ld/testsuite/ld-elf/pr25617-1a-sec-hdr.rd b/ld/testsuite/ld-elf/pr25617-1a-sec-hdr.rd
index 9ccf0565af6..0de2915811a 100644
--- a/ld/testsuite/ld-elf/pr25617-1a-sec-hdr.rd
+++ b/ld/testsuite/ld-elf/pr25617-1a-sec-hdr.rd
@@ -13,7 +13,7 @@ Program Headers:
+Num: +Value +Size Type +Bind +Vis +Ndx Name
+0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND +
#...
- +[0-9]+: +[a-f0-9]+ +0 +FUNC +GLOBAL +DEFAULT +UND +_?puts(@.*|)
+.* FUNC +GLOBAL +DEFAULT.* (UND +_?puts(@.*|)|[0-9]+ +_?test)
#...
- +[0-9]+: +[a-f0-9]+ +[0-9]+ +FUNC +GLOBAL +DEFAULT +[0-9]+ +_?test
+.* FUNC +GLOBAL +DEFAULT.* (UND +_?puts(@.*|)|[0-9]+ +_?test)
#pass
diff --git a/ld/testsuite/ld-elf/start-shared-noheader-sysv.rd b/ld/testsuite/ld-elf/start-shared-noheader-sysv.rd
index d8f02497e58..d5bbb8bb6d0 100644
--- a/ld/testsuite/ld-elf/start-shared-noheader-sysv.rd
+++ b/ld/testsuite/ld-elf/start-shared-noheader-sysv.rd
@@ -14,13 +14,13 @@ Program Headers:
+Num: +Value +Size Type +Bind +Vis +Ndx Name
+0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND +
#...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +__start
+.* GLOBAL +DEFAULT.* __start
#...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +_start
+.* GLOBAL +DEFAULT.* _start
#...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +main
+.* GLOBAL +DEFAULT.* main
#...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +start
+.* GLOBAL +DEFAULT.* start
#...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +_main
+.* GLOBAL +DEFAULT.* _main
#pass
diff --git a/ld/testsuite/ld-elf/start-shared-noheader.nd b/ld/testsuite/ld-elf/start-shared-noheader.nd
index 6ec6cdf8af9..d1e7dd11fd4 100644
--- a/ld/testsuite/ld-elf/start-shared-noheader.nd
+++ b/ld/testsuite/ld-elf/start-shared-noheader.nd
@@ -1,11 +1,11 @@
#...
-[0-9a-z]+ A __start
+[0-9a-z]+ [AD] __start
#...
-[0-9a-z]+ A _main
+[0-9a-z]+ [AD] _main
#...
-[0-9a-z]+ A _start
+[0-9a-z]+ [AD] _start
#...
-[0-9a-z]+ A main
+[0-9a-z]+ [AD] main
#...
-[0-9a-z]+ A start
+[0-9a-z]+ [AD] start
#pass