Use run_host_cmd to run $CC and other no-section-header test fixes
authorAlan Modra <amodra@gmail.com>
Wed, 5 Jul 2023 13:53:51 +0000 (23:23 +0930)
committerAlan Modra <amodra@gmail.com>
Thu, 6 Jul 2023 01:09:40 +0000 (10:39 +0930)
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.

ld/testsuite/ld-elf/no-section-header.exp
ld/testsuite/ld-elf/pr25617-1-no-sec-hdr.rd
ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.nd
ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.rd
ld/testsuite/ld-elf/pr25617-1a-sec-hdr.rd
ld/testsuite/ld-elf/start-shared-noheader-sysv.rd
ld/testsuite/ld-elf/start-shared-noheader.nd

index c010e572a3287ead8b51cfc7ac0f860d4b76d4c5..bd4697ddd4cedaddcb3c1290808e15c6dc96c1b8 100644 (file)
@@ -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)"
index be49dea32dbedbb4ff6cf45572cdab56a3b56b69..05957dc3e6999e0d130a73dd661b9213f4d17f55 100644 (file)
@@ -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
index 2813ffc66520d4529140b51d224ceec526ac7e1c..2dc92a2ff50a913f94adba7249de98724b187b5f 100644 (file)
@@ -1,3 +1,3 @@
 #...
  + U _?puts(@.*|)
-[0-9a-z]+ T _?test
+[0-9a-z]+ [TD] _?test
index f7a4eec73625e6c64f246a1ca1b3563cb8dc0019..519ce15453e42cab5dcc8d43ad2b869cc1bbf241 100644 (file)
@@ -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
index 9ccf0565af63c1849e0d6eee1616fc6d584767c8..0de2915811a7cd1526145b0417e508bb6c841f30 100644 (file)
@@ -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
index d8f02497e58af670e2ed40d7eaf07399f9782758..d5bbb8bb6d0d28446a3ed2eb34f1d6942e75bc78 100644 (file)
@@ -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
index 6ec6cdf8af9f0792c2974e42bf5cee37340d77a9..d1e7dd11fd4488a908a61eed48baf891eb719009 100644 (file)
@@ -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