aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2022-10-14 13:09:50 +0200
committerTom de Vries <tdevries@suse.de>2022-10-14 13:09:50 +0200
commit68f7bda9b1c32920ce4a2fe65129525bc0b05bf7 (patch)
treead018153084f5479847d43ccda86eeda31820b27 /gdb/testsuite
parent1806054393e033dfac661fe4f68683a23646cb61 (diff)
downloadgdb-68f7bda9b1c32920ce4a2fe65129525bc0b05bf7.zip
gdb-68f7bda9b1c32920ce4a2fe65129525bc0b05bf7.tar.gz
gdb-68f7bda9b1c32920ce4a2fe65129525bc0b05bf7.tar.bz2
[gdb/testsuite] Fix nopie test-cases with target board unix/-fPIE/-pie
Compilers default to either PIE or no-PIE executables. In order to test PIE executables with a compiler that produces non-PIE by default, we can use target board unix/-fPIE/-pie, which set the multilib_flags of the target board to "-fPIE -pie". Likewise, we can use target board unix/-fno-PIE/-no-pie with a compiler that produces PIE by default. The target board unix/-fno-PIE/-no-pie has a potential problem when compiling shared libs, because the multilib_flags will override the attempts of gdb_compile_shlib to compile with -fPIC. This is taken care of by running the body of gdb_compile_shlib wrapped in with_PIE_multilib_flags_filtered. The target board unix/-fPIE/-pie has a problem with nopie compilations. The current approach is to do the compilation hoping for the best, and if we find out that the resulting executable is PIE despite specifying nopie, we error out with the standard error message "nopie failed to prevent PIE executable". That however does not work for hard-coded assembly nopie test-cases, which will just noisily refuse to compile: ... ld: amd64-disp-step0.o: relocation R_X86_64_32S against `.text' can not be \ used when making a PIE object; recompile with -fPIE^M ... Fix this in gdb_compile by filtering out the PIE settings in the target board multilib_flags when pie or nopie is specified. Tested on x86_64-linux.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/lib/gdb.exp5
1 files changed, 4 insertions, 1 deletions
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 7de8bb6..1167aa7 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4783,7 +4783,10 @@ proc gdb_compile {source dest type options} {
}
}
- set result [target_compile $source $dest $type $options]
+ cond_wrap [expr $pie != -1 || $nopie != -1] \
+ with_PIE_multilib_flags_filtered {
+ set result [target_compile $source $dest $type $options]
+ }
# Prune uninteresting compiler (and linker) output.
regsub "Creating library file: \[^\r\n\]*\[\r\n\]+" $result "" result