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.
This commit is contained in:
parent
fd5c076a06
commit
b93a3ed0a8
3 changed files with 21 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2021-03-03 Markus Metzger <markus.t.metzger@intel.com>
|
||||||
|
|
||||||
|
* README (Note): Add nopie_ldflag.
|
||||||
|
* lib/gdb.exp (gdb_compile): Extend nopie handling.
|
||||||
|
|
||||||
2021-03-02 Tom Tromey <tromey@adacore.com>
|
2021-03-02 Tom Tromey <tromey@adacore.com>
|
||||||
|
|
||||||
* gdb.ada/fixed_points.exp: Remove most special cases for minimal
|
* gdb.ada/fixed_points.exp: Remove most special cases for minimal
|
||||||
|
|
|
@ -528,6 +528,11 @@ gdb,nopie_flag
|
||||||
The flag required to force the compiler to produce non-position-independent
|
The flag required to force the compiler to produce non-position-independent
|
||||||
executables.
|
executables.
|
||||||
|
|
||||||
|
gdb,nopie_ldflag
|
||||||
|
|
||||||
|
The flag required to force the linker to produce non-position-independent
|
||||||
|
executables.
|
||||||
|
|
||||||
gdb,debug
|
gdb,debug
|
||||||
|
|
||||||
When set gdb debug is sent to the file gdb.debug in the test output
|
When set gdb debug is sent to the file gdb.debug in the test output
|
||||||
|
|
|
@ -4210,16 +4210,23 @@ proc gdb_compile {source dest type options} {
|
||||||
lappend options "$flag"
|
lappend options "$flag"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Replace the "nopie" option with the appropriate linker flag to disable
|
# Replace the "nopie" option with the appropriate compiler and linker
|
||||||
# PIE executables. There are no compiler flags for this option.
|
# flags to disable PIE executables.
|
||||||
set nopie [lsearch -exact $options nopie]
|
set nopie [lsearch -exact $options nopie]
|
||||||
if {$nopie != -1} {
|
if {$nopie != -1} {
|
||||||
if [target_info exists gdb,nopie_flag] {
|
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 "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 {
|
} else {
|
||||||
set flag "ldflags=-no-pie"
|
set flag "ldflags=-no-pie"
|
||||||
}
|
}
|
||||||
set options [lreplace $options $nopie $nopie $flag]
|
lappend options "$flag"
|
||||||
}
|
}
|
||||||
|
|
||||||
if { $type == "executable" } {
|
if { $type == "executable" } {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue