public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] add a configure option for using RELRO by default
@ 2015-01-14 15:22 Daniel Micay
  2015-02-27 19:36 ` Nicholas Clifton
  2015-02-27 19:42 ` Matthias Klose
  0 siblings, 2 replies; 21+ messages in thread
From: Daniel Micay @ 2015-01-14 15:22 UTC (permalink / raw)
  To: binutils; +Cc: nickc, Daniel Micay

2015-01-14  Daniel Micay  <danielmicay@gmail.com>

	* ld/configure.ac: Add --enable-default-relro switch.
	* ld/emultempl/elf32.em: Handle ENABLE_DEFAULT_RELRO.
	* ld/testsuite/config/default.exp: Disable RELRO.
	* ld/testsuite/ld-bootstrap/bootstrap.exp: Disable RELRO.
	* ld/config.in: Regenerate.
	* ld/configure: Regenerate.
---
 ld/ChangeLog                            |  9 +++++++++
 ld/config.in                            |  3 +++
 ld/configure                            | 16 ++++++++++++++--
 ld/configure.ac                         |  7 +++++++
 ld/emultempl/elf32.em                   |  3 +++
 ld/testsuite/config/default.exp         |  6 +++---
 ld/testsuite/ld-bootstrap/bootstrap.exp |  8 +++++++-
 7 files changed, 46 insertions(+), 6 deletions(-)

diff --git a/ld/ChangeLog b/ld/ChangeLog
index be4617f..be24325 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,12 @@
+2015-01-14  Daniel Micay  <danielmicay@gmail.com>
+
+	* configure.ac: Add --enable-default-relro switch.
+	* emultempl/elf32.em: Handle ENABLE_DEFAULT_RELRO.
+	* testsuite/config/default.exp: Disable RELRO.
+	* testsuite/ld-bootstrap/bootstrap.exp: Disable RELRO.
+	* config.in: Regenerate.
+	* configure: Regenerate.
+
 2015-01-01  Alan Modra  <amodra@gmail.com>
 
 	* ldver.c (ldversion): Just print current year.
diff --git a/ld/config.in b/ld/config.in
index 2ab4844..8afcc16 100644
--- a/ld/config.in
+++ b/ld/config.in
@@ -17,6 +17,9 @@
 /* Define to choose default GOT handling scheme */
 #undef GOT_HANDLING_DEFAULT
 
+/* Define to mark relocations read-only by default. */
+#undef ENABLE_DEFAULT_RELRO
+
 /* Define to 1 if you have the `close' function. */
 #undef HAVE_CLOSE
 
diff --git a/ld/configure b/ld/configure
index 8a7bd20..337e68c 100755
--- a/ld/configure
+++ b/ld/configure
@@ -785,6 +785,7 @@ enable_64_bit_bfd
 with_sysroot
 enable_gold
 enable_got
+enable_default_relro
 enable_werror
 enable_build_warnings
 enable_nls
@@ -1442,6 +1443,7 @@ Optional Features:
   --enable-gold[=ARG]     build gold [ARG={default,yes,no}]
   --enable-got=<type>     GOT handling scheme (target, single, negative,
                           multigot)
+  --enable-default-relro       mark relocations read-only by default
   --enable-werror         treat compile warnings as errors
   --enable-build-warnings enable build-time compiler warnings
   --disable-nls           do not use Native Language Support
@@ -11712,7 +11714,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11715 "configure"
+#line 11717 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11818,7 +11820,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11821 "configure"
+#line 11823 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -15520,6 +15522,16 @@ $as_echo "#define GOT_HANDLING_DEFAULT GOT_HANDLING_MULTIGOT" >>confdefs.h
   *)  as_fn_error "bad value ${got_handling} for --enable-got option" "$LINENO" 5 ;;
 esac
 
+# Check whether --enable-default-relro was given.
+if test "${enable_default_relro+set}" = set; then :
+  enableval=$enable_default_relro;
+
+$as_echo "#define ENABLE_DEFAULT_RELRO  " >>confdefs.h
+
+
+fi
+
+
 
 # Set the 'development' global.
 . $srcdir/../bfd/development.sh
diff --git a/ld/configure.ac b/ld/configure.ac
index 043c597..1e5153f 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -142,6 +142,13 @@ case "${got_handling}" in
   *)  AC_MSG_ERROR(bad value ${got_handling} for --enable-got option) ;;
 esac
 
+AC_ARG_ENABLE(default-relro,
+              [  --enable-default-relro       mark relocations read-only by default],
+[
+  AC_DEFINE([ENABLE_DEFAULT_RELRO], [ ],
+            [Define to mark relocations read-only by default.])
+], [])
+
 AM_BINUTILS_WARNINGS
 
 AM_LC_MESSAGES
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 34a729e..c994783 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -102,6 +102,9 @@ gld${EMULATION_NAME}_before_parse (void)
   input_flags.dynamic = ${DYNAMIC_LINK-TRUE};
   config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
   config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
+#ifdef ENABLE_DEFAULT_RELRO
+  link_info.relro = TRUE;
+#endif
 }
 
 EOF
diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
index e25189b..5eadf07 100644
--- a/ld/testsuite/config/default.exp
+++ b/ld/testsuite/config/default.exp
@@ -22,7 +22,7 @@
 #
 
 if ![info exists ld] then {
-    set ld [findfile $base_dir/ld-new $base_dir/ld-new [transform ld]]
+    set ld "[findfile $base_dir/ld-new $base_dir/ld-new [transform ld]] -znorelro"
 }
 
 if ![info exists as] then {
@@ -60,7 +60,7 @@ if {![file isdirectory tmpdir/ld]} then {
     catch "exec ln -s ld tmpdir/ld/collect-ld" status
     catch "exec ln -s ../../../gas/as-new tmpdir/ld/as" status
 }
-set gcc_B_opt "-B[pwd]/tmpdir/ld/"
+set gcc_B_opt "-B[pwd]/tmpdir/ld/ -Wl,-z,norelro"
 
 # load the linker path
 set ld_L_opt ""
@@ -272,7 +272,7 @@ if ![info exists READELFFLAGS] then {
 }
 
 if ![info exists LD] then {
-    set LD [findfile $base_dir/ld-new ./ld-new [transform ld]]
+    set LD "[findfile $base_dir/ld-new ./ld-new [transform ld]] -znorelro"
 }
 
 if ![info exists LDFLAGS] then {
diff --git a/ld/testsuite/ld-bootstrap/bootstrap.exp b/ld/testsuite/ld-bootstrap/bootstrap.exp
index fe8031d..23b0e10 100644
--- a/ld/testsuite/ld-bootstrap/bootstrap.exp
+++ b/ld/testsuite/ld-bootstrap/bootstrap.exp
@@ -78,7 +78,13 @@ foreach flags $test_flags {
 
     # This test can only be run if we have the ld build directory,
     # since we need the object files.
-    if {$ld != "$objdir/ld-new"} {
+    set ldexe $ld
+    set ldparm [string first " " $ld]
+    if { $ldparm > 0 } then {
+	set ldparm [expr $ldparm - 1]
+	set ldexe [string range $ld 0 $ldparm]
+    }
+    if {$ldexe != "$objdir/ld-new"} {
 	untested $testname
 	continue
     }
-- 
2.2.2

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] add a configure option for using RELRO by default
  2015-01-14 15:22 [PATCH] add a configure option for using RELRO by default Daniel Micay
@ 2015-02-27 19:36 ` Nicholas Clifton
  2015-02-27 19:42 ` Matthias Klose
  1 sibling, 0 replies; 21+ messages in thread
From: Nicholas Clifton @ 2015-02-27 19:36 UTC (permalink / raw)
  To: Daniel Micay, binutils; +Cc: nickc

Hi Daniel,

> 2015-01-14  Daniel Micay  <danielmicay@gmail.com>
>
> 	* ld/configure.ac: Add --enable-default-relro switch.
> 	* ld/emultempl/elf32.em: Handle ENABLE_DEFAULT_RELRO.
> 	* ld/testsuite/config/default.exp: Disable RELRO.
> 	* ld/testsuite/ld-bootstrap/bootstrap.exp: Disable RELRO.
> 	* ld/config.in: Regenerate.
> 	* ld/configure: Regenerate.

Approved - please apply.

Cheers
   Nick


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] add a configure option for using RELRO by default
  2015-01-14 15:22 [PATCH] add a configure option for using RELRO by default Daniel Micay
  2015-02-27 19:36 ` Nicholas Clifton
@ 2015-02-27 19:42 ` Matthias Klose
  2015-02-27 23:30   ` Daniel Micay
  1 sibling, 1 reply; 21+ messages in thread
From: Matthias Klose @ 2015-02-27 19:42 UTC (permalink / raw)
  To: Daniel Micay, binutils; +Cc: nickc

On 01/14/2015 04:21 PM, Daniel Micay wrote:
> 2015-01-14  Daniel Micay  <danielmicay@gmail.com>
> 
> 	* ld/configure.ac: Add --enable-default-relro switch.
> 	* ld/emultempl/elf32.em: Handle ENABLE_DEFAULT_RELRO.
> 	* ld/testsuite/config/default.exp: Disable RELRO.
> 	* ld/testsuite/ld-bootstrap/bootstrap.exp: Disable RELRO.
> 	* ld/config.in: Regenerate.
> 	* ld/configure: Regenerate.

shouldn't that change the default for gold too?

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] add a configure option for using RELRO by default
  2015-02-27 19:42 ` Matthias Klose
@ 2015-02-27 23:30   ` Daniel Micay
  0 siblings, 0 replies; 21+ messages in thread
From: Daniel Micay @ 2015-02-27 23:30 UTC (permalink / raw)
  To: Matthias Klose, binutils; +Cc: nickc

[-- Attachment #1: Type: text/plain, Size: 556 bytes --]

On 27/02/15 10:59 AM, Matthias Klose wrote:
> On 01/14/2015 04:21 PM, Daniel Micay wrote:
>> 2015-01-14  Daniel Micay  <danielmicay@gmail.com>
>>
>> 	* ld/configure.ac: Add --enable-default-relro switch.
>> 	* ld/emultempl/elf32.em: Handle ENABLE_DEFAULT_RELRO.
>> 	* ld/testsuite/config/default.exp: Disable RELRO.
>> 	* ld/testsuite/ld-bootstrap/bootstrap.exp: Disable RELRO.
>> 	* ld/config.in: Regenerate.
>> 	* ld/configure: Regenerate.
> 
> shouldn't that change the default for gold too?

That's true, I'll add that into the commit.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] add a configure option for using RELRO by default
  2015-11-24  9:20               ` Romain Geissler
@ 2015-11-24  9:56                 ` Nick Clifton
  0 siblings, 0 replies; 21+ messages in thread
From: Nick Clifton @ 2015-11-24  9:56 UTC (permalink / raw)
  To: Romain Geissler; +Cc: Mike Frysinger, binutils, schwab, hjl.tools, danielmicay

[-- Attachment #1: Type: text/plain, Size: 344 bytes --]

Hi Romain

> No I don't have currently any FSF copyright assignment and my employer
> (Amadeus) never set that up until today, so it will take a bit of time.
> The Amadeus legal team was contacted to fix this problem.
>
> Do you have a form for a corporate level assignment that I could forward
> to them ?

Sure, attached...

Cheers
   Nick



[-- Attachment #2: assign.changes.manual --]
[-- Type: text/plain, Size: 5656 bytes --]

The way to assign copyright to the Foundation is to sign an assignment
contract.  This is what legally makes the FSF the copyright holder so
that we can register the copyright on the new version.
I'm assuming that you wrote these changes yourself;
if other people wrote parts, we may need papers from them.

If you are employed to do writing (even at a university), or have
made an agreement with your employer or school saying it owns text
you write, then you and we need a signed piece of paper from your
employer disclaiming rights to your changes.

The disclaimer should be signed by a vice president or general manager
of the company.  If you can't get at them, anyone else authorized to
license manuals produced there will do.  Here is a sample wording:

  Digital Stimulation Corporation hereby disclaims all copyright
  interest in the changes and enhancements made by Hugh Heffner to the
  manual "The Seduction Manual", also including any future revisions
  of these changes and enhancements.  We do not consider them as a work
  made for hire for us.

  <signature of Ty Coon>, 1 April 1987
  Ty Coon, President of Vice, Digital Stimulation Corp.

IMPORTANT: When you talk to your employer, *no matter what
instructions they have given you*, don't fail to show them the sample
disclaimer above, or a disclaimer with the details filled in for your
specific case.  Companies are usually willing to sign a disclaimer
without any fuss.  If you make your request less specific, you may
open Pandora's box and cause a long and unnecessary delay.

Below is the assignment contract that we usually use.  You would need
to print it out, sign it, and snail it to:

Assignment Coordinator
Free Software Foundation
51 Franklin Street, Suite 500
Boston, MA 02110-1335
USA

Snail a copy of the employer's disclaimer as well.

Please send me email about what you decide to do.  If you have any
questions, or would like something to be changed, ask rms@ai.mit.edu via email.
\f			    ASSIGNMENT

   For good and valuable consideration, receipt of which I acknowledge, I,
NAME OF PERSON, hereby transfer to the Free Software Foundation, Inc. (the
"Foundation") my entire right, title, and interest (including all rights
under copyright) in my changes and enhancements to the manual "NAME OF
MANUAL", subject to the conditions below.  These changes and enhancements
are herein called the "Work".  The work hereby assigned shall also include
any future revisions of these changes and enhancements hereafter made by me.

   Upon thirty days' prior written notice, the Foundation agrees to
grant me non-exclusive rights to use the Work (i.e. my changes and
enhancements, not the manual which I enhanced) as I see fit; (and the
Foundation's rights shall otherwise continue unchanged).

   For the purposes of this contract, a work "based on the Work" means
any work that in whole or in part incorporates or is derived from all or
part of the Work.

   The Foundation promises that all distribution of the Work, or of any
work "based on the Work", that takes place under the control of the
Foundation or its assignees, shall be on terms that explicitly and
perpetually permit anyone possessing a copy of the work to which the terms
apply, and possessing accurate notice of these terms, to redistribute
copies of the work to anyone on the same terms.  These terms shall not
restrict which members of the public copies may be distributed to.  These
terms shall not require a member of the public to pay any royalty to the
Foundation or to anyone else for any permitted use of the work they apply
to, or to communicate with the Foundation or its agents in any way either
when redistribution is performed or on any other occasion.

   The Foundation promises to give or send me, upon reasonable prior notice
and payment of a fee no more than twenty times the cost of the necessary
materials and postage, a copy of any or all of the works "based on the
Work" that it offers to the public or that it has offered within the
past six months, or that it distributed for the first time within the past
six months.  My request shall detail whether I wish to receive all
such works or specific works.  My choice of works to request may affect the
cost and therefore the fee.

   I hereby represent and warrant that I am the sole copyright holder for the
Work and that I have the right and power to enter into this contract.  I
hereby indemnify and hold harmless the Foundation, its officers, employees,
and agents against any and all claims, actions or damages (including
attorney's reasonable fees) asserted by or paid to any party on account of a
breach or alleged breach of the foregoing warranty.  I make no other express
or implied warranty (including without limitation, in this disclaimer of
warranty, any warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE).

Agreed:  [signature]			Date:


ACCEPTED: FREE SOFTWARE FOUNDATION - Thanks for contributing to the GNU
project!

Richard M. Stallman, President
\f
Please do not delete the control-l character before this line.
Please print this as a separate page.

Please email a copy of the information on this page to
fsf-records@gnu.org, if you can, so that our clerk doesn't have
to type it in.  Use your full name as the subject line.

Otherwise, please write down the answers and snail this with
your assignment.

[For the copyright registration, what country are you a citizen of?]


[What year were you born?]


[What is your email address?]


[Please write your snail address here, so we can snail a copy back to you.]






[Which files have you changed so far, and which new files have you written
so far?]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] add a configure option for using RELRO by default
  2015-11-20 14:34             ` Nick Clifton
@ 2015-11-24  9:20               ` Romain Geissler
  2015-11-24  9:56                 ` Nick Clifton
  0 siblings, 1 reply; 21+ messages in thread
From: Romain Geissler @ 2015-11-24  9:20 UTC (permalink / raw)
  To: Nick Clifton
  Cc: Romain Geissler, Mike Frysinger, binutils, schwab, hjl.tools,
	danielmicay



On Fri, 20 Nov 2015, Nick Clifton wrote:

> Hi Romain,

Hi,

>
>   There is one small feature missing from your patch - a note in the ld/NEWS
> file mentioning the new configure option.

Ok I will add that as soon as I have the legal papers signed.

>   More important than that however is that I cannot find a FSF copyright
> assignment from you for the binutils.  Do you have one ? Without one we cannot
> accept the patch, since it does not count as an obvious fix.

No I don't have currently any FSF copyright assignment and my employer
(Amadeus) never set that up until today, so it will take a bit of time.
The Amadeus legal team was contacted to fix this problem.

Do you have a form for a corporate level assignment that I could forward
to them ?

Cheers,
Romain

>
> Cheers
>   Nick
>
>

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] add a configure option for using RELRO by default
  2015-11-11  2:10           ` Romain Geissler
@ 2015-11-20 14:34             ` Nick Clifton
  2015-11-24  9:20               ` Romain Geissler
  0 siblings, 1 reply; 21+ messages in thread
From: Nick Clifton @ 2015-11-20 14:34 UTC (permalink / raw)
  To: Romain Geissler; +Cc: Mike Frysinger, binutils, schwab, hjl.tools, danielmicay

Hi Romain,

   There is one small feature missing from your patch - a note in the 
ld/NEWS file mentioning the new configure option.

   More important than that however is that I cannot find a FSF 
copyright assignment from you for the binutils.  Do you have one ? 
Without one we cannot accept the patch, since it does not count as an 
obvious fix.

Cheers
   Nick

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] add a configure option for using RELRO by default
  2015-11-11  7:50               ` Mike Frysinger
@ 2015-11-11  7:58                 ` Daniel Micay
  0 siblings, 0 replies; 21+ messages in thread
From: Daniel Micay @ 2015-11-11  7:58 UTC (permalink / raw)
  To: Romain Geissler, binutils, schwab, hjl.tools

[-- Attachment #1: Type: text/plain, Size: 283 bytes --]

On 11/11/15 02:50 AM, Mike Frysinger wrote:
> On 11 Nov 2015 00:10, Daniel Micay wrote:
>> really be upstream (as should SSP by default in GCC).
> 
> gcc already has flags:
> 	--enable-default-ssp
> 	--enable-default-pie
> -mike

Ah, missed --enable-default-ssp landing.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] add a configure option for using RELRO by default
  2015-11-11  5:10             ` Daniel Micay
@ 2015-11-11  7:50               ` Mike Frysinger
  2015-11-11  7:58                 ` Daniel Micay
  0 siblings, 1 reply; 21+ messages in thread
From: Mike Frysinger @ 2015-11-11  7:50 UTC (permalink / raw)
  To: Daniel Micay; +Cc: Romain Geissler, binutils, schwab, hjl.tools

[-- Attachment #1: Type: text/plain, Size: 172 bytes --]

On 11 Nov 2015 00:10, Daniel Micay wrote:
> really be upstream (as should SSP by default in GCC).

gcc already has flags:
	--enable-default-ssp
	--enable-default-pie
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] add a configure option for using RELRO by default
  2015-11-11  4:48           ` Mike Frysinger
@ 2015-11-11  5:10             ` Daniel Micay
  2015-11-11  7:50               ` Mike Frysinger
  0 siblings, 1 reply; 21+ messages in thread
From: Daniel Micay @ 2015-11-11  5:10 UTC (permalink / raw)
  To: Romain Geissler, binutils, schwab, hjl.tools

[-- Attachment #1: Type: text/plain, Size: 1118 bytes --]

On 10/11/15 11:48 PM, Mike Frysinger wrote:
> On 11 Nov 2015 03:01, Romain Geissler wrote:
>> For us the goal is obviously to activate it by default, like many we have
>> been using relro binaries for years now without any issue (x64). I know
>> SuSe that we use is shipping by default binutils having a similar patch.
>> However I'll wait the advice of the binutils gurus to decide this change.
> 
> i don't remember if i mentioned this before, but we've been doing it in Gentoo
> as well for all arches/targets since at least 2.18 / 2008.  i don't recall any 
> grievous bugs due to it, but it's been a long time ...
> -mike

There's a similar patch in Fedora. I want this enabled in Arch Linux
(which already uses RELRO, strong SSP, _FORTIFY_SOURCE=2, etc. via
CFLAGS/LDFLAGS), but it has a policy against applying patches not
accepted by upstream (i.e. backports are fine). There's a cost to having
stuff like this out-of-tree. If the major distributions want this and
patch their toolchain to have it, that's a strong sign that it should
really be upstream (as should SSP by default in GCC).


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] add a configure option for using RELRO by default
       [not found]         ` <alpine.LNX.2.10.1511110256280.26881@ncegcolnx273.nce.amadeus.net>
  2015-11-11  2:10           ` Romain Geissler
@ 2015-11-11  4:48           ` Mike Frysinger
  2015-11-11  5:10             ` Daniel Micay
  1 sibling, 1 reply; 21+ messages in thread
From: Mike Frysinger @ 2015-11-11  4:48 UTC (permalink / raw)
  To: Romain Geissler; +Cc: binutils, schwab, hjl.tools, danielmicay

[-- Attachment #1: Type: text/plain, Size: 577 bytes --]

On 11 Nov 2015 03:01, Romain Geissler wrote:
> For us the goal is obviously to activate it by default, like many we have
> been using relro binaries for years now without any issue (x64). I know
> SuSe that we use is shipping by default binutils having a similar patch.
> However I'll wait the advice of the binutils gurus to decide this change.

i don't remember if i mentioned this before, but we've been doing it in Gentoo
as well for all arches/targets since at least 2.18 / 2008.  i don't recall any 
grievous bugs due to it, but it's been a long time ...
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] add a configure option for using RELRO by default
       [not found]         ` <alpine.LNX.2.10.1511110256280.26881@ncegcolnx273.nce.amadeus.net>
@ 2015-11-11  2:10           ` Romain Geissler
  2015-11-20 14:34             ` Nick Clifton
  2015-11-11  4:48           ` Mike Frysinger
  1 sibling, 1 reply; 21+ messages in thread
From: Romain Geissler @ 2015-11-11  2:10 UTC (permalink / raw)
  To: Romain Geissler; +Cc: Mike Frysinger, binutils, schwab, hjl.tools, danielmicay


Re-sending this mail after spam notice from binutils mailing list daemon.

On Wed, 11 Nov 2015, Romain Geissler wrote:

> On Wed, 11 Nov 2015, Mike Frysinger wrote:
>
> > On 11 Nov 2015 00:51, Romain Geissler wrote:
> > > On Tue, 10 Nov 2015, Mike Frysinger wrote:
> > > > On 10 Nov 2015 22:16, Romain Geissler wrote:
> > > > > --- a/gold/configure.ac
> > > > > +++ b/gold/configure.ac
> > > > >
> > > > > +# Decide whether you want to set "-z relro" by default
> > > >
> > > > should be a dnl instead of a # ?
> > > >
> > > > > +ac_default_relro=unset
> > >
> > > With dnl this comment will not be in the generated configure file. With #
> > > it will. For me it might help to have this comment when investigating
> > > issues in configure. So I let it this way. Unless you want me to really
> > > switch to dnl.
> >
> > i think everything should be a dnl unless there's an explicit reason,
> > but i don't think we have a policy on this
> >
> > > +esac], default_relro=unset)
> >
> > would be good to quote with [] too.  applies to both configure scripts.
>
> Fixed.
>
> > otherwise looks fine to me.  not sure if we want to make it default to yes
> > for some targets (like linux?) but we can debate that in a follow up commit.
> > -mike
>
> For us the goal is obviously to activate it by default, like many we have
> been using relro binaries for years now without any issue (x64). I know
> SuSe that we use is shipping by default binutils having a similar patch.
> However I'll wait the advice of the binutils gurus to decide this change.
>
> Cheers,
> Romain

gold/ChangeLog:
2015-11-10  Romain Geissler  <romain.geissler@amadeus.com>

	* configure.ac: Add --enable-default-relro switch.
	* options.cc (General_options::finalize): Disable relro if not set
	explicitly when linking incrementally.
	* options.h (General_options): Handle DEFAULT_RELRO.
	* config.in: Regenerate.
	* configure: Regenerate.
	* Makefile.in: Regenerate.

ld/ChangeLog:
2015-11-10  Romain Geissler  <romain.geissler@amadeus.com>

	* configure.ac: Add --enable-default-relro switch.
	* emultempl/elf32.em: Handle DEFAULT_RELRO.
	* testsuite/config/default.exp: Disable RELRO.
	* testsuite/ld-bootstrap/bootstrap.exp: Disable RELRO.
	* config.in: Regenerate.
	* configure: Regenerate.

ld/testsuite/ChangeLog:
2015-11-10  Romain Geissler  <romain.geissler@amadeus.com>

	* config/default.exp (ld, LD, ld_L_opt): Append -z norelro for ELF targets.
	* ld-bootstrap/bootstrap.exp (ldexe): New.


diff --git a/gold/Makefile.in b/gold/Makefile.in
index dbfde80..d04378e 100644
--- a/gold/Makefile.in
+++ b/gold/Makefile.in
@@ -70,8 +70,8 @@ subdir = .
 DIST_COMMON = NEWS README ChangeLog $(srcdir)/Makefile.in \
 	$(srcdir)/Makefile.am $(top_srcdir)/configure \
 	$(am__configure_deps) $(srcdir)/config.in \
-	$(srcdir)/../mkinstalldirs $(top_srcdir)/po/Make-in pread.c \
-	ffsll.c ftruncate.c mremap.c yyscript.h yyscript.c \
+	$(srcdir)/../mkinstalldirs $(top_srcdir)/po/Make-in ffsll.c \
+	ftruncate.c pread.c mremap.c yyscript.h yyscript.c \
 	$(srcdir)/../depcomp $(srcdir)/../ylwrap
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
diff --git a/gold/config.in b/gold/config.in
index 88e8712..fe6190b 100644
--- a/gold/config.in
+++ b/gold/config.in
@@ -10,6 +10,9 @@
 /* Define if building universal (internal helper macro) */
 #undef AC_APPLE_UNIVERSAL_BUILD

+/* Define if you want to use read only relocations by default */
+#undef DEFAULT_RELRO
+
 /* Define to 1 if translation of program messages to the user's native
    language is requested. */
 #undef ENABLE_NLS
diff --git a/gold/configure b/gold/configure
index 987a846..635de35 100755
--- a/gold/configure
+++ b/gold/configure
@@ -791,6 +791,7 @@ enable_gold
 enable_threads
 enable_plugins
 enable_targets
+enable_default_relro
 with_lib_path
 enable_dependency_tracking
 enable_nls
@@ -1440,6 +1441,7 @@ Optional Features:
   --enable-threads        multi-threaded linking
   --enable-plugins        linker plugins
   --enable-targets        alternative target configurations
+  --enable-default-relro  mark relocations read-only by default
   --disable-dependency-tracking  speeds up one-time build
   --enable-dependency-tracking   do not reject slow dependency extractors
   --disable-nls           do not use Native Language Support
@@ -3384,6 +3386,24 @@ if test -n "$enable_targets"; then
   done
 fi

+# Check whether --enable-default-relro was given.
+if test "${enable_default_relro+set}" = set; then :
+  enableval=$enable_default_relro; case "${enableval}" in
+  yes) default_relro=yes ;;
+  no) ac_default_relro=no ;;
+  *) as_fn_error "bad value ${enableval} for default-relro option" "$LINENO" 5 ;;
+esac
+else
+  default_relro=unset
+fi
+
+
+if test "x$default_relro" = "xyes" ; then
+
+$as_echo "#define DEFAULT_RELRO 1" >>confdefs.h
+
+fi
+
 # See which specific instantiations we need.
 targetobjs=
 all_targets=
diff --git a/gold/configure.ac b/gold/configure.ac
index 89f6c53..6ba3257 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -144,6 +144,19 @@ if test -n "$enable_targets"; then
   done
 fi

+dnl Decide whether you want to set "-z relro" by default
+AC_ARG_ENABLE([default-relro],
+              AS_HELP_STRING([--enable-default-relro], [mark relocations read-only by default]),
+[case "${enableval}" in
+  yes) default_relro=yes ;;
+  no) ac_default_relro=no ;;
+  *) AC_MSG_ERROR([bad value ${enableval} for default-relro option]) ;;
+esac], [default_relro=unset])
+
+if test "x$default_relro" = "xyes" ; then
+  AC_DEFINE([DEFAULT_RELRO], [1], [Define if you want to use read only relocations by default])
+fi
+
 # See which specific instantiations we need.
 targetobjs=
 all_targets=
diff --git a/gold/options.cc b/gold/options.cc
index c42623f..2c1994a 100644
--- a/gold/options.cc
+++ b/gold/options.cc
@@ -1279,7 +1279,12 @@ General_options::finalize()
       if (this->has_plugins())
 	gold_fatal(_("incremental linking is not compatible with --plugin"));
       if (this->relro())
-	gold_fatal(_("incremental linking is not compatible with -z relro"));
+      {
+        if (this->user_set_relro())
+          gold_fatal(_("incremental linking is not compatible with -z relro"));
+        else
+          this->set_relro(false);
+      }
       if (this->gc_sections())
 	{
 	  gold_warning(_("ignoring --gc-sections for an incremental link"));
diff --git a/gold/options.h b/gold/options.h
index ffc44e6..5cf003a 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -1332,7 +1332,12 @@ class General_options
   DEFINE_bool(origin, options::DASH_Z, '\0', false,
 	      N_("Mark DSO to indicate that needs immediate $ORIGIN "
 		 "processing at runtime"), NULL);
-  DEFINE_bool(relro, options::DASH_Z, '\0', false,
+#ifdef DEFAULT_RELRO
+# define DEFAULT_RELRO_VALUE true
+#else
+# define DEFAULT_RELRO_VALUE false
+#endif
+  DEFINE_bool(relro, options::DASH_Z, '\0', DEFAULT_RELRO_VALUE,
 	      N_("Where possible mark variables read-only after relocation"),
 	      N_("Don't mark variables read-only after relocation"));
   DEFINE_bool(text, options::DASH_Z, '\0', false,
diff --git a/ld/config.in b/ld/config.in
index 276fb77..002002c 100644
--- a/ld/config.in
+++ b/ld/config.in
@@ -10,6 +10,9 @@
 /* Define if you want compressed debug sections by default. */
 #undef DEFAULT_FLAG_COMPRESS_DEBUG

+/* Define if you want to use read only relocations by default */
+#undef DEFAULT_RELRO
+
 /* Define to 1 if translation of program messages to the user's native
    language is requested. */
 #undef ENABLE_NLS
diff --git a/ld/configure b/ld/configure
index b41efe8..f681d7d 100755
--- a/ld/configure
+++ b/ld/configure
@@ -789,6 +789,7 @@ with_sysroot
 enable_gold
 enable_got
 enable_compressed_debug_sections
+enable_default_relro
 enable_werror
 enable_build_warnings
 enable_nls
@@ -1447,6 +1448,7 @@ Optional Features:
                           multigot)
   --enable-compressed-debug-sections={all,ld,none}
                           compress debug sections by default]
+  --enable-default-relro  mark relocations read-only by default
   --enable-werror         treat compile warnings as errors
   --enable-build-warnings enable build-time compiler warnings
   --disable-nls           do not use Native Language Support
@@ -11716,7 +11718,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11719 "configure"
+#line 11721 "configure"
 #include "confdefs.h"

 #if HAVE_DLFCN_H
@@ -11822,7 +11824,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11825 "configure"
+#line 11827 "configure"
 #include "confdefs.h"

 #if HAVE_DLFCN_H
@@ -15536,6 +15538,24 @@ if test "${enable_compressed_debug_sections+set}" = set; then :
 esac
 fi

+# Check whether --enable-default-relro was given.
+if test "${enable_default_relro+set}" = set; then :
+  enableval=$enable_default_relro; case "${enableval}" in
+  yes) default_relro=yes ;;
+  no) ac_default_relro=no ;;
+  *) as_fn_error "bad value ${enableval} for default-relro option" "$LINENO" 5 ;;
+esac
+else
+  default_relro=unset
+fi
+
+
+if test "x$default_relro" = "xyes" ; then
+
+$as_echo "#define DEFAULT_RELRO 1" >>confdefs.h
+
+fi
+

 # Set the 'development' global.
 . $srcdir/../bfd/development.sh
diff --git a/ld/configure.ac b/ld/configure.ac
index 188172d..8dea9c1 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -155,6 +155,19 @@ AC_ARG_ENABLE(compressed_debug_sections,
   ,no, | ,none,)  ac_default_compressed_debug_sections=no ;;
 esac])dnl

+dnl Decide whether you want to set "-z relro" by default
+AC_ARG_ENABLE([default-relro],
+              AS_HELP_STRING([--enable-default-relro], [mark relocations read-only by default]),
+[case "${enableval}" in
+  yes) default_relro=yes ;;
+  no) ac_default_relro=no ;;
+  *) AC_MSG_ERROR([bad value ${enableval} for default-relro option]) ;;
+esac], [default_relro=unset])
+
+if test "x$default_relro" = "xyes" ; then
+  AC_DEFINE([DEFAULT_RELRO], [1], [Define if you want to use read only relocations by default])
+fi
+
 AM_BINUTILS_WARNINGS

 AM_LC_MESSAGES
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 0405d4f..d991c16 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -104,6 +104,9 @@ gld${EMULATION_NAME}_before_parse (void)
   config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
   config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
   `if test -n "$CALL_NOP_BYTE" ; then echo link_info.call_nop_byte = $CALL_NOP_BYTE; fi`;
+#ifdef DEFAULT_RELRO
+  link_info.relro = TRUE;
+#endif
 }

 EOF
diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
index 310a3b2..d74cdd3 100644
--- a/ld/testsuite/config/default.exp
+++ b/ld/testsuite/config/default.exp
@@ -21,8 +21,16 @@
 # Written by Jeffrey Wheat (cassidy@cygnus.com)
 #

+# load the utility procedures
+load_lib ld-lib.exp
+
 if ![info exists ld] then {
     set ld [findfile $base_dir/ld-new $base_dir/ld-new [transform ld]]
+
+    # Make sure tests pass even if configured with --enable-default-relro
+    if {[is_elf_format]} then {
+        append ld " -z norelro"
+    }
 }

 if ![info exists as] then {
@@ -76,6 +84,11 @@ if {[file exists tmpdir/libpath.exp]} {
     }
 }

+# Make sure tests pass even if configured with --enable-default-relro
+if {[is_elf_format]} then {
+    append ld_L_opt " -z norelro"
+}
+
 # The "make check" target in the Makefile passes in
 # "CC=$(CC_FOR_TARGET)".  But, if the user invokes runtest directly
 # (as when testing an installed linker), these flags may not be set.
@@ -108,9 +121,6 @@ if { [istarget rx-*-*] } {
     set ASFLAGS "-muse-conventional-section-names"
 }

-# load the utility procedures
-load_lib ld-lib.exp
-
 proc get_link_files {varname} {
     global $varname
     global target_triplet
@@ -277,6 +287,11 @@ if ![info exists READELFFLAGS] then {

 if ![info exists LD] then {
     set LD [findfile $base_dir/ld-new ./ld-new [transform ld]]
+
+    # Make sure tests pass even if configured with --enable-default-relro
+    if {[is_elf_format]} then {
+        append LD " -z norelro"
+    }
 }

 if ![info exists LDFLAGS] then {
diff --git a/ld/testsuite/ld-bootstrap/bootstrap.exp b/ld/testsuite/ld-bootstrap/bootstrap.exp
index 3b6eb84..749bd9a 100644
--- a/ld/testsuite/ld-bootstrap/bootstrap.exp
+++ b/ld/testsuite/ld-bootstrap/bootstrap.exp
@@ -78,7 +78,13 @@ foreach flags $test_flags {

     # This test can only be run if we have the ld build directory,
     # since we need the object files.
-    if {$ld != "$objdir/ld-new"} {
+    set ldexe $ld
+    set ldparm [string first " " $ld]
+    if { $ldparm > 0 } then {
+        set ldparm [expr $ldparm - 1]
+        set ldexe [string range $ld 0 $ldparm]
+    }
+    if {$ldexe != "$objdir/ld-new"} {
 	untested $testname
 	continue
     }

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] add a configure option for using RELRO by default
  2015-11-10 23:52     ` Romain Geissler
@ 2015-11-11  1:24       ` Mike Frysinger
       [not found]         ` <alpine.LNX.2.10.1511110256280.26881@ncegcolnx273.nce.amadeus.net>
  0 siblings, 1 reply; 21+ messages in thread
From: Mike Frysinger @ 2015-11-11  1:24 UTC (permalink / raw)
  To: Romain Geissler; +Cc: binutils, schwab, hjl.tools, danielmicay

[-- Attachment #1: Type: text/plain, Size: 989 bytes --]

On 11 Nov 2015 00:51, Romain Geissler wrote:
> On Tue, 10 Nov 2015, Mike Frysinger wrote:
> > On 10 Nov 2015 22:16, Romain Geissler wrote:
> > > --- a/gold/configure.ac
> > > +++ b/gold/configure.ac
> > >
> > > +# Decide whether you want to set "-z relro" by default
> >
> > should be a dnl instead of a # ?
> >
> > > +ac_default_relro=unset
> 
> With dnl this comment will not be in the generated configure file. With #
> it will. For me it might help to have this comment when investigating
> issues in configure. So I let it this way. Unless you want me to really
> switch to dnl.

i think everything should be a dnl unless there's an explicit reason,
but i don't think we have a policy on this

> +esac], default_relro=unset)

