Solaris PIE support
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Tue, 22 Sep 2015 09:12:51 +0000 (11:12 +0200)
committerRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Tue, 22 Sep 2015 09:12:51 +0000 (11:12 +0200)
include/elf:
* common.h (DF_1_STUB, DF_1_PIE): Define.

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.

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

binutils/ChangeLog
binutils/readelf.c
include/elf/ChangeLog
include/elf/common.h
ld/ChangeLog
ld/emulparams/solaris2.sh
ld/emultempl/elf32.em

index 1e1ccd4b0f5124cbf1a8433751f62c41cd251478..13f216652b683f90c887fa28ac1951f7b6c370a8 100644 (file)
@@ -1,3 +1,7 @@
+2015-09-22  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+       * readelf.c (process_dynamic_section): Handle DF_1_STUB, DF_1_PIE.
+
 2015-09-10  Erik Ackermann  <kurterikackermann@gmail.com>
 
        * strings.c: Add -s/--output-separator option to specify custom
index 12fb415eee77db6ff8ec012047bc378336ea41d6..4d19e6fb1376c0294ce8370ca9ddd500eff2eea1 100644 (file)
@@ -9241,6 +9241,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 ("");
index 47d6bad017e9c52327001104f8589429fae4ce30..8e6bb445becd598e77bbb5d68498ec62d2382deb 100644 (file)
@@ -1,3 +1,7 @@
+2015-09-22  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+       * common.h (DF_1_STUB, DF_1_PIE): Define.
+
 2015-09-21  H.J. Lu  <hongjiu.lu@intel.com>
 
        * external.h (Elf64_External_Chdr): Change ch_type to 4 bytes
index e6d8c14d3a2d94a0aec76a8a1d6095dfe03c5344..fbf1f3c02fa5be72fecbcf169c4cd26dbfd2cdc3 100644 (file)
 #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)
index a5f1cd793a4fea4d22fa86637a4d8312ee530a7c..88a46c5fce5f4bc15341de0ab9cd75d22d9d2c62 100644 (file)
@@ -1,3 +1,11 @@
+2015-09-22  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+       * 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.
+
 2015-09-22  Alan Modra  <amodra@gmail.com>
 
        * ld.texinfo: Put --dotsyms/--no-dotsyms on separate lines.
index dabbb05d0c0d2b0e34389dae467c9bdcc5749b12..aa976f8184a7e340cd2506ebf75ffa07439fc096 100644 (file)
@@ -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
index 7fe90894e8fa5517f97a71d40babd02999d19c5f..5fe576ea48063bb326eb39a5d7b8a8a49136e18d 100644 (file)
@@ -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"
@@ -2289,6 +2290,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)