diff options
author | Markus Metzger <markus.t.metzger@intel.com> | 2020-12-21 08:34:25 +0100 |
---|---|---|
committer | Markus Metzger <markus.t.metzger@intel.com> | 2021-03-03 09:07:49 +0100 |
commit | b93a3ed0a8561cb8f9541eca975e8c76f728d86c (patch) | |
tree | 79c01f555f1aaa11ad3c86e574d092d05bcab09a /gdb/testsuite/lib/gdb.exp | |
parent | fd5c076a06d88dc53e56a17d43ea4ad5e27515a0 (diff) | |
download | gdb-b93a3ed0a8561cb8f9541eca975e8c76f728d86c.zip gdb-b93a3ed0a8561cb8f9541eca975e8c76f728d86c.tar.gz gdb-b93a3ed0a8561cb8f9541eca975e8c76f728d86c.tar.bz2 |
testsuite: extend nopie handling to add -fno-pie to compiler flags
Some older GCC, e.g. 7.5.0 on Ubuntu 18.04 need -fno-pie to be passed to
the compiler in addition to -no-pie to be passed to the linker for non-pie
code generation.
The gdb,nopie_flag is already documented as getting passed to the
compiler, not the linker. Use that for the new -fno-pie compiler flag and
add a new gdb,nopie_ldflag for the existing -no-pie linker flag.
CAUTION: this might break existing board files that specify
gdb,nopie_flag. Affected board files need to rename
gdb,nopie_flag into gdb,nopie_ldflag.
Diffstat (limited to 'gdb/testsuite/lib/gdb.exp')
-rw-r--r-- | gdb/testsuite/lib/gdb.exp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 7480bd5..0496ca2 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4210,16 +4210,23 @@ proc gdb_compile {source dest type options} { lappend options "$flag" } - # Replace the "nopie" option with the appropriate linker flag to disable - # PIE executables. There are no compiler flags for this option. + # Replace the "nopie" option with the appropriate compiler and linker + # flags to disable PIE executables. set nopie [lsearch -exact $options nopie] if {$nopie != -1} { if [target_info exists gdb,nopie_flag] { - set flag "ldflags=[target_info gdb,nopie_flag]" + set flag "additional_flags=[target_info gdb,nopie_flag]" } else { - set flag "ldflags=-no-pie" + set flag "additional_flags=-fno-pie" } set options [lreplace $options $nopie $nopie $flag] + + if [target_info exists gdb,nopie_ldflag] { + set flag "ldflags=[target_info gdb,nopie_ldflag]" + } else { + set flag "ldflags=-no-pie" + } + lappend options "$flag" } if { $type == "executable" } { |