would be good to quote with [] too.  applies to both configure scripts.

otherwise looks fine to me.  not sure if we want to make it default to yes
for some targets (like linux?) but we can debate that in a follow up commit.
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] add a configure option for using RELRO by default
  2015-11-10 23:28   ` Mike Frysinger
@ 2015-11-10 23:52     ` Romain Geissler
  2015-11-11  1:24       ` Mike Frysinger
  0 siblings, 1 reply; 21+ messages in thread
From: Romain Geissler @ 2015-11-10 23:52 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: Romain Geissler, binutils, schwab, hjl.tools, danielmicay

On Tue, 10 Nov 2015, Mike Frysinger wrote:

> On 10 Nov 2015 22:16, Romain Geissler wrote:
> > --- a/gold/configure.ac
> > +++ b/gold/configure.ac
> >
> > +# Decide whether you want to set "-z relro" by default
>
> should be a dnl instead of a # ?
>
> > +ac_default_relro=unset

With dnl this comment will not be in the generated configure file. With #
it will. For me it might help to have this comment when investigating
issues in configure. So I let it this way. Unless you want me to really
switch to dnl.

>
> i don't think we want the ac_ prefix since this isn't autoconf code.
>
> would be better too imo to make this the 4th arg to AC_ARG_ENABLE below.
>
> > +  *) AC_MSG_ERROR(bad value ${enableval} for default-relro option) ;;
>
> should quote the arg with []
>
> > +if test x$ac_default_relro == xyes ; then
>
> quote the LHS and change the == to =
>
> > +  AC_DEFINE(DEFAULT_RELRO, 1, [Define if you want to use read only relocations by default])
>
> quote the 1st & 2nd arg with []
>
> > +#ifdef DEFAULT_RELRO
> > +#define DEFAULT_RELRO_VALUE true
> > +#else
> > +#define DEFAULT_RELRO_VALUE false
> > +#endif
>
> should use "# define" imo
>
> > --- a/ld/configure.ac
> > +++ b/ld/configure.ac
>
> same feedback here as for gold
> -mike
>

I implemented that in v3.

gold/ChangeLog:
2015-11-10  Romain Geissler  <romain.geissler@amadeus.com>

	* configure.ac: Add --enable-default-relro switch.
	* options.cc (General_options::finalize): Disable relro if not set
	explicitly when linking incrementally.
	* options.h (General_options): Handle DEFAULT_RELRO.
	* config.in: Regenerate.
	* configure: Regenerate.
	* Makefile.in: Regenerate.

ld/ChangeLog:
2015-11-10  Romain Geissler  <romain.geissler@amadeus.com>

	* configure.ac: Add --enable-default-relro switch.
	* emultempl/elf32.em: Handle DEFAULT_RELRO.
	* testsuite/config/default.exp: Disable RELRO.
	* testsuite/ld-bootstrap/bootstrap.exp: Disable RELRO.
	* config.in: Regenerate.
	* configure: Regenerate.

ld/testsuite/ChangeLog:
2015-11-10  Romain Geissler  <romain.geissler@amadeus.com>

	* config/default.exp (ld, LD, ld_L_opt): Append -z norelro for ELF targets.
	* ld-bootstrap/bootstrap.exp (ldexe): New.



diff --git a/gold/Makefile.in b/gold/Makefile.in
index dbfde80..d04378e 100644
--- a/gold/Makefile.in
+++ b/gold/Makefile.in
@@ -70,8 +70,8 @@ subdir = .
 DIST_COMMON = NEWS README ChangeLog $(srcdir)/Makefile.in \
 	$(srcdir)/Makefile.am $(top_srcdir)/configure \
 	$(am__configure_deps) $(srcdir)/config.in \
-	$(srcdir)/../mkinstalldirs $(top_srcdir)/po/Make-in pread.c \
-	ffsll.c ftruncate.c mremap.c yyscript.h yyscript.c \
+	$(srcdir)/../mkinstalldirs $(top_srcdir)/po/Make-in ffsll.c \
+	ftruncate.c pread.c mremap.c yyscript.h yyscript.c \
 	$(srcdir)/../depcomp $(srcdir)/../ylwrap
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
diff --git a/gold/config.in b/gold/config.in
index 88e8712..fe6190b 100644
--- a/gold/config.in
+++ b/gold/config.in
@@ -10,6 +10,9 @@
 /* Define if building universal (internal helper macro) */
 #undef AC_APPLE_UNIVERSAL_BUILD

+/* Define if you want to use read only relocations by default */
+#undef DEFAULT_RELRO
+
 /* Define to 1 if translation of program messages to the user's native
    language is requested. */
 #undef ENABLE_NLS
diff --git a/gold/configure b/gold/configure
index 987a846..4b2ffc4 100755
--- a/gold/configure
+++ b/gold/configure
@@ -791,6 +791,7 @@ enable_gold
 enable_threads
 enable_plugins
 enable_targets
+enable_default_relro
 with_lib_path
 enable_dependency_tracking
 enable_nls
@@ -1440,6 +1441,7 @@ Optional Features:
   --enable-threads        multi-threaded linking
   --enable-plugins        linker plugins
   --enable-targets        alternative target configurations
+  --enable-default-relro  mark relocations read-only by default
   --disable-dependency-tracking  speeds up one-time build
   --enable-dependency-tracking   do not reject slow dependency extractors
   --disable-nls           do not use Native Language Support
@@ -3384,6 +3386,25 @@ if test -n "$enable_targets"; then
   done
 fi

+# Decide whether you want to set "-z relro" by default
+# Check whether --enable-default-relro was given.
+if test "${enable_default_relro+set}" = set; then :
+  enableval=$enable_default_relro; case "${enableval}" in
+  yes) default_relro=yes ;;
+  no) ac_default_relro=no ;;
+  *) as_fn_error "bad value ${enableval} for default-relro option" "$LINENO" 5 ;;
+esac
+else
+  default_relro=unset
+fi
+
+
+if test "x$default_relro" = "xyes" ; then
+
+$as_echo "#define DEFAULT_RELRO 1" >>confdefs.h
+
+fi
+
 # See which specific instantiations we need.
 targetobjs=
 all_targets=
diff --git a/gold/configure.ac b/gold/configure.ac
index 89f6c53..d4a4b39 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -144,6 +144,19 @@ if test -n "$enable_targets"; then
   done
 fi

+# Decide whether you want to set "-z relro" by default
+AC_ARG_ENABLE([default-relro],
+              AS_HELP_STRING([--enable-default-relro], [mark relocations read-only by default]),
+[case "${enableval}" in
+  yes) default_relro=yes ;;
+  no) ac_default_relro=no ;;
+  *) AC_MSG_ERROR([bad value ${enableval} for default-relro option]) ;;
+esac], default_relro=unset)
+
+if test "x$default_relro" = "xyes" ; then
+  AC_DEFINE([DEFAULT_RELRO], [1], [Define if you want to use read only relocations by default])
+fi
+
 # See which specific instantiations we need.
 targetobjs=
 all_targets=
diff --git a/gold/options.cc b/gold/options.cc
index c42623f..2c1994a 100644
--- a/gold/options.cc
+++ b/gold/options.cc
@@ -1279,7 +1279,12 @@ General_options::finalize()
       if (this->has_plugins())
 	gold_fatal(_("incremental linking is not compatible with --plugin"));
       if (this->relro())
-	gold_fatal(_("incremental linking is not compatible with -z relro"));
+      {
+        if (this->user_set_relro())
+          gold_fatal(_("incremental linking is not compatible with -z relro"));
+        else
+          this->set_relro(false);
+      }
       if (this->gc_sections())
 	{
 	  gold_warning(_("ignoring --gc-sections for an incremental link"));
diff --git a/gold/options.h b/gold/options.h
index ffc44e6..5cf003a 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -1332,7 +1332,12 @@ class General_options
   DEFINE_bool(origin, options::DASH_Z, '\0', false,
 	      N_("Mark DSO to indicate that needs immediate $ORIGIN "
 		 "processing at runtime"), NULL);
-  DEFINE_bool(relro, options::DASH_Z, '\0', false,
+#ifdef DEFAULT_RELRO
+# define DEFAULT_RELRO_VALUE true
+#else
+# define DEFAULT_RELRO_VALUE false
+#endif
+  DEFINE_bool(relro, options::DASH_Z, '\0', DEFAULT_RELRO_VALUE,
 	      N_("Where possible mark variables read-only after relocation"),
 	      N_("Don't mark variables read-only after relocation"));
   DEFINE_bool(text, options::DASH_Z, '\0', false,
diff --git a/ld/config.in b/ld/config.in
index 276fb77..002002c 100644
--- a/ld/config.in
+++ b/ld/config.in
@@ -10,6 +10,9 @@
 /* Define if you want compressed debug sections by default. */
 #undef DEFAULT_FLAG_COMPRESS_DEBUG

+/* Define if you want to use read only relocations by default */
+#undef DEFAULT_RELRO
+
 /* Define to 1 if translation of program messages to the user's native
    language is requested. */
 #undef ENABLE_NLS
diff --git a/ld/configure b/ld/configure
index b41efe8..4ea45a8 100755
--- a/ld/configure
+++ b/ld/configure
@@ -789,6 +789,7 @@ with_sysroot
 enable_gold
 enable_got
 enable_compressed_debug_sections
+enable_default_relro
 enable_werror
 enable_build_warnings
 enable_nls
@@ -1447,6 +1448,7 @@ Optional Features:
                           multigot)
   --enable-compressed-debug-sections={all,ld,none}
                           compress debug sections by default]
+  --enable-default-relro  mark relocations read-only by default
   --enable-werror         treat compile warnings as errors
   --enable-build-warnings enable build-time compiler warnings
   --disable-nls           do not use Native Language Support
@@ -11716,7 +11718,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11719 "configure"
+#line 11721 "configure"
 #include "confdefs.h"

 #if HAVE_DLFCN_H
@@ -11822,7 +11824,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11825 "configure"
+#line 11827 "configure"
 #include "confdefs.h"

 #if HAVE_DLFCN_H
@@ -15536,6 +15538,25 @@ if test "${enable_compressed_debug_sections+set}" = set; then :
 esac
 fi

+# Decide whether you want to set "-z relro" by default
+# Check whether --enable-default-relro was given.
+if test "${enable_default_relro+set}" = set; then :
+  enableval=$enable_default_relro; case "${enableval}" in
+  yes) default_relro=yes ;;
+  no) ac_default_relro=no ;;
+  *) as_fn_error "bad value ${enableval} for default-relro option" "$LINENO" 5 ;;
+esac
+else
+  default_relro=unset
+fi
+
+
+if test "x$default_relro" = "xyes" ; then
+
+$as_echo "#define DEFAULT_RELRO 1" >>confdefs.h
+
+fi
+

 # Set the 'development' global.
 . $srcdir/../bfd/development.sh
diff --git a/ld/configure.ac b/ld/configure.ac
index 188172d..dbd6186 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -155,6 +155,19 @@ AC_ARG_ENABLE(compressed_debug_sections,
   ,no, | ,none,)  ac_default_compressed_debug_sections=no ;;
 esac])dnl

+# Decide whether you want to set "-z relro" by default
+AC_ARG_ENABLE([default-relro],
+              AS_HELP_STRING([--enable-default-relro], [mark relocations read-only by default]),
+[case "${enableval}" in
+  yes) default_relro=yes ;;
+  no) ac_default_relro=no ;;
+  *) AC_MSG_ERROR([bad value ${enableval} for default-relro option]) ;;
+esac], default_relro=unset)
+
+if test "x$default_relro" = "xyes" ; then
+  AC_DEFINE([DEFAULT_RELRO], [1], [Define if you want to use read only relocations by default])
+fi
+
 AM_BINUTILS_WARNINGS

 AM_LC_MESSAGES
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 0405d4f..d991c16 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -104,6 +104,9 @@ gld${EMULATION_NAME}_before_parse (void)
   config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
   config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
   `if test -n "$CALL_NOP_BYTE" ; then echo link_info.call_nop_byte = $CALL_NOP_BYTE; fi`;
+#ifdef DEFAULT_RELRO
+  link_info.relro = TRUE;
+#endif
 }

 EOF
diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
index 310a3b2..d74cdd3 100644
--- a/ld/testsuite/config/default.exp
+++ b/ld/testsuite/config/default.exp
@@ -21,8 +21,16 @@
 # Written by Jeffrey Wheat (cassidy@cygnus.com)
 #

+# load the utility procedures
+load_lib ld-lib.exp
+
 if ![info exists ld] then {
     set ld [findfile $base_dir/ld-new $base_dir/ld-new [transform ld]]
+
+    # Make sure tests pass even if configured with --enable-default-relro
+    if {[is_elf_format]} then {
+        append ld " -z norelro"
+    }
 }

 if ![info exists as] then {
@@ -76,6 +84,11 @@ if {[file exists tmpdir/libpath.exp]} {
     }
 }

+# Make sure tests pass even if configured with --enable-default-relro
+if {[is_elf_format]} then {
+    append ld_L_opt " -z norelro"
+}
+
 # The "make check" target in the Makefile passes in
 # "CC=$(CC_FOR_TARGET)".  But, if the user invokes runtest directly
 # (as when testing an installed linker), these flags may not be set.
@@ -108,9 +121,6 @@ if { [istarget rx-*-*] } {
     set ASFLAGS "-muse-conventional-section-names"
 }

-# load the utility procedures
-load_lib ld-lib.exp
-
 proc get_link_files {varname} {
     global $varname
     global target_triplet
@@ -277,6 +287,11 @@ if ![info exists READELFFLAGS] then {

 if ![info exists LD] then {
     set LD [findfile $base_dir/ld-new ./ld-new [transform ld]]
+
+    # Make sure tests pass even if configured with --enable-default-relro
+    if {[is_elf_format]} then {
+        append LD " -z norelro"
+    }
 }

 if ![info exists LDFLAGS] then {
diff --git a/ld/testsuite/ld-bootstrap/bootstrap.exp b/ld/testsuite/ld-bootstrap/bootstrap.exp
index 3b6eb84..749bd9a 100644
--- a/ld/testsuite/ld-bootstrap/bootstrap.exp
+++ b/ld/testsuite/ld-bootstrap/bootstrap.exp
@@ -78,7 +78,13 @@ foreach flags $test_flags {

     # This test can only be run if we have the ld build directory,
     # since we need the object files.
-    if {$ld != "$objdir/ld-new"} {
+    set ldexe $ld
+    set ldparm [string first " " $ld]
+    if { $ldparm > 0 } then {
+        set ldparm [expr $ldparm - 1]
+        set ldexe [string range $ld 0 $ldparm]
+    }
+    if {$ldexe != "$objdir/ld-new"} {
 	untested $testname
 	continue
     }

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] add a configure option for using RELRO by default
  2015-11-10 21:17 ` Romain Geissler
