This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Support PIE on Solaris 12
- From: Rainer Orth <ro at CeBiTec dot Uni-Bielefeld dot DE>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Thu, 03 Sep 2015 10:58:07 +0200
- Subject: Re: Support PIE on Solaris 12
- Authentication-results: sourceware.org; auth=none
- References: <yddd1yb7fgm dot fsf at lokon dot CeBiTec dot Uni-Bielefeld dot DE> <CAMe9rOr8Y059NZ2D2uP2TLwyipzBrWDrNRtTDP7eqnYZKQdi7A at mail dot gmail dot com> <ydd1teijqjb dot fsf at lokon dot CeBiTec dot Uni-Bielefeld dot DE> <CAMe9rOrHK7vmy43j4+eoFjB4e_N89f_3oZXGTTAdGoLTOomTgA at mail dot gmail dot com> <ydd4mjdgpho dot fsf at lokon dot CeBiTec dot Uni-Bielefeld dot DE> <CAMe9rOobyNz1sdyuzvzT+4MFZ2fJUV3=2_HEKOdvmv7q=wRkVQ at mail dot gmail dot com> <yddwpw9f3ux dot fsf at lokon dot CeBiTec dot Uni-Bielefeld dot DE> <CAMe9rOqaBNpPtvp3Ppfk-OpzzWoj_m0M17vMEvwdrFVTo3=sAA at mail dot gmail dot com>
"H.J. Lu" <hjl.tools@gmail.com> writes:
> On Wed, Sep 2, 2015 at 4:38 AM, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
>> "H.J. Lu" <hjl.tools@gmail.com> writes:
>>
>>>> 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.
>>>
>>> Should we set DF_1_PIE for Linux?
>>
>> That's nothing I can decide ;-) It's mostly informational on Solaris,
>> so I guess there's no harm doing it on Linux, too.
>>
>> Rainer
>
> We should.
That certainly massively simplifies that patch ;-) The following
(resending only the ld part for now) has been very lightly tested by
checking that DF_1_PIE is set in a Solaris 12 gcc build with gas/gld
configured with --enable-default-pie.
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.
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 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