From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11924 invoked by alias); 19 Mar 2019 16:07:42 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 11915 invoked by uid 89); 19 Mar 2019 16:07:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy=chose X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 19 Mar 2019 16:07:40 +0000 Received: from [172.16.0.89] (192-222-157-41.qc.cable.ebox.net [192.222.157.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 8F8471E471; Tue, 19 Mar 2019 12:07:38 -0400 (EDT) Subject: Re: [PATCH] Testsuite: Ensure pie is disabled on some tests To: Alan Hayward Cc: "gdb-patches@sourceware.org" , nd References: <20190306102006.99150-1-alan.hayward@arm.com> <696945e9-4942-5285-0bb4-0bf899606f0a@simark.ca> <260313A3-D685-4306-8DE1-080D51BAE0BE@arm.com> From: Simon Marchi Message-ID: Date: Tue, 19 Mar 2019 16:07:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <260313A3-D685-4306-8DE1-080D51BAE0BE@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-SW-Source: 2019-03/txt/msg00408.txt.bz2 On 2019-03-19 11:45 a.m., Alan Hayward wrote: > > >> On 19 Mar 2019, at 13:47, Simon Marchi wrote: >> >> 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 >>> * 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”). > > Aha! That’s exactly what I needed. > > In my mind, we should have a “pie” flag too. I’ll add this in too. Good idea. > Updated. I would have pushed this new version - but - I’m a little unsure about adding the additional board flags. > > Pie option adds both flag and ldflag versions to make sure it gets the cases where we’re just compiling to objects. Right, if we are looking to enable pie (versus disabling it), we need both. > This version ok? > > > 2019-03-19 Alan Hayward > > * README: Add pie options. > * gdb.base/break-interp.exp: Ensure pie is disabled. > * gdb.base/dump.exp: Likewise. > * lib/gdb.exp (gdb_compile): Add pie option. > > diff --git a/gdb/testsuite/README b/gdb/testsuite/README > index b5e75b9a79..25381cdf04 100644 > --- a/gdb/testsuite/README > +++ b/gdb/testsuite/README > @@ -482,6 +482,16 @@ gdb,no_thread_names > > The target doesn't support thread names. > > +gdb,pie_flag > + > + The flag required to force the compiler to produce position-independent > + executables. > + > +gdb,ldpie_flag > + > + The flag required to force the linker to produce position-independent > + executables. > + "pie_ldflag" sounds more natural to me than "ldpie_flag", unless you chose this name to be consistent with other existing options? > gdb,nopie_flag > > The flag required to force the compiler to produce non-position-independent > diff --git a/gdb/testsuite/gdb.base/break-interp.exp b/gdb/testsuite/gdb.base/break-interp.exp > index f85e8a650a..8bb853c041 100644 > --- a/gdb/testsuite/gdb.base/break-interp.exp > +++ b/gdb/testsuite/gdb.base/break-interp.exp > @@ -625,8 +625,10 @@ foreach ldprelink {NO YES} { > lappend opts {debug} > } > if {$binpie != "NO"} { > - lappend opts {additional_flags=-fPIE} > - lappend opts {ldflags=-pie} > + lappend opts {pie} > + } else { > + # Recent Debian/Ubuntu defaults to PIE enabled. Ensure it is disabled. > + lappend opts {nopie} > } > > set dir ${exec}.d > diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp > index 44b0988b80..56dcafd4cb 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" > } > > +# Recent Debian/Ubuntu defaults to PIE enabled. Ensure it is disabled as this > +# causes addresses to be out of range for IHEX. > +lappend options {nopie} > + > if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ${options}] != "" } { > untested "failed to compile" > return -1 > diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp > index f13f909c34..259865f5fd 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -3461,6 +3461,7 @@ set gdb_saved_set_unbuffered_mode_obj "" > # dynamically load libraries at runtime. For example, on Linux, this adds > # -ldl so that the test can use dlopen. > # - nowarnings: Inhibit all compiler warnings. > +# - pie: Force creation of PIE executables. > # - nopie: Prevent creation of PIE executables. > # > # And here are some of the not too obscure options understood by DejaGnu that > @@ -3599,8 +3600,27 @@ proc gdb_compile {source dest type options} { > set options [lreplace $options $nowarnings $nowarnings $flag] > } > > - # Replace the "nopie" option with the appropriate additional_flags > - # to disable PIE executables. > + # Replace the "pie" option with the appropriate flags to enable PIE > + # executables. > + set pie [lsearch -exact $options pie] > + if {$pie != -1} { > + if [target_info exists gdb,pie_flag] { > + set flag "additional_flags=[target_info gdb,pie_flag]" > + } else { > + set flag "additional_flags=-fpie" I know there's a difference between -fpie and -fPIE, but I don't really that what it is about. Did you choose -fpie on purpose? Since it matters on AArch64, among others, maybe you know the difference? Simon