@ 2015-11-10 23:28   ` Mike Frysinger
  2015-11-10 23:52     ` Romain Geissler
  0 siblings, 1 reply; 21+ messages in thread
From: Mike Frysinger @ 2015-11-10 23:28 UTC (permalink / raw)
  To: Romain Geissler; +Cc: binutils, schwab, hjl.tools, danielmicay

[-- Attachment #1: Type: text/plain, Size: 910 bytes --]

On 10 Nov 2015 22:16, Romain Geissler wrote:
> --- a/gold/configure.ac
> +++ b/gold/configure.ac
>
> +# Decide whether you want to set "-z relro" by default

should be a dnl instead of a # ?

> +ac_default_relro=unset

i don't think we want the ac_ prefix since this isn't autoconf code.

would be better too imo to make this the 4th arg to AC_ARG_ENABLE below.

> +  *) AC_MSG_ERROR(bad value ${enableval} for default-relro option) ;;

should quote the arg with []

> +if test x$ac_default_relro == xyes ; then

quote the LHS and change the == to =

> +  AC_DEFINE(DEFAULT_RELRO, 1, [Define if you want to use read only relocations by default])

quote the 1st & 2nd arg with []

> +#ifdef DEFAULT_RELRO
> +#define DEFAULT_RELRO_VALUE true
> +#else
> +#define DEFAULT_RELRO_VALUE false
> +#endif

