[PATCH][gdb/testsuite] Fix ada tests with -fPIE/-pie

Tom de Vries tdevries@suse.de
Wed Aug 7 11:07:00 GMT 2019


Hi,

When running the gdb testsuite with target board unix/-fPIE/-pie, the
resulting ada executables are not PIE executables, because gnatmake doesn't
recognize -pie, and consequently doesn't pass it to gnatlink.

Fix this by replacing "-pie" with "-largs -pie -margs" for ada test-cases in
gdb_default_target_compile, and doing the same for -no-pie.

Tested on x86_64-linux.

OK for trunk?

Thanks,
- Tom

[gdb/testsuite] Fix ada tests with -fPIE/-pie

gdb/testsuite/ChangeLog:

2019-08-07  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24888
	* lib/future.exp (gdb_default_target_compile): Route -pie/-no-pie to
	gnatlink for ada.

---
 gdb/testsuite/lib/future.exp | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/lib/future.exp b/gdb/testsuite/lib/future.exp
index 122e652858..e26e49af91 100644
--- a/gdb/testsuite/lib/future.exp
+++ b/gdb/testsuite/lib/future.exp
@@ -530,7 +530,19 @@ proc gdb_default_target_compile {source destfile type options} {
     }
 
     if {[board_info $dest exists multilib_flags]} {
-	append add_flags " [board_info $dest multilib_flags]"
+	if { $compiler_type == "ada" } {
+	    foreach op [board_info $dest multilib_flags] {
+		if { $op == "-pie" || $op == "-no-pie" } {
+		    # Pretend gnatmake supports -pie/-no-pie, route it to
+		    # linker.
+		    append add_flags " -largs $op -margs"
+		} else {
+		    append add_flags " $op"
+		}
+	    }
+	} else {
+	    append add_flags " [board_info $dest multilib_flags]"
+	}
     }
 
     verbose "doing compile"



More information about the Gdb-patches mailing list