]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
testsuite: extend nopie handling to add -fno-pie to compiler flags
authorMarkus Metzger <markus.t.metzger@intel.com>
Mon, 21 Dec 2020 07:34:25 +0000 (08:34 +0100)
committerMarkus Metzger <markus.t.metzger@intel.com>
Wed, 3 Mar 2021 08:07:49 +0000 (09:07 +0100)
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.

gdb/testsuite/ChangeLog
gdb/testsuite/README
gdb/testsuite/lib/gdb.exp

index 4f7bdbfccf24634ea2b28fa2d95525f973aab00f..9bc6995aa87ac29aa8a153ea1d5b5ce73a42a4a0 100644 (file)
@@ -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>
 
        * gdb.ada/fixed_points.exp: Remove most special cases for minimal
index f3c2642db37bd352948cd866ca293f535d4e31ce..0036753eff03f1cf16d40b9f249ed32d7f93bdb0 100644 (file)
@@ -528,6 +528,11 @@ gdb,nopie_flag
   The flag required to force the compiler to produce non-position-independent
   executables.
 
+gdb,nopie_ldflag
+
+  The flag required to force the linker to produce non-position-independent
+  executables.
+
 gdb,debug
 
   When set gdb debug is sent to the file gdb.debug in the test output
index 7480bd5665fa96edfec14b058449fa81509c020f..0496ca2afe1c41d464e5882316de29455b763884 100644 (file)
@@ -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" } {