[gdb/testsuite] Fix gdb.base/infoline-reloc-main-from-zero.exp with recent ld
authorTom de Vries <tdevries@suse.de>
Wed, 12 Oct 2022 14:50:16 +0000 (16:50 +0200)
committerTom de Vries <tdevries@suse.de>
Wed, 12 Oct 2022 14:50:16 +0000 (16:50 +0200)
On openSUSE Tumbleweed (with ld 2.39) and test-case
gdb.base/infoline-reloc-main-from-zero.exp, I get:
...
gdb compile failed, ld: warning: infoline-reloc-main-from-zero has a LOAD \
  segment with RWX permissions
UNTESTED: gdb.base/infoline-reloc-main-from-zero.exp: \
  infoline-reloc-main-from-zero.exp
...

Fix this by compiling with -Wl,--no-warn-rwx-segments.

Tested on x86_64-linux.

gdb/testsuite/gdb.base/infoline-reloc-main-from-zero.exp

index 31e753a0c1c263612e3151eb9e7ccc8b2cae5694..35c2db00c0761df2576509c470dcbb86c2298745 100644 (file)
@@ -25,7 +25,15 @@ standard_testfile .c
 
 # Build executable with stripped startup code and text section starting at zero
 
-set opts {debug "additional_flags=-nostdlib -emain -Wl,-Ttext=0x00 -Wl,-N"}
+set opts {}
+lappend opts debug
+lappend opts "additional_flags=-nostdlib -emain -Wl,-Ttext=0x00 -Wl,-N"
+
+set ld_flags additional_flags=-Wl,--no-warn-rwx-segments
+if { [gdb_can_simple_compile ld-flags {int main () { return 0; }} executable \
+         $ld_flags] } {
+    lappend opts $ld_flags
+}
 
 if {[build_executable $testfile.exp $testfile $srcfile $opts] == -1} {
     untested "failed to compile"