should use "# define" imo

> --- a/ld/configure.ac
> +++ b/ld/configure.ac

same feedback here as for gold
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] add a configure option for using RELRO by default
       [not found] <alpine.LNX.2.10.1509191703290.15470@ncegcolnx273.nce.amadeus.net>
@ 2015-11-10 21:17 ` Romain Geissler
  2015-11-10 23:28   ` Mike Frysinger
  0 siblings, 1 reply; 21+ messages in thread
From: Romain Geissler @ 2015-11-10 21:17 UTC (permalink / raw)
  To: Romain Geissler, binutils, schwab, vapier, hjl.tools; +Cc: danielmicay

On Sat, 19 Sep 2015, Romain Geissler wrote:

> Hi,
>
> Daniel Micay originally submitted a patch here
> https://sourceware.org/ml/binutils/2015-01/msg00165.html to allow distro
> maintainers to enable relro by default when building binutils. However
> that patch never made it into the repo, since gold patch was missing. I
> have just finished the work made by him by changing gold as well.
>
> Tested without regression both with and without the --enable-default-relro
> flag on a SLES 11 SP1 x64, for both ld and gold.
>
> Ok for the trunk ?
>
> Cheers,
> Romain

Hi,

I forgot about this patch that I never finalized. Here is version 2 with
all your comments addressed.

Cheers,
Romain

gold/ChangeLog:
2015-11-10  Romain Geissler  <romain.geissler@amadeus.com>

	* configure.ac: Add --enable-default-relro switch.
	* options.cc (General_options::finalize): Disable relro if not set
	explicitly when linking incrementally.
	* options.h (General_options): Handle DEFAULT_RELRO.
	* config.in: Regenerate.
	* configure: Regenerate.
	* Makefile.in: Regenerate.

ld/ChangeLog:
2015-11-10  Romain Geissler  <romain.geissler@amadeus.com>

	* configure.ac: Add --enable-default-relro switch.
	* emultempl/elf32.em: Handle DEFAULT_RELRO.
	* testsuite/config/default.exp: Disable RELRO.
	* testsuite/ld-bootstrap/bootstrap.exp: Disable RELRO.
	* config.in: Regenerate.
	* configure: Regenerate.

ld/testsuite/ChangeLog:
2015-11-10  Romain Geissler  <romain.geissler@amadeus.com>

	* config/default.exp (ld, LD, ld_L_opt): Append -z norelro for ELF targets.
	* ld-bootstrap/bootstrap.exp (ldexe): New.



diff --git a/gold/Makefile.in b/gold/Makefile.in
index dbfde80..d04378e 100644
--- a/gold/Makefile.in
+++ b/gold/Makefile.in
@@ -70,8 +70,8 @@ subdir = .
 DIST_COMMON = NEWS README ChangeLog $(srcdir)/Makefile.in \
 	$(srcdir)/Makefile.am $(top_srcdir)/configure \
 	$(am__configure_deps) $(srcdir)/config.in \
-	$(srcdir)/../mkinstalldirs $(top_srcdir)/po/Make-in pread.c \
-	ffsll.c ftruncate.c mremap.c yyscript.h yyscript.c \
+	$(srcdir)/../mkinstalldirs $(top_srcdir)/po/Make-in ffsll.c \
+	ftruncate.c pread.c mremap.c yyscript.h yyscript.c \
 	$(srcdir)/../depcomp $(srcdir)/../ylwrap
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
diff --git a/gold/config.in b/gold/config.in
index 88e8712..fe6190b 100644
--- a/gold/config.in
+++ b/gold/config.in
@@ -10,6 +10,9 @@
 /* Define if building universal (internal helper macro) */
 #undef AC_APPLE_UNIVERSAL_BUILD

