With gcc 7.5.0 and test-case gdb.base/rtld-step.exp, I run into:
...
gdb compile failed, gcc: error: unrecognized command line option \
'-static-pie'; did you mean '-static'?
...
Silence this by checking in the test-case that -static-pie is supported, and
emitting instead:
...
UNTESTED: gdb.base/rtld-step.exp: \
failed to compile (-static-pie not supported or static libc missing)
...
Tested on x86_64-linux, with:
- gcc 7.5.0: UNTESTED
- gcc 12.2.1 with static glibc not installed: UNTESTED
- gcc 12.2.1 with static glibc installed: PASS
set rtld_flags [list debug additional_flags=[list -static-pie -fPIE \
-nostdlib -static -lc]]
+if { ![gdb_can_simple_compile static-pie-static-libc \
+ "void _start (void) { _exit (0); }" \
+ executable $rtld_flags] } {
+ set reason "-static-pie not supported or static libc missing"
+ untested "failed to compile ($reason)"
+ return -1
+}
+
# Main program file names and flags:
set main_basename ${::gdb_test_file_name}-main
set srcfile_main ${srcdir}/${subdir}/${main_basename}.c