Patchwork Testsuite: Ensure pie is disabled on some tests

login
register
mail settings
Submitter Alan Hayward
Date March 6, 2019, 10:20 a.m.
Message ID <20190306102006.99150-1-alan.hayward@arm.com>
Download mbox | patch
Permalink /patch/31728/
State New
Headers show

Comments

Alan Hayward - March 6, 2019, 10:20 a.m.
Recent versions of Ubuntu and Debian default GCC to enable pie.

In dump.exp, pie will causes addresses to be out of range for IHEX.

In break-interp.exp, pie is explicitly set for some tests and assumed
to be disabled for the remainder.

Ensure pie is disabled for these tests when required.

gdb/testsuite/ChangeLog:

2019-03-06  Alan Hayward  <alan.hayward@arm.com>

	* gdb.base/break-interp.exp: Ensure pie is disabled.
	* gdb.base/dump.exp: Likewise.
---
 gdb/testsuite/gdb.base/break-interp.exp | 4 ++++
 gdb/testsuite/gdb.base/dump.exp         | 4 ++++
 2 files changed, 8 insertions(+)
Alan Hayward - March 19, 2019, 10:45 a.m.
Ping for this.


> On 6 Mar 2019, at 10:20, Alan Hayward <Alan.Hayward@arm.com> wrote:
> 
> Recent versions of Ubuntu and Debian default GCC to enable pie.
> 
> In dump.exp, pie will causes addresses to be out of range for IHEX.
> 
> In break-interp.exp, pie is explicitly set for some tests and assumed
> to be disabled for the remainder.
> 
> Ensure pie is disabled for these tests when required.
> 
> gdb/testsuite/ChangeLog:
> 
> 2019-03-06  Alan Hayward  <alan.hayward@arm.com>
> 
> 	* gdb.base/break-interp.exp: Ensure pie is disabled.
> 	* gdb.base/dump.exp: Likewise.
> ---
> gdb/testsuite/gdb.base/break-interp.exp | 4 ++++
> gdb/testsuite/gdb.base/dump.exp         | 4 ++++
> 2 files changed, 8 insertions(+)
> 
> diff --git a/gdb/testsuite/gdb.base/break-interp.exp b/gdb/testsuite/gdb.base/break-interp.exp
> index f85e8a650a..409c31e568 100644
> --- a/gdb/testsuite/gdb.base/break-interp.exp
> +++ b/gdb/testsuite/gdb.base/break-interp.exp
> @@ -627,6 +627,10 @@ foreach ldprelink {NO YES} {
> 			    if {$binpie != "NO"} {
> 				lappend opts {additional_flags=-fPIE}
> 				lappend opts {ldflags=-pie}
> +			    } else {
> +				# Recent Debian/Ubuntu defaults PIE enabled. Ensure it is disabled.
> +				lappend opts {additional_flags=-no-pie}
> +				lappend opts {ldflags=-no-pie}
> 			    }
> 
> 			    set dir ${exec}.d
> diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp
> index 44b0988b80..b2d7ef938a 100644
> --- a/gdb/testsuite/gdb.base/dump.exp
> +++ b/gdb/testsuite/gdb.base/dump.exp
> @@ -36,6 +36,10 @@ if {[istarget "spu*-*-*"]} then {
>     set is64bitonly "yes"
> }
> 
> +# Ensure -pie is disabled as this breaks IHEX tests.
> +# (PIE defaults to enabled on recent Debian/Ubuntu).
> +lappend options "additional_flags=-no-pie"
> +
> if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ${options}] != "" } {
>      untested "failed to compile"
>      return -1
> -- 
> 2.17.2 (Apple Git-113)
>
Simon Marchi - March 19, 2019, 1:47 p.m.
On 2019-03-06 5:20 a.m., Alan Hayward wrote:
> Recent versions of Ubuntu and Debian default GCC to enable pie.
> 
> In dump.exp, pie will causes addresses to be out of range for IHEX.
> 
> In break-interp.exp, pie is explicitly set for some tests and assumed
> to be disabled for the remainder.
> 
> Ensure pie is disabled for these tests when required.
> 
> gdb/testsuite/ChangeLog:
> 
> 2019-03-06  Alan Hayward  <alan.hayward@arm.com>
> 
> 	* gdb.base/break-interp.exp: Ensure pie is disabled.
> 	* gdb.base/dump.exp: Likewise.

Hi Alan,

The "nopie" flag to gdb_compile has been introduced recently for this, 
could you use that instead?  See commit 6e8b1ab2fd4c ("Fix various tests 
to use -no-pie linker flag when needed").

> ---
>   gdb/testsuite/gdb.base/break-interp.exp | 4 ++++
>   gdb/testsuite/gdb.base/dump.exp         | 4 ++++
>   2 files changed, 8 insertions(+)
> 
> diff --git a/gdb/testsuite/gdb.base/break-interp.exp b/gdb/testsuite/gdb.base/break-interp.exp
> index f85e8a650a..409c31e568 100644
> --- a/gdb/testsuite/gdb.base/break-interp.exp
> +++ b/gdb/testsuite/gdb.base/break-interp.exp
> @@ -627,6 +627,10 @@ foreach ldprelink {NO YES} {
>   			    if {$binpie != "NO"} {
>   				lappend opts {additional_flags=-fPIE}
>   				lappend opts {ldflags=-pie}
> +			    } else {
> +				# Recent Debian/Ubuntu defaults PIE enabled. Ensure it is disabled.
> +				lappend opts {additional_flags=-no-pie}
> +				lappend opts {ldflags=-no-pie}
>   			    }

I believe it won't be necessary here to change CFLAGS (which 
additional_flags does), only ldflags, to make the final executable a 
non-PIE.  Anyway, you'll probably end up using the "nopie" gdb_compile flag.

>   
>   			    set dir ${exec}.d
> diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp
> index 44b0988b80..b2d7ef938a 100644
> --- a/gdb/testsuite/gdb.base/dump.exp
> +++ b/gdb/testsuite/gdb.base/dump.exp
> @@ -36,6 +36,10 @@ if {[istarget "spu*-*-*"]} then {
>       set is64bitonly "yes"
>   }
>   
> +# Ensure -pie is disabled as this breaks IHEX tests.

Can you just precise how it breaks the IHEX tests, as you did in the 
commit message (it causes the addresses to be out of range for that format)?

This patch is ok with those fixed, thanks!

Simon

Patch

diff --git a/gdb/testsuite/gdb.base/break-interp.exp b/gdb/testsuite/gdb.base/break-interp.exp
index f85e8a650a..409c31e568 100644
--- a/gdb/testsuite/gdb.base/break-interp.exp
+++ b/gdb/testsuite/gdb.base/break-interp.exp
@@ -627,6 +627,10 @@  foreach ldprelink {NO YES} {
 			    if {$binpie != "NO"} {
 				lappend opts {additional_flags=-fPIE}
 				lappend opts {ldflags=-pie}
+			    } else {
+				# Recent Debian/Ubuntu defaults PIE enabled. Ensure it is disabled.
+				lappend opts {additional_flags=-no-pie}
+				lappend opts {ldflags=-no-pie}
 			    }
 
 			    set dir ${exec}.d
diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp
index 44b0988b80..b2d7ef938a 100644
--- a/gdb/testsuite/gdb.base/dump.exp
+++ b/gdb/testsuite/gdb.base/dump.exp
@@ -36,6 +36,10 @@  if {[istarget "spu*-*-*"]} then {
     set is64bitonly "yes"
 }
 
+# Ensure -pie is disabled as this breaks IHEX tests.
+# (PIE defaults to enabled on recent Debian/Ubuntu).
+lappend options "additional_flags=-no-pie"
+
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ${options}] != "" } {
      untested "failed to compile"
      return -1