+/* Define if you want to use read only relocations by default */
+#undef DEFAULT_RELRO
+
 /* Define to 1 if translation of program messages to the user's native
    language is requested. */
 #undef ENABLE_NLS
diff --git a/gold/configure b/gold/configure
index 987a846..58ffdaa 100755
--- a/gold/configure
+++ b/gold/configure
@@ -791,6 +791,7 @@ enable_gold
 enable_threads
 enable_plugins
 enable_targets
+enable_default_relro
 with_lib_path
 enable_dependency_tracking
 enable_nls
@@ -1440,6 +1441,7 @@ Optional Features:
   --enable-threads        multi-threaded linking
   --enable-plugins        linker plugins
   --enable-targets        alternative target configurations
+  --enable-default-relro  mark relocations read-only by default
   --disable-dependency-tracking  speeds up one-time build
   --enable-dependency-tracking   do not reject slow dependency extractors
   --disable-nls           do not use Native Language Support
@@ -3384,6 +3386,24 @@ if test -n "$enable_targets"; then
   done
 fi

+# Decide whether you want to set "-z relro" by default
+ac_default_relro=unset
+# Check whether --enable-default-relro was given.
+if test "${enable_default_relro+set}" = set; then :
+  enableval=$enable_default_relro; case "${enableval}" in
+  yes) ac_default_relro=yes ;;
+  no) ac_default_relro=no ;;
+  *) as_fn_error "bad value ${enableval} for default-relro option" "$LINENO" 5 ;;
+esac
+fi
+
+
+if test x$ac_default_relro == xyes ; then
+
+$as_echo "#define DEFAULT_RELRO 1" >>confdefs.h
+
+fi
+
 # See which specific instantiations we need.
 targetobjs=
 all_targets=
diff --git a/gold/configure.ac b/gold/configure.ac
index 89f6c53..80e761d 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -144,6 +144,20 @@ if test -n "$enable_targets"; then
   done
 fi

+# Decide whether you want to set "-z relro" by default
+ac_default_relro=unset
+AC_ARG_ENABLE([default-relro],
+              AS_HELP_STRING([--enable-default-relro], [mark relocations read-only by default]),
+[case "${enableval}" in
+  yes) ac_default_relro=yes ;;
+  no) ac_default_relro=no ;;
+  *) AC_MSG_ERROR(bad value ${enableval} for default-relro option) ;;
+esac])
+
+if test x$ac_default_relro == xyes ; then
+  AC_DEFINE(DEFAULT_RELRO, 1, [Define if you want to use read only relocations by default])
+fi
+
 # See which specific instantiations we need.
 targetobjs=
 all_targets=
diff --git a/gold/options.cc b/gold/options.cc
index c42623f..2c1994a 100644
--- a/gold/options.cc
+++ b/gold/options.cc
@@ -1279,7 +1279,12 @@ General_options::finalize()
       if (this->has_plugins())
 	gold_fatal(_("incremental linking is not compatible with --plugin"));
       if (this->relro())
-	gold_fatal(_("incremental linking is not compatible with -z relro"));
+      {
+        if (this->user_set_relro())
+          gold_fatal(_("incremental linking is not compatible with -z relro"));
+        else
+          this->set_relro(false);
+      }
       if (this->gc_sections())
 	{
 	  gold_warning(_("ignoring --gc-sections for an incremental link"));
diff --git a/gold/options.h b/gold/options.h
index ffc44e6..9de9c44 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -1332,7 +1332,12 @@ class General_options
   DEFINE_bool(origin, options::DASH_Z, '\0', false,
 	      N_("Mark DSO to indicate that needs immediate $ORIGIN "
 		 "processing at runtime"), NULL);
-  DEFINE_bool(relro, options::DASH_Z, '\0', false,
+#ifdef DEFAULT_RELRO
+#define DEFAULT_RELRO_VALUE true
+#else
+#define DEFAULT_RELRO_VALUE false
+#endif
+  DEFINE_bool(relro, options::DASH_Z, '\0', DEFAULT_RELRO_VALUE,
 	      N_("Where possible mark variables read-only after relocation"),
 	      N_("Don't mark variables read-only after relocation"));
   DEFINE_bool(text, options::DASH_Z, '\0', false,
diff --git a/ld/config.in b/ld/config.in
index 276fb77..002002c 100644
--- a/ld/config.in
+++ b/ld/config.in
@@ -10,6 +10,9 @@
 /* Define if you want compressed debug sections by default. */
 #undef DEFAULT_FLAG_COMPRESS_DEBUG

+/* Define if you want to use read only relocations by default */
+#undef DEFAULT_RELRO
+
 /* Define to 1 if translation of program messages to the user's native
    language is requested. */
 #undef ENABLE_NLS
diff --git a/ld/configure b/ld/configure
index b41efe8..a47b443 100755
--- a/ld/configure
+++ b/ld/configure
@@ -789,6 +789,7 @@ with_sysroot
 enable_gold
 enable_got
 enable_compressed_debug_sections
+enable_default_relro
 enable_werror
 enable_build_warnings
 enable_nls
@@ -1447,6 +1448,7 @@ Optional Features:
                           multigot)
   --enable-compressed-debug-sections={all,ld,none}
                           compress debug sections by default]
+  --enable-default-relro  mark relocations read-only by default
   --enable-werror         treat compile warnings as errors
   --enable-build-warnings enable build-time compiler warnings
   --disable-nls           do not use Native Language Support
@@ -11716,7 +11718,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11719 "configure"
+#line 11721 "configure"
 #include "confdefs.h"

 #if HAVE_DLFCN_H
@@ -11822,7 +11824,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11825 "configure"
+#line 11827 "configure"
 #include "confdefs.h"

 #if HAVE_DLFCN_H
@@ -15536,6 +15538,24 @@ if test "${enable_compressed_debug_sections+set}" = set; then :
 esac
 fi

+# Decide whether you want to set "-z relro" by default
+ac_default_relro=unset
+# Check whether --enable-default-relro was given.
+if test "${enable_default_relro+set}" = set; then :
+  enableval=$enable_default_relro; case "${enableval}" in
+  yes) ac_default_relro=yes ;;
+  no) ac_default_relro=no ;;
+  *) as_fn_error "bad value ${enableval} for default-relro option" "$LINENO" 5 ;;
+esac
+fi
+
+
+if test x$ac_default_relro == xyes ; then
+
+$as_echo "#define DEFAULT_RELRO 1" >>confdefs.h
+
+fi
+

 # Set the 'development' global.
 . $srcdir/../bfd/development.sh
diff --git a/ld/configure.ac b/ld/configure.ac
index 188172d..386e6f8 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -155,6 +155,20 @@ AC_ARG_ENABLE(compressed_debug_sections,
   ,no, | ,none,)  ac_default_compressed_debug_sections=no ;;
 esac])dnl

+# Decide whether you want to set "-z relro" by default
+ac_default_relro=unset
+AC_ARG_ENABLE([default-relro],
+              AS_HELP_STRING([--enable-default-relro], [mark relocations read-only by default]),
+[case "${enableval}" in
+  yes) ac_default_relro=yes ;;
+  no) ac_default_relro=no ;;
+  *) AC_MSG_ERROR(bad value ${enableval} for default-relro option) ;;
+esac])
+
+if test x$ac_default_relro == xyes ; then
+  AC_DEFINE(DEFAULT_RELRO, 1, [Define if you want to use read only relocations by default])
+fi
+
 AM_BINUTILS_WARNINGS

 AM_LC_MESSAGES
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 0405d4f..d991c16 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -104,6 +104,9 @@ gld${EMULATION_NAME}_before_parse (void)
   config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
   config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
   `if test -n "$CALL_NOP_BYTE" ; then echo link_info.call_nop_byte = $CALL_NOP_BYTE; fi`;
+#ifdef DEFAULT_RELRO
+  link_info.relro = TRUE;
+#endif
 }

 EOF
diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
index 310a3b2..d74cdd3 100644
--- a/ld/testsuite/config/default.exp
+++ b/ld/testsuite/config/default.exp
@@ -21,8 +21,16 @@
 # Written by Jeffrey Wheat (cassidy@cygnus.com)
 #

+# load the utility procedures
+load_lib ld-lib.exp
+
 if ![info exists ld] then {
     set ld [findfile $base_dir/ld-new $base_dir/ld-new [transform ld]]
+
+    # Make sure tests pass even if configured with --enable-default-relro
+    if {[is_elf_format]} then {
+        append ld " -z norelro"
+    }
 }

 if ![info exists as] then {
@@ -76,6 +84,11 @@ if {[file exists tmpdir/libpath.exp]} {
     }
 }

+# Make sure tests pass even if configured with --enable-default-relro
+if {[is_elf_format]} then {
+    append ld_L_opt " -z norelro"
+}
+
 # The "make check" target in the Makefile passes in
 # "CC=$(CC_FOR_TARGET)".  But, if the user invokes runtest directly
 # (as when testing an installed linker), these flags may not be set.
@@ -108,9 +121,6 @@ if { [istarget rx-*-*] } {
     set ASFLAGS "-muse-conventional-section-names"
 }

