This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Support PIE on Solaris 12


"H.J. Lu" <hjl.tools@gmail.com> writes:

> On Mon, Sep 21, 2015 at 6:46 AM, Rainer Orth
> <ro@cebitec.uni-bielefeld.de> wrote:
>> "H.J. Lu" <hjl.tools@gmail.com> writes:
>>
>>> On Thu, Sep 10, 2015 at 4:40 AM, Rainer Orth
>>> <ro@cebitec.uni-bielefeld.de> wrote:
>>>> Alan Modra <amodra@gmail.com> writes:
>>>>
>>>>> On Wed, Sep 02, 2015 at 11:05:55AM +0200, Rainer Orth wrote:
>>>>>> 2015-08-25  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
>>>>>>
>>>>>>      ld:
>>>>>>      * emulparams/solaris2.sh (GENERATE_PIE_SCRIPT): Set to yes.
>>>>>>
>>>>>>      * emultempl/elf32.em (ld_${EMULATION_NAME}_emulation): Allow
>>>>>>      overriding gld${EMULATION_NAME}_handle_option.
>>>>>>      * emultempl/solaris2.em: Include ldlex.h.
>>>>>>      (gld${EMULATION_NAME}_handle_option): Declare.
>>>>>>      (elf_solaris2_handle_option): New function.
>>>>>>      (LDEMUL_HANDLE_OPTION): Uset it.
>>>>>>
>>>>>>      include/elf:
>>>>>>      * common.h (DF_1_STUB, DF_1_PIE): Define.
>>>>>>
>>>>>>      binutils:
>>>>>>      * readelf.c (process_dynamic_section): Handle DF_1_STUB, DF_1_PIE.
>>>>>
>>>>> OK.
>>>>
>>>> How should we proceed with this patch?  Keep setting DF_1_PIE
>>>> Solaris-specific as in the version above you've already approved or set
>>>> it everywhere as HJ suggested, using the ld part from
>>>>
>>>>         https://sourceware.org/ml/binutils/2015-09/msg00035.html
>>>>
>>>> instead.
>>>
>>> We have set bits in DT_FLAGS_1 which ld supports.  I don't see
>>> DF_1_PIE is special.
>>
>> It's been more than a week since this mail: can I have either approval
>> or rejection for generically setting DF_1_PIE so I can install either
>> version of the patch?
>>
>
> Please just set DF_1_PIE unconditionally for PIE.

Here's what I've installed.

Thanks.
        Rainer


2015-09-03  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	ld:
	* emulparams/solaris2.sh (GENERATE_PIE_SCRIPT): Set to yes.

	* emultempl/elf32.em: Include ldlex.h.
	(gld${EMULATION_NAME}_handle_option) [GENERATE_PIE_SCRIPT]
	<OPTION_PIE>: Set DF_1_PIE.

	include/elf:
	* common.h (DF_1_STUB, DF_1_PIE): Define.

	binutils:
	* readelf.c (process_dynamic_section): Handle DF_1_STUB, DF_1_PIE.

# HG changeset patch
# Parent a5cee57d6f429ca6dc2f929bc07a9ea8e6686d71
# Parent  a5cee57d6f429ca6dc2f929bc07a9ea8e6686d71
Solaris 12+ PIE support

diff --git a/binutils/readelf.c b/binutils/readelf.c
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -9234,6 +9234,16 @@ process_dynamic_section (FILE * file)
 		      printf (" SINGLETON");
 		      val ^= DF_1_SINGLETON;
 		    }
+		  if (val & DF_1_STUB)
+		    {
+		      printf (" STUB");
+		      val ^= DF_1_STUB;
+		    }
+		  if (val & DF_1_PIE)
+		    {
+		      printf (" PIE");
+		      val ^= DF_1_PIE;
+		    }
 		  if (val != 0)
 		    printf (" %lx", val);
 		  puts ("");
diff --git a/include/elf/common.h b/include/elf/common.h
--- a/include/elf/common.h
+++ b/include/elf/common.h
@@ -867,6 +867,8 @@
 #define	DF_1_SYMINTPOSE	0x00800000
 #define	DF_1_GLOBAUDIT	0x01000000
 #define	DF_1_SINGLETON	0x02000000
+#define	DF_1_STUB	0x04000000
+#define	DF_1_PIE	0x08000000
 
 /* Flag values for the DT_FLAGS entry.	*/
 #define DF_ORIGIN	(1 << 0)
diff --git a/ld/emulparams/solaris2.sh b/ld/emulparams/solaris2.sh
--- a/ld/emulparams/solaris2.sh
+++ b/ld/emulparams/solaris2.sh
@@ -8,3 +8,5 @@
 # File, p.63.
 TEXT_START_SYMBOLS='_START_ = .;'
 OTHER_END_SYMBOLS='_END_ = .;'
+# Beginning with Solaris 11.x and Solaris 12, there's PIE support.
+GENERATE_PIE_SCRIPT=yes
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -49,6 +49,7 @@ fragment <<EOF
 #include "ldmain.h"
 #include "ldmisc.h"
 #include "ldexp.h"
+#include "ldlex.h"
 #include "ldlang.h"
 #include "ldfile.h"
 #include "ldemul.h"
@@ -2285,6 +2286,13 @@ fragment <<EOF
 
 EOF
 fi
+if test x"$GENERATE_PIE_SCRIPT" = xyes; then
+fragment <<EOF
+    case OPTION_PIE:
+      link_info.flags_1 |= (bfd_vma) DF_1_PIE;
+      break;
+EOF
+fi
 fragment <<EOF
     case 'z':
       if (strcmp (optarg, "defs") == 0)
-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]