-# load the utility procedures
-load_lib ld-lib.exp
-
 proc get_link_files {varname} {
     global $varname
     global target_triplet
@@ -277,6 +287,11 @@ if ![info exists READELFFLAGS] then {

 if ![info exists LD] then {
     set LD [findfile $base_dir/ld-new ./ld-new [transform ld]]
+
+    # Make sure tests pass even if configured with --enable-default-relro
+    if {[is_elf_format]} then {
+        append LD " -z norelro"
+    }
 }

 if ![info exists LDFLAGS] then {
diff --git a/ld/testsuite/ld-bootstrap/bootstrap.exp b/ld/testsuite/ld-bootstrap/bootstrap.exp
index 3b6eb84..749bd9a 100644
--- a/ld/testsuite/ld-bootstrap/bootstrap.exp
+++ b/ld/testsuite/ld-bootstrap/bootstrap.exp
@@ -78,7 +78,13 @@ foreach flags $test_flags {

     # This test can only be run if we have the ld build directory,
     # since we need the object files.
-    if {$ld != "$objdir/ld-new"} {
+    set ldexe $ld
+    set ldparm [string first " " $ld]
+    if { $ldparm > 0 } then {
+        set ldparm [expr $ldparm - 1]
+        set ldexe [string range $ld 0 $ldparm]
+    }
+    if {$ldexe != "$objdir/ld-new"} {
 	untested $testname
 	continue
     }
-- 
2.3.0

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] add a configure option for using RELRO by default
  2015-09-19 15:11 Romain Geissler
                   ` (2 preceding siblings ...)
  2015-09-29  4:00 ` Mike Frysinger
@ 2015-09-29  7:49 ` Andreas Schwab
  3 siblings, 0 replies; 21+ messages in thread
From: Andreas Schwab @ 2015-09-29  7:49 UTC (permalink / raw)
  To: Romain Geissler; +Cc: binutils, danielmicay

Romain Geissler <romain.geissler@amadeus.com> writes:

> diff --git a/gold/options.h b/gold/options.h
> index 641efee..228c527 100644
> --- a/gold/options.h
> +++ b/gold/options.h
> @@ -1327,7 +1327,12 @@ class General_options
>    DEFINE_bool(origin, options::DASH_Z, '\0', false,
>  	      N_("Mark DSO to indicate that needs immediate $ORIGIN "
>  		 "processing at runtime"), NULL);
> -  DEFINE_bool(relro, options::DASH_Z, '\0', false,
> +  DEFINE_bool(relro, options::DASH_Z, '\0',
> +#ifdef ENABLE_DEFAULT_RELRO
> +              true,
> +#else
> +              false,
> +#endif

You cannot use preprocessing directives inside macro arguments.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] add a configure option for using RELRO by default
  2015-09-19 15:11 Romain Geissler
  2015-09-28 19:53 ` Romain Geissler
  2015-09-28 22:49 ` H.J. Lu
@ 2015-09-29  4:00 ` Mike Frysinger
  2015-09-29  7:49 ` Andreas Schwab
  3 siblings, 0 replies; 21+ messages in thread
From: Mike Frysinger @ 2015-09-29  4:00 UTC (permalink / raw)
  To: Romain Geissler; +Cc: binutils, danielmicay

[-- Attachment #1: Type: text/plain, Size: 884 bytes --]

On 19 Sep 2015 17:11, Romain Geissler wrote:
> --- a/gold/configure.ac
> +++ b/gold/configure.ac
>
> +AC_ARG_ENABLE(default-relro,
> +              [  --enable-default-relro       mark relocations read-only by default],

please use AS_HELP_STRING instead

> +[
> +  AC_DEFINE([ENABLE_DEFAULT_RELRO], [ ],
> +            [Define to mark relocations read-only by default.])
> +], [])

this is wrong for two reasons:
(1) you must check $enableval and change behavior based on that
(2) you should define it to a value like 1

you should also just omit the 4th arg

> --- a/ld/configure.ac
> +++ b/ld/configure.ac
>
> +AC_ARG_ENABLE(default-relro,
> +              [  --enable-default-relro       mark relocations read-only by default],
> +[
> +  AC_DEFINE([ENABLE_DEFAULT_RELRO], [ ],
> +            [Define to mark relocations read-only by default.])
> +], [])

same feedback here
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] add a configure option for using RELRO by default
  2015-09-19 15:11 Romain Geissler
  2015-09-28 19:53 ` Romain Geissler
@ 2015-09-28 22:49 ` H.J. Lu
  2015-09-29  4:00 ` Mike Frysinger
  2015-09-29  7:49 ` Andreas Schwab
  3 siblings, 0 replies; 21+ messages in thread
From: H.J. Lu @ 2015-09-28 22:49 UTC (permalink / raw)
  To: Romain Geissler; +Cc: Binutils, danielmicay

On Sat, Sep 19, 2015 at 8:11 AM, Romain Geissler
<romain.geissler@amadeus.com> wrote:
> Hi,
>
> Daniel Micay originally submitted a patch here
> https://sourceware.org/ml/binutils/2015-01/msg00165.html to allow distro
> maintainers to enable relro by default when building binutils. However
> that patch never made it into the repo, since gold patch was missing. I
> have just finished the work made by him by changing gold as well.
>
> Tested without regression both with and without the --enable-default-relro
> flag on a SLES 11 SP1 x64, for both ld and gold.
>
> Ok for the trunk ?
>
> Cheers,
> Romain
>
> 2015-09-18  Romain Geissler  <romain.geissler@amadeus.com>
>
>         * ld/configure.ac: Add --enable-default-relro switch.
>         * ld/emultempl/elf32.em: Handle ENABLE_DEFAULT_RELRO.
>         * ld/testsuite/config/default.exp: Disable RELRO.
>         * ld/testsuite/ld-bootstrap/bootstrap.exp: Disable RELRO.
>         * ld/config.in: Regenerate.
>         * ld/configure: Regenerate.
>         * gold/configure.ac: Add --enable-default-relro switch.
>         * gold/options.cc (General_options::finalize): Disable relro if not set
>         explicitly when linking incrementally.
>         * gold/options.h (General_options): Handle ENABLE_DEFAULT_RELRO.
>         * gold/config.in: Regenerate.
>         * gold/configure: Regenerate.
>         * gold/Makefile.in: Regenerate.
>
> ---
>  gold/ChangeLog                          | 10 ++++++++++
>  gold/Makefile.in                        |  4 ++--
>  gold/config.in                          |  3 +++
>  gold/configure                          | 12 ++++++++++++
>  gold/configure.ac                       |  7 +++++++
>  gold/options.cc                         |  7 ++++++-
>  gold/options.h                          |  7 ++++++-
>  ld/ChangeLog                            |  9 +++++++++
>  ld/config.in                            |  3 +++
>  ld/configure                            | 16 ++++++++++++++--
>  ld/configure.ac                         |  7 +++++++
>  ld/emultempl/elf32.em                   |  3 +++
>  ld/testsuite/config/default.exp         |  6 +++---
>  ld/testsuite/ld-bootstrap/bootstrap.exp |  8 +++++++-
>  14 files changed, 92 insertions(+), 10 deletions(-)
>


>  EOF
> diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
> index 5b3e29f..5c56b5b 100644
> --- a/ld/testsuite/config/default.exp
> +++ b/ld/testsuite/config/default.exp
> @@ -22,7 +22,7 @@
>  #
>
>  if ![info exists ld] then {
> -    set ld [findfile $base_dir/ld-new $base_dir/ld-new [transform ld]]
> +    set ld "[findfile $base_dir/ld-new $base_dir/ld-new [transform ld]] -znorelro"
>  }
>
>  if ![info exists as] then {
> @@ -60,7 +60,7 @@ if {![file isdirectory tmpdir/ld]} then {
>      catch "exec ln -s ld tmpdir/ld/collect-ld" status
>      catch "exec ln -s ../../../gas/as-new tmpdir/ld/as" status
>  }
> -set gcc_B_opt "-B[pwd]/tmpdir/ld/"
> +set gcc_B_opt "-B[pwd]/tmpdir/ld/ -Wl,-z,norelro"
>
>  # load the linker path
>  set ld_L_opt ""
> @@ -272,7 +272,7 @@ if ![info exists READELFFLAGS] then {
>  }
>
>  if ![info exists LD] then {
> -    set LD [findfile $base_dir/ld-new ./ld-new [transform ld]]
> +    set LD "[findfile $base_dir/ld-new ./ld-new [transform ld]] -znorelro"
>  }
>
>  if ![info exists LDFLAGS] then {
> diff --git a/ld/testsuite/ld-bootstrap/bootstrap.exp b/ld/testsuite/ld-bootstrap/bootstrap.exp
> index 3b6eb84..2a7ac8f 100644
> --- a/ld/testsuite/ld-bootstrap/bootstrap.exp
> +++ b/ld/testsuite/ld-bootstrap/bootstrap.exp
> @@ -78,7 +78,13 @@ foreach flags $test_flags {
>
>      # This test can only be run if we have the ld build directory,
>      # since we need the object files.
> -    if {$ld != "$objdir/ld-new"} {
> +    set ldexe $ld
> +    set ldparm [string first " " $ld]
> +    if { $ldparm > 0 } then {
> +   set ldparm [expr $ldparm - 1]
> +   set ldexe [string range $ld 0 $ldparm]
> +    }
> +    if {$ldexe != "$objdir/ld-new"} {
>         untested $testname
>         continue
>      }
> --
> 2.3.0
>

You can't do this way since not all linkers allow -z relro.


-- 
H.J.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] add a configure option for using RELRO by default
  2015-09-19 15:11 Romain Geissler
@ 2015-09-28 19:53 ` Romain Geissler
  2015-09-28 22:49 ` H.J. Lu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 21+ messages in thread
From: Romain Geissler @ 2015-09-28 19:53 UTC (permalink / raw)
  To: Romain Geissler; +Cc: binutils, danielmicay

On Sat, 19 Sep 2015, Romain Geissler wrote:

> Hi,
>
> Daniel Micay originally submitted a patch here
> https://sourceware.org/ml/binutils/2015-01/msg00165.html to allow distro
> maintainers to enable relro by default when building binutils. However
> that patch never made it into the repo, since gold patch was missing. I
> have just finished the work made by him by changing gold as well.
>
> Tested without regression both with and without the --enable-default-relro
> flag on a SLES 11 SP1 x64, for both ld and gold.
>
> Ok for the trunk ?
>
> Cheers,
> Romain

Ping
https://sourceware.org/ml/binutils/2015-09/msg00222.html

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH] add a configure option for using RELRO by default
@ 2015-09-19 15:11 Romain Geissler
  2015-09-28 19:53 ` Romain Geissler
                   ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: Romain Geissler @ 2015-09-19 15:11 UTC (permalink / raw)
  To: binutils; +Cc: danielmicay, romain.geissler

Hi,

Daniel Micay originally submitted a patch here
https://sourceware.org/ml/binutils/2015-01/msg00165.html to allow distro
maintainers to enable relro by default when building binutils. However
that patch never made it into the repo, since gold patch was missing. I
have just finished the work made by him by changing gold as well.

Tested without regression both with and without the --enable-default-relro
flag on a SLES 11 SP1 x64, for both ld and gold.

Ok for the trunk ?

Cheers,
Romain

2015-09-18  Romain Geissler  <romain.geissler@amadeus.com>

	* ld/configure.ac: Add --enable-default-relro switch.
	* ld/emultempl/elf32.em: Handle ENABLE_DEFAULT_RELRO.
	* ld/testsuite/config/default.exp: Disable RELRO.
	* ld/testsuite/ld-bootstrap/bootstrap.exp: Disable RELRO.
	* ld/config.in: Regenerate.
	* ld/configure: Regenerate.
	* gold/configure.ac: Add --enable-default-relro switch.
	* gold/options.cc (General_options::finalize): Disable relro if not set
	explicitly when linking incrementally.
	* gold/options.h (General_options): Handle ENABLE_DEFAULT_RELRO.
	* gold/config.in: Regenerate.
	* gold/configure: Regenerate.
	* gold/Makefile.in: Regenerate.

---
 gold/ChangeLog                          | 10 ++++++++++
 gold/Makefile.in                        |  4 ++--
 gold/config.in                          |  3 +++
 gold/configure                          | 12 ++++++++++++
 gold/configure.ac                       |  7 +++++++
 gold/options.cc                         |  7 ++++++-
 gold/options.h                          |  7 ++++++-
 ld/ChangeLog                            |  9 +++++++++
 ld/config.in                            |  3 +++
 ld/configure                            | 16 ++++++++++++++--
 ld/configure.ac                         |  7 +++++++
 ld/emultempl/elf32.em                   |  3 +++
 ld/testsuite/config/default.exp         |  6 +++---
 ld/testsuite/ld-bootstrap/bootstrap.exp |  8 +++++++-
 14 files changed, 92 insertions(+), 10 deletions(-)

diff --git a/gold/ChangeLog b/gold/ChangeLog
index 49ce2fe..eb1791b 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,13 @@
+2015-09-18  Romain Geissler  <romain.geissler@amadeus.com>
+
+	* configure.ac: Add --enable-default-relro switch.
+	* options.cc (General_options::finalize): Disable relro if not set
+	explicitly when linking incrementally.
+	* options.h (General_options): Handle ENABLE_DEFAULT_RELRO.
+	* config.in: Regenerate.
+	* configure: Regenerate.
+	* Makefile.in: Regenerate.
+
 2015-09-07  Cary Coutant  <ccoutant@gmail.com>

 	PR gold/18930
diff --git a/gold/Makefile.in b/gold/Makefile.in
index 8a23524..9bc1de7 100644
--- a/gold/Makefile.in
+++ b/gold/Makefile.in
@@ -70,8 +70,8 @@ subdir = .
 DIST_COMMON = NEWS README ChangeLog $(srcdir)/Makefile.in \
 	$(srcdir)/Makefile.am $(top_srcdir)/configure \
 	$(am__configure_deps) $(srcdir)/config.in \
-	$(srcdir)/../mkinstalldirs $(top_srcdir)/po/Make-in mremap.c \
-	pread.c ffsll.c ftruncate.c yyscript.h yyscript.c \
+	$(srcdir)/../mkinstalldirs $(top_srcdir)/po/Make-in ffsll.c \
+	ftruncate.c pread.c mremap.c yyscript.h yyscript.c \
 	$(srcdir)/../depcomp $(srcdir)/../ylwrap
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
diff --git a/gold/config.in b/gold/config.in
index 88e8712..aecc9ac 100644
--- a/gold/config.in
+++ b/gold/config.in
@@ -10,6 +10,9 @@
 /* Define if building universal (internal helper macro) */
 #undef AC_APPLE_UNIVERSAL_BUILD

+/* Define to mark relocations read-only by default. */
+#undef ENABLE_DEFAULT_RELRO
+
 /* Define to 1 if translation of program messages to the user's native
    language is requested. */
 #undef ENABLE_NLS
diff --git a/gold/configure b/gold/configure
index eac9669..51b57b6e 100755
--- a/gold/configure
+++ b/gold/configure
@@ -789,6 +789,7 @@ enable_gold
 enable_threads
 enable_plugins
 enable_targets
+enable_default_relro
 with_lib_path
 enable_dependency_tracking
 enable_nls
@@ -1438,6 +1439,7 @@ Optional Features:
   --enable-threads        multi-threaded linking
   --enable-plugins        linker plugins
   --enable-targets        alternative target configurations
+  --enable-default-relro       mark relocations read-only by default
   --disable-dependency-tracking  speeds up one-time build
   --enable-dependency-tracking   do not reject slow dependency extractors
   --disable-nls           do not use Native Language Support
@@ -3382,6 +3384,16 @@ if test -n "$enable_targets"; then
   done
 fi

+# Check whether --enable-default-relro was given.
+if test "${enable_default_relro+set}" = set; then :
+  enableval=$enable_default_relro;
+
+$as_echo "#define ENABLE_DEFAULT_RELRO  " >>confdefs.h
+
+
+fi
+
+
 # See which specific instantiations we need.
 targetobjs=
 all_targets=
diff --git a/gold/configure.ac b/gold/configure.ac
index 94cae31..913f5d3 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -144,6 +144,13 @@ if test -n "$enable_targets"; then
   done
 fi

+AC_ARG_ENABLE(default-relro,
+              [  --enable-default-relro       mark relocations read-only by default],
+[
+  AC_DEFINE([ENABLE_DEFAULT_RELRO], [ ],
+            [Define to mark relocations read-only by default.])
+], [])
+
 # See which specific instantiations we need.
 targetobjs=
 all_targets=
diff --git a/gold/options.cc b/gold/options.cc
index c42623f..2c1994a 100644
--- a/gold/options.cc
+++ b/gold/options.cc
@@ -1279,7 +1279,12 @@ General_options::finalize()
       if (this->has_plugins())
 	gold_fatal(_("incremental linking is not compatible with --plugin"));
       if (this->relro())
-	gold_fatal(_("incremental linking is not compatible with -z relro"));
+      {
+        if (this->user_set_relro())
+          gold_fatal(_("incremental linking is not compatible with -z relro"));
+        else
+          this->set_relro(false);
+      }
       if (this->gc_sections())
 	{
 	  gold_warning(_("ignoring --gc-sections for an incremental link"));
diff --git a/gold/options.h b/gold/options.h
index 641efee..228c527 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -1327,7 +1327,12 @@ class General_options
   DEFINE_bool(origin, options::DASH_Z, '\0', false,
 	      N_("Mark DSO to indicate that needs immediate $ORIGIN "
 		 "processing at runtime"), NULL);
-  DEFINE_bool(relro, options::DASH_Z, '\0', false,
+  DEFINE_bool(relro, options::DASH_Z, '\0',
+#ifdef ENABLE_DEFAULT_RELRO
+              true,
+#else
+              false,
+#endif
 	      N_("Where possible mark variables read-only after relocation"),
 	      N_("Don't mark variables read-only after relocation"));
   DEFINE_bool(text, options::DASH_Z, '\0', false,
diff --git a/ld/ChangeLog b/ld/ChangeLog
index e73abeb..b3a9350 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,12 @@
+2015-09-18  Romain Geissler  <romain.geissler@amadeus.com>
+
+	* configure.ac: Add --enable-default-relro switch.
+	* emultempl/elf32.em: Handle ENABLE_DEFAULT_RELRO.
+	* testsuite/config/default.exp: Disable RELRO.
+	* testsuite/ld-bootstrap/bootstrap.exp: Disable RELRO.
+	* config.in: Regenerate.
+	* configure: Regenerate.
+
 2015-09-18  Alan Modra  <amodra@gmail.com>

 	* ld.texinfo: Document PowerPC64 --{no-,}save-restore-funcs.
diff --git a/ld/config.in b/ld/config.in
index a9a37e0..541d75e 100644
--- a/ld/config.in
+++ b/ld/config.in
@@ -7,6 +7,9 @@
 #endif
 #define __CONFIG_H__ 1

+/* Define to mark relocations read-only by default. */
+#undef ENABLE_DEFAULT_RELRO
+
 /* Define to 1 if translation of program messages to the user's native
    language is requested. */
 #undef ENABLE_NLS
diff --git a/ld/configure b/ld/configure
index 1249852..ab426ca 100755
--- a/ld/configure
+++ b/ld/configure
@@ -788,6 +788,7 @@ enable_64_bit_bfd
 with_sysroot
 enable_gold
 enable_got
+enable_default_relro
 enable_werror
 enable_build_warnings
 enable_nls
@@ -1444,6 +1445,7 @@ Optional Features:
   --enable-gold[=ARG]     build gold [ARG={default,yes,no}]
   --enable-got=<type>     GOT handling scheme (target, single, negative,
                           multigot)
+  --enable-default-relro       mark relocations read-only by default
   --enable-werror         treat compile warnings as errors
   --enable-build-warnings enable build-time compiler warnings
   --disable-nls           do not use Native Language Support
@@ -11713,7 +11715,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11716 "configure"
+#line 11718 "configure"
 #include "confdefs.h"

 #if HAVE_DLFCN_H
@@ -11819,7 +11821,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11822 "configure"
+#line 11824 "configure"
 #include "confdefs.h"

 #if HAVE_DLFCN_H
@@ -15521,6 +15523,16 @@ $as_echo "#define GOT_HANDLING_DEFAULT GOT_HANDLING_MULTIGOT" >>confdefs.h
   *)  as_fn_error "bad value ${got_handling} for --enable-got option" "$LINENO" 5 ;;
 esac

+# Check whether --enable-default-relro was given.
+if test "${enable_default_relro+set}" = set; then :
+  enableval=$enable_default_relro;
+
+$as_echo "#define ENABLE_DEFAULT_RELRO  " >>confdefs.h
+
+
+fi
+
+

 # Set the 'development' global.
 . $srcdir/../bfd/development.sh
diff --git a/ld/configure.ac b/ld/configure.ac
index e1d2c81..4715aea 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -143,6 +143,13 @@ case "${got_handling}" in
   *)  AC_MSG_ERROR(bad value ${got_handling} for --enable-got option) ;;
 esac

+AC_ARG_ENABLE(default-relro,
+              [  --enable-default-relro       mark relocations read-only by default],
+[
+  AC_DEFINE([ENABLE_DEFAULT_RELRO], [ ],
+            [Define to mark relocations read-only by default.])
+], [])
+
 AM_BINUTILS_WARNINGS

 AM_LC_MESSAGES
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 7fe9089..dbf6a0b 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -102,6 +102,9 @@ gld${EMULATION_NAME}_before_parse (void)
   input_flags.dynamic = ${DYNAMIC_LINK-TRUE};
   config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
   config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
+#ifdef ENABLE_DEFAULT_RELRO
+  link_info.relro = TRUE;
+#endif
 }

 EOF
diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
index 5b3e29f..5c56b5b 100644
--- a/ld/testsuite/config/default.exp
+++ b/ld/testsuite/config/default.exp
@@ -22,7 +22,7 @@
 #

 if ![info exists ld] then {
-    set ld [findfile $base_dir/ld-new $base_dir/ld-new [transform ld]]
+    set ld "[findfile $base_dir/ld-new $base_dir/ld-new [transform ld]] -znorelro"
 }

 if ![info exists as] then {
@@ -60,7 +60,7 @@ if {![file isdirectory tmpdir/ld]} then {
     catch "exec ln -s ld tmpdir/ld/collect-ld" status
     catch "exec ln -s ../../../gas/as-new tmpdir/ld/as" status
 }
-set gcc_B_opt "-B[pwd]/tmpdir/ld/"
+set gcc_B_opt "-B[pwd]/tmpdir/ld/ -Wl,-z,norelro"

 # load the linker path
 set ld_L_opt ""
@@ -272,7 +272,7 @@ if ![info exists READELFFLAGS] then {
 }

 if ![info exists LD] then {
-    set LD [findfile $base_dir/ld-new ./ld-new [transform ld]]
+    set LD "[findfile $base_dir/ld-new ./ld-new [transform ld]] -znorelro"
 }

 if ![info exists LDFLAGS] then {
diff --git a/ld/testsuite/ld-bootstrap/bootstrap.exp b/ld/testsuite/ld-bootstrap/bootstrap.exp
index 3b6eb84..2a7ac8f 100644
--- a/ld/testsuite/ld-bootstrap/bootstrap.exp
+++ b/ld/testsuite/ld-bootstrap/bootstrap.exp
@@ -78,7 +78,13 @@ foreach flags $test_flags {

     # This test can only be run if we have the ld build directory,
     # since we need the object files.
-    if {$ld != "$objdir/ld-new"} {
+    set ldexe $ld
+    set ldparm [string first " " $ld]
+    if { $ldparm > 0 } then {
+   set ldparm [expr $ldparm - 1]
+   set ldexe [string range $ld 0 $ldparm]
+    }
+    if {$ldexe != "$objdir/ld-new"} {
 	untested $testname
 	continue
     }
-- 
2.3.0

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2015-11-24  9:56 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-14 15:22 [PATCH] add a configure option for using RELRO by default Daniel Micay
2015-02-27 19:36 ` Nicholas Clifton
2015-02-27 19:42 ` Matthias Klose
2015-02-27 23:30   ` Daniel Micay
2015-09-19 15:11 Romain Geissler
2015-09-28 19:53 ` Romain Geissler
2015-09-28 22:49 ` H.J. Lu
2015-09-29  4:00 ` Mike Frysinger
2015-09-29  7:49 ` Andreas Schwab
     [not found] <alpine.LNX.2.10.1509191703290.15470@ncegcolnx273.nce.amadeus.net>
2015-11-10 21:17 ` Romain Geissler
2015-11-10 23:28   ` Mike Frysinger
2015-11-10 23:52     ` Romain Geissler
2015-11-11  1:24       ` Mike Frysinger
     [not found]         ` <alpine.LNX.2.10.1511110256280.26881@ncegcolnx273.nce.amadeus.net>
2015-11-11  2:10           ` Romain Geissler
2015-11-20 14:34             ` Nick Clifton
2015-11-24  9:20               ` Romain Geissler
2015-11-24  9:56                 ` Nick Clifton
2015-11-11  4:48           ` Mike Frysinger
2015-11-11  5:10             ` Daniel Micay
2015-11-11  7:50               ` Mike Frysinger
2015-11-11  7:58                 ` Daniel Micay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).