Add binutils-2.19.1 patchset, propagated from the 2.19 patchset.
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Mar 08 11:14:03 2009 +0000 (2009-03-08)
changeset 12435d15872659ec
parent 1242 470541ef2b72
child 1244 ea45530f42c1
Add binutils-2.19.1 patchset, propagated from the 2.19 patchset.

/trunk/patches/binutils/2.19.1/120-sh-targets.patch | 57 57 0 0 +++
/trunk/patches/binutils/2.19.1/170-use-relro.patch | 19 19 0 0 +
/trunk/patches/binutils/2.19.1/160-use-new-ld-dtags.patch | 19 19 0 0 +
/trunk/patches/binutils/2.19.1/180-libiberty-pic.patch | 19 19 0 0 +
/trunk/patches/binutils/2.19.1/100-ppc64-pie.patch | 25 25 0 0 +
/trunk/patches/binutils/2.19.1/110-RPATH_ENVVAR-smack.patch | 22 22 0 0 +
/trunk/patches/binutils/2.19.1/140-pt-pax-flags-20081101.patch | 254 254 0 0 +++++++++++++++
/trunk/patches/binutils/2.19.1/150-warn-textrel.patch | 53 53 0 0 +++
/trunk/patches/binutils/2.19.1/130-check_ldrunpath_length.patch | 36 36 0 0 ++
9 files changed, 504 insertions(+)
patches/binutils/2.19.1/100-ppc64-pie.patch
patches/binutils/2.19.1/110-RPATH_ENVVAR-smack.patch
patches/binutils/2.19.1/120-sh-targets.patch
patches/binutils/2.19.1/130-check_ldrunpath_length.patch
patches/binutils/2.19.1/140-pt-pax-flags-20081101.patch
patches/binutils/2.19.1/150-warn-textrel.patch
patches/binutils/2.19.1/160-use-new-ld-dtags.patch
patches/binutils/2.19.1/170-use-relro.patch
patches/binutils/2.19.1/180-libiberty-pic.patch
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patches/binutils/2.19.1/100-ppc64-pie.patch	Sun Mar 08 11:14:03 2009 +0000
     1.3 @@ -0,0 +1,25 @@
     1.4 +Original patch from: ../crosstool-NG/ct-ng.trunk/patches/binutils/2.19/100-ppc64-pie.patch
     1.5 +
     1.6 +-= BEGIN original header =-
     1.7 +Original patch from Gentoo:
     1.8 +gentoo/src/patchsets/binutils/2.19/03_all_binutils-2.15.92.0.2-ppc64-pie.patch
     1.9 +
    1.10 +-= END original header =-
    1.11 +
    1.12 +diff -durN binutils-2.19.1.orig/bfd/elf64-ppc.c binutils-2.19.1/bfd/elf64-ppc.c
    1.13 +--- binutils-2.19.1.orig/bfd/elf64-ppc.c	2008-10-09 14:18:24.000000000 +0200
    1.14 ++++ binutils-2.19.1/bfd/elf64-ppc.c	2009-03-08 11:56:59.000000000 +0100
    1.15 +@@ -11294,7 +11294,12 @@
    1.16 + 	      else if (!SYMBOL_REFERENCES_LOCAL (info, &h->elf)
    1.17 + 		       && !is_opd
    1.18 + 		       && r_type != R_PPC64_TOC)
    1.19 +-		outrel.r_info = ELF64_R_INFO (h->elf.dynindx, r_type);
    1.20 ++		{
    1.21 ++		  outrel.r_info = ELF64_R_INFO (h->elf.dynindx, r_type);
    1.22 ++		  if (h->elf.dynindx == -1
    1.23 ++		      && h->elf.root.type == bfd_link_hash_undefweak)
    1.24 ++		  memset (&outrel, 0, sizeof outrel);
    1.25 ++		}
    1.26 + 	      else
    1.27 + 		{
    1.28 + 		  /* This symbol is local, or marked to become local,
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/patches/binutils/2.19.1/110-RPATH_ENVVAR-smack.patch	Sun Mar 08 11:14:03 2009 +0000
     2.3 @@ -0,0 +1,22 @@
     2.4 +Original patch from: ../crosstool-NG/ct-ng.trunk/patches/binutils/2.19/110-RPATH_ENVVAR-smack.patch
     2.5 +
     2.6 +-= BEGIN original header =-
     2.7 +Original patch from Gentoo:
     2.8 +gentoo/src/patchsets/binutils/2.19/08_all_binutils-RPATH_ENVVAR-smack.patch
     2.9 +
    2.10 +http://sourceware.org/ml/binutils/2007-07/msg00401.html
    2.11 +http://sourceware.org/bugzilla/show_bug.cgi?id=4970
    2.12 +
    2.13 +-= END original header =-
    2.14 +
    2.15 +diff -durN binutils-2.19.1.orig/configure binutils-2.19.1/configure
    2.16 +--- binutils-2.19.1.orig/configure	2008-09-04 04:18:16.000000000 +0200
    2.17 ++++ binutils-2.19.1/configure	2009-03-08 11:57:00.000000000 +0100
    2.18 +@@ -5601,6 +5601,7 @@
    2.19 +   *-*-mingw* | *-*-cygwin ) RPATH_ENVVAR=PATH ;;
    2.20 +   *) RPATH_ENVVAR=LD_LIBRARY_PATH ;;
    2.21 + esac
    2.22 ++RPATH_ENVVAR="cant_touch_this_nah_nah_nah"
    2.23 + 
    2.24 + # On systems where the dynamic library environment variable is PATH,
    2.25 + if test "$RPATH_ENVVAR" = PATH; then
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/patches/binutils/2.19.1/120-sh-targets.patch	Sun Mar 08 11:14:03 2009 +0000
     3.3 @@ -0,0 +1,57 @@
     3.4 +Original patch from: ../crosstool-NG/ct-ng.trunk/patches/binutils/2.19/120-sh-targets.patch
     3.5 +
     3.6 +-= BEGIN original header =-
     3.7 +Original patch from Gentoo:
     3.8 +gentoo/src/patchsets/binutils/2.19/12_all_sh-targets.patch
     3.9 +
    3.10 +r10231 | lethal | 2005-05-02 09:58:00 -0400 (Mon, 02 May 2005) | 13 lines
    3.11 +
    3.12 +Likewise, binutils has no idea about any of these new targets either, so we
    3.13 +fix that up too.. now we're able to actually build a real toolchain for
    3.14 +sh2a_nofpu- and other more ineptly named toolchains (and yes, there are more
    3.15 +inept targets than that one, really. Go look, I promise).
    3.16 +
    3.17 +-= END original header =-
    3.18 +
    3.19 +diff -durN binutils-2.19.1.orig/configure binutils-2.19.1/configure
    3.20 +--- binutils-2.19.1.orig/configure	2009-03-08 11:57:00.000000000 +0100
    3.21 ++++ binutils-2.19.1/configure	2009-03-08 11:57:00.000000000 +0100
    3.22 +@@ -2281,7 +2281,7 @@
    3.23 +   am33_2.0-*-linux*)
    3.24 +     noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
    3.25 +     ;;
    3.26 +-  sh-*-linux*)
    3.27 ++  sh*-*-linux*)
    3.28 +     noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
    3.29 +     ;;
    3.30 +   sh*-*-pe|mips*-*-pe|*arm-wince-pe)
    3.31 +@@ -2606,7 +2606,7 @@
    3.32 +   romp-*-*)
    3.33 +     noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
    3.34 +     ;;
    3.35 +-  sh-*-* | sh64-*-*)
    3.36 ++  sh*-*-* | sh64-*-*)
    3.37 +     case "${host}" in
    3.38 +       i[3456789]86-*-vsta) ;; # don't add gprof back in
    3.39 +       i[3456789]86-*-go32*) ;; # don't add gprof back in
    3.40 +diff -durN binutils-2.19.1.orig/configure.ac binutils-2.19.1/configure.ac
    3.41 +--- binutils-2.19.1.orig/configure.ac	2009-02-02 12:54:49.000000000 +0100
    3.42 ++++ binutils-2.19.1/configure.ac	2009-03-08 11:57:00.000000000 +0100
    3.43 +@@ -530,7 +530,7 @@
    3.44 +   am33_2.0-*-linux*)
    3.45 +     noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
    3.46 +     ;;
    3.47 +-  sh-*-linux*)
    3.48 ++  sh*-*-linux*)
    3.49 +     noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
    3.50 +     ;;    
    3.51 +   sh*-*-pe|mips*-*-pe|*arm-wince-pe)
    3.52 +@@ -855,7 +855,7 @@
    3.53 +   romp-*-*)
    3.54 +     noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
    3.55 +     ;;
    3.56 +-  sh-*-* | sh64-*-*)
    3.57 ++  sh*-*-* | sh64-*-*)
    3.58 +     case "${host}" in
    3.59 +       i[[3456789]]86-*-vsta) ;; # don't add gprof back in
    3.60 +       i[[3456789]]86-*-go32*) ;; # don't add gprof back in
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/patches/binutils/2.19.1/130-check_ldrunpath_length.patch	Sun Mar 08 11:14:03 2009 +0000
     4.3 @@ -0,0 +1,36 @@
     4.4 +Original patch from: ../crosstool-NG/ct-ng.trunk/patches/binutils/2.19/130-check_ldrunpath_length.patch
     4.5 +
     4.6 +-= BEGIN original header =-
     4.7 +Original patch from Gentoo:
     4.8 +gentoo/src/patchsets/binutils/2.19/42_all_012_check_ldrunpath_length.patch
     4.9 +
    4.10 +Originaly from Debian:
    4.11 +## 012_check_ldrunpath_length.dpatch by Chris Chimelis <chris@debian.org>
    4.12 +##
    4.13 +## All lines beginning with `## DP:' are a description of the patch.
    4.14 +## DP: Only generate an RPATH entry if LD_RUN_PATH is not empty, for
    4.15 +## DP: cases where -rpath isn't specified. (#151024)
    4.16 +
    4.17 +-= END original header =-
    4.18 +
    4.19 +diff -durN binutils-2.19.1.orig/ld/emultempl/elf32.em binutils-2.19.1/ld/emultempl/elf32.em
    4.20 +--- binutils-2.19.1.orig/ld/emultempl/elf32.em	2008-09-07 06:02:31.000000000 +0200
    4.21 ++++ binutils-2.19.1/ld/emultempl/elf32.em	2009-03-08 11:57:01.000000000 +0100
    4.22 +@@ -1219,6 +1219,8 @@
    4.23 + 	      && command_line.rpath == NULL)
    4.24 + 	    {
    4.25 + 	      lib_path = (const char *) getenv ("LD_RUN_PATH");
    4.26 ++	      if ((lib_path) && (strlen (lib_path) == 0))
    4.27 ++		  lib_path = NULL;
    4.28 + 	      if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
    4.29 + 						      force))
    4.30 + 		break;
    4.31 +@@ -1404,6 +1406,8 @@
    4.32 +   rpath = command_line.rpath;
    4.33 +   if (rpath == NULL)
    4.34 +     rpath = (const char *) getenv ("LD_RUN_PATH");
    4.35 ++  if ((rpath) && (strlen (rpath) == 0))
    4.36 ++      rpath = NULL;
    4.37 +   if (! (bfd_elf_size_dynamic_sections
    4.38 + 	 (link_info.output_bfd, command_line.soname, rpath,
    4.39 + 	  command_line.filter_shlib,
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/patches/binutils/2.19.1/140-pt-pax-flags-20081101.patch	Sun Mar 08 11:14:03 2009 +0000
     5.3 @@ -0,0 +1,254 @@
     5.4 +Original patch from: ../crosstool-NG/ct-ng.trunk/patches/binutils/2.19/140-pt-pax-flags-20081101.patch
     5.5 +
     5.6 +-= BEGIN original header =-
     5.7 +Original patch from Gentoo:
     5.8 +gentoo/src/patchsets/binutils/2.19/63_all_binutils-2.19-pt-pax-flags-20081101.patch
     5.9 +
    5.10 +-= END original header =-
    5.11 +
    5.12 +diff -durN binutils-2.19.1.orig/bfd/elf-bfd.h binutils-2.19.1/bfd/elf-bfd.h
    5.13 +--- binutils-2.19.1.orig/bfd/elf-bfd.h	2008-08-21 01:28:58.000000000 +0200
    5.14 ++++ binutils-2.19.1/bfd/elf-bfd.h	2009-03-08 11:57:02.000000000 +0100
    5.15 +@@ -1526,6 +1526,9 @@
    5.16 +   /* Segment flags for the PT_GNU_STACK segment.  */
    5.17 +   unsigned int stack_flags;
    5.18 + 
    5.19 ++  /* Segment flags for the PT_PAX_FLAGS segment.  */
    5.20 ++  unsigned int pax_flags;
    5.21 ++
    5.22 +   /* Symbol version definitions in external objects.  */
    5.23 +   Elf_Internal_Verdef *verdef;
    5.24 + 
    5.25 +diff -durN binutils-2.19.1.orig/bfd/elf.c binutils-2.19.1/bfd/elf.c
    5.26 +--- binutils-2.19.1.orig/bfd/elf.c	2008-12-23 14:54:48.000000000 +0100
    5.27 ++++ binutils-2.19.1/bfd/elf.c	2009-03-08 11:57:02.000000000 +0100
    5.28 +@@ -1136,6 +1136,7 @@
    5.29 +     case PT_GNU_EH_FRAME: pt = "EH_FRAME"; break;
    5.30 +     case PT_GNU_STACK: pt = "STACK"; break;
    5.31 +     case PT_GNU_RELRO: pt = "RELRO"; break;
    5.32 ++    case PT_PAX_FLAGS: pt = "PAX_FLAGS"; break;
    5.33 +     default: pt = NULL; break;
    5.34 +     }
    5.35 +   return pt;
    5.36 +@@ -2442,6 +2443,9 @@
    5.37 +     case PT_GNU_RELRO:
    5.38 +       return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "relro");
    5.39 + 
    5.40 ++    case PT_PAX_FLAGS:
    5.41 ++      return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "pax_flags");
    5.42 ++
    5.43 +     default:
    5.44 +       /* Check for any processor-specific program segment types.  */
    5.45 +       bed = get_elf_backend_data (abfd);
    5.46 +@@ -3404,6 +3408,11 @@
    5.47 +       ++segs;
    5.48 +     }
    5.49 + 
    5.50 ++    {
    5.51 ++      /* We need a PT_PAX_FLAGS segment.  */
    5.52 ++      ++segs;
    5.53 ++    }
    5.54 ++
    5.55 +   for (s = abfd->sections; s != NULL; s = s->next)
    5.56 +     {
    5.57 +       if ((s->flags & SEC_LOAD) != 0
    5.58 +@@ -3983,6 +3992,20 @@
    5.59 + 	    }
    5.60 + 	}
    5.61 + 
    5.62 ++    {
    5.63 ++      amt = sizeof (struct elf_segment_map);
    5.64 ++      m = bfd_zalloc (abfd, amt);
    5.65 ++      if (m == NULL)
    5.66 ++	goto error_return;
    5.67 ++      m->next = NULL;
    5.68 ++      m->p_type = PT_PAX_FLAGS;
    5.69 ++      m->p_flags = elf_tdata (abfd)->pax_flags;
    5.70 ++      m->p_flags_valid = 1;
    5.71 ++
    5.72 ++      *pm = m;
    5.73 ++      pm = &m->next;
    5.74 ++    }
    5.75 ++
    5.76 +       free (sections);
    5.77 +       elf_tdata (abfd)->segment_map = mfirst;
    5.78 +     }
    5.79 +@@ -5160,7 +5183,8 @@
    5.80 +        6. PT_TLS segment includes only SHF_TLS sections.
    5.81 +        7. SHF_TLS sections are only in PT_TLS or PT_LOAD segments.
    5.82 +        8. PT_DYNAMIC should not contain empty sections at the beginning
    5.83 +-	  (with the possible exception of .dynamic).  */
    5.84 ++	  (with the possible exception of .dynamic).
    5.85 ++       9. PT_PAX_FLAGS segments does not include any sections.  */
    5.86 + #define IS_SECTION_IN_INPUT_SEGMENT(section, segment, bed)		\
    5.87 +   ((((segment->p_paddr							\
    5.88 +       ? IS_CONTAINED_BY_LMA (section, segment, segment->p_paddr)	\
    5.89 +@@ -5168,6 +5192,7 @@
    5.90 +      && (section->flags & SEC_ALLOC) != 0)				\
    5.91 +     || IS_NOTE (segment, section))					\
    5.92 +    && segment->p_type != PT_GNU_STACK					\
    5.93 ++   && segment->p_type != PT_PAX_FLAGS					\
    5.94 +    && (segment->p_type != PT_TLS					\
    5.95 +        || (section->flags & SEC_THREAD_LOCAL))				\
    5.96 +    && (segment->p_type == PT_LOAD					\
    5.97 +diff -durN binutils-2.19.1.orig/bfd/elflink.c binutils-2.19.1/bfd/elflink.c
    5.98 +--- binutils-2.19.1.orig/bfd/elflink.c	2008-08-22 10:32:39.000000000 +0200
    5.99 ++++ binutils-2.19.1/bfd/elflink.c	2009-03-08 11:57:02.000000000 +0100
   5.100 +@@ -5397,16 +5397,30 @@
   5.101 +     return TRUE;
   5.102 + 
   5.103 +   bed = get_elf_backend_data (output_bfd);
   5.104 ++  elf_tdata (output_bfd)->pax_flags = PF_NORANDEXEC;
   5.105 ++
   5.106 ++  if (info->execheap)
   5.107 ++    elf_tdata (output_bfd)->pax_flags |= PF_NOMPROTECT;
   5.108 ++  else if (info->noexecheap)
   5.109 ++    elf_tdata (output_bfd)->pax_flags |= PF_MPROTECT;
   5.110 ++
   5.111 +   if (info->execstack)
   5.112 +-    elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X;
   5.113 ++    {
   5.114 ++      elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X;
   5.115 ++      elf_tdata (output_bfd)->pax_flags |= PF_EMUTRAMP;
   5.116 ++    }
   5.117 +   else if (info->noexecstack)
   5.118 +-    elf_tdata (output_bfd)->stack_flags = PF_R | PF_W;
   5.119 ++    {
   5.120 ++      elf_tdata (output_bfd)->stack_flags = PF_R | PF_W;
   5.121 ++      elf_tdata (output_bfd)->pax_flags |= PF_NOEMUTRAMP;
   5.122 ++    }
   5.123 +   else
   5.124 +     {
   5.125 +       bfd *inputobj;
   5.126 +       asection *notesec = NULL;
   5.127 +       int exec = 0;
   5.128 + 
   5.129 ++      elf_tdata (output_bfd)->pax_flags |= PF_NOEMUTRAMP;
   5.130 +       for (inputobj = info->input_bfds;
   5.131 + 	   inputobj;
   5.132 + 	   inputobj = inputobj->link_next)
   5.133 +@@ -5419,7 +5433,11 @@
   5.134 + 	  if (s)
   5.135 + 	    {
   5.136 + 	      if (s->flags & SEC_CODE)
   5.137 +-		exec = PF_X;
   5.138 ++		{
   5.139 ++		  elf_tdata (output_bfd)->pax_flags &= ~PF_NOEMUTRAMP;
   5.140 ++		  elf_tdata (output_bfd)->pax_flags |= PF_EMUTRAMP;
   5.141 ++		  exec = PF_X;
   5.142 ++		}
   5.143 + 	      notesec = s;
   5.144 + 	    }
   5.145 + 	  else if (bed->default_execstack)
   5.146 +diff -durN binutils-2.19.1.orig/binutils/readelf.c binutils-2.19.1/binutils/readelf.c
   5.147 +--- binutils-2.19.1.orig/binutils/readelf.c	2008-09-17 11:00:44.000000000 +0200
   5.148 ++++ binutils-2.19.1/binutils/readelf.c	2009-03-08 11:57:02.000000000 +0100
   5.149 +@@ -2505,6 +2505,7 @@
   5.150 + 			return "GNU_EH_FRAME";
   5.151 +     case PT_GNU_STACK:	return "GNU_STACK";
   5.152 +     case PT_GNU_RELRO:  return "GNU_RELRO";
   5.153 ++    case PT_PAX_FLAGS:  return "PAX_FLAGS";
   5.154 + 
   5.155 +     default:
   5.156 +       if ((p_type >= PT_LOPROC) && (p_type <= PT_HIPROC))
   5.157 +diff -durN binutils-2.19.1.orig/include/bfdlink.h binutils-2.19.1/include/bfdlink.h
   5.158 +--- binutils-2.19.1.orig/include/bfdlink.h	2008-08-17 05:12:50.000000000 +0200
   5.159 ++++ binutils-2.19.1/include/bfdlink.h	2009-03-08 11:57:02.000000000 +0100
   5.160 +@@ -319,6 +319,14 @@
   5.161 +   /* TRUE if PT_GNU_RELRO segment should be created.  */
   5.162 +   unsigned int relro: 1;
   5.163 + 
   5.164 ++  /* TRUE if PT_PAX_FLAGS segment should be created with PF_NOMPROTECT
   5.165 ++     flags.  */
   5.166 ++  unsigned int execheap: 1;
   5.167 ++
   5.168 ++  /* TRUE if PT_PAX_FLAGS segment should be created with PF_MPROTECT
   5.169 ++     flags.  */
   5.170 ++  unsigned int noexecheap: 1;
   5.171 ++
   5.172 +   /* TRUE if we should warn when adding a DT_TEXTREL to a shared object.  */
   5.173 +   unsigned int warn_shared_textrel: 1;
   5.174 + 
   5.175 +diff -durN binutils-2.19.1.orig/include/elf/common.h binutils-2.19.1/include/elf/common.h
   5.176 +--- binutils-2.19.1.orig/include/elf/common.h	2008-08-04 01:20:42.000000000 +0200
   5.177 ++++ binutils-2.19.1/include/elf/common.h	2009-03-08 11:57:02.000000000 +0100
   5.178 +@@ -360,6 +360,7 @@
   5.179 + #define PT_SUNW_EH_FRAME PT_GNU_EH_FRAME      /* Solaris uses the same value */
   5.180 + #define PT_GNU_STACK	(PT_LOOS + 0x474e551) /* Stack flags */
   5.181 + #define PT_GNU_RELRO	(PT_LOOS + 0x474e552) /* Read-only after relocation */
   5.182 ++#define PT_PAX_FLAGS	(PT_LOOS + 0x5041580) /* PaX flags */
   5.183 + 
   5.184 + /* Program segment permissions, in program header p_flags field.  */
   5.185 + 
   5.186 +@@ -370,6 +371,21 @@
   5.187 + #define PF_MASKOS	0x0FF00000	/* New value, Oct 4, 1999 Draft */
   5.188 + #define PF_MASKPROC	0xF0000000	/* Processor-specific reserved bits */
   5.189 + 
   5.190 ++/* Flags to control PaX behavior.  */
   5.191 ++
   5.192 ++#define PF_PAGEEXEC	(1 << 4)	/* Enable  PAGEEXEC */
   5.193 ++#define PF_NOPAGEEXEC	(1 << 5)	/* Disable PAGEEXEC */
   5.194 ++#define PF_SEGMEXEC	(1 << 6)	/* Enable  SEGMEXEC */
   5.195 ++#define PF_NOSEGMEXEC	(1 << 7)	/* Disable SEGMEXEC */
   5.196 ++#define PF_MPROTECT	(1 << 8)	/* Enable  MPROTECT */
   5.197 ++#define PF_NOMPROTECT	(1 << 9)	/* Disable MPROTECT */
   5.198 ++#define PF_RANDEXEC	(1 << 10)	/* Enable  RANDEXEC */
   5.199 ++#define PF_NORANDEXEC	(1 << 11)	/* Disable RANDEXEC */
   5.200 ++#define PF_EMUTRAMP	(1 << 12)	/* Enable  EMUTRAMP */
   5.201 ++#define PF_NOEMUTRAMP	(1 << 13)	/* Disable EMUTRAMP */
   5.202 ++#define PF_RANDMMAP	(1 << 14)	/* Enable  RANDMMAP */
   5.203 ++#define PF_NORANDMMAP	(1 << 15)	/* Disable RANDMMAP */
   5.204 ++
   5.205 + /* Values for section header, sh_type field.  */
   5.206 + 
   5.207 + #define SHT_NULL	0		/* Section header table entry unused */
   5.208 +diff -durN binutils-2.19.1.orig/ld/emultempl/elf32.em binutils-2.19.1/ld/emultempl/elf32.em
   5.209 +--- binutils-2.19.1.orig/ld/emultempl/elf32.em	2009-03-08 11:57:01.000000000 +0100
   5.210 ++++ binutils-2.19.1/ld/emultempl/elf32.em	2009-03-08 11:57:02.000000000 +0100
   5.211 +@@ -2146,6 +2146,16 @@
   5.212 + 	  link_info.noexecstack = TRUE;
   5.213 + 	  link_info.execstack = FALSE;
   5.214 + 	}
   5.215 ++      else if (strcmp (optarg, "execheap") == 0)
   5.216 ++	{
   5.217 ++	  link_info.execheap = TRUE;
   5.218 ++	  link_info.noexecheap = FALSE;
   5.219 ++	}
   5.220 ++      else if (strcmp (optarg, "noexecheap") == 0)
   5.221 ++	{
   5.222 ++	  link_info.noexecheap = TRUE;
   5.223 ++	  link_info.execheap = FALSE;
   5.224 ++	}
   5.225 + EOF
   5.226 + 
   5.227 +   if test -n "$COMMONPAGESIZE"; then
   5.228 +@@ -2229,6 +2239,8 @@
   5.229 +   fprintf (file, _("\
   5.230 +   -z execstack                Mark executable as requiring executable stack\n"));
   5.231 +   fprintf (file, _("\
   5.232 ++  -z execheap\t\tMark executable as requiring executable heap\n"));
   5.233 ++  fprintf (file, _("\
   5.234 +   -z initfirst                Mark DSO to be initialized first at runtime\n"));
   5.235 +   fprintf (file, _("\
   5.236 +   -z interpose                Mark object to interpose all DSOs but executable\n"));
   5.237 +@@ -2252,6 +2264,8 @@
   5.238 +   -z nodump                   Mark DSO not available to dldump\n"));
   5.239 +   fprintf (file, _("\
   5.240 +   -z noexecstack              Mark executable as not requiring executable stack\n"));
   5.241 ++  fprintf (file, _("\
   5.242 ++  -z noexecheap\tMark executable as not requiring executable heap\n"));
   5.243 + EOF
   5.244 + 
   5.245 +   if test -n "$COMMONPAGESIZE"; then
   5.246 +diff -durN binutils-2.19.1.orig/ld/ldgram.y binutils-2.19.1/ld/ldgram.y
   5.247 +--- binutils-2.19.1.orig/ld/ldgram.y	2008-07-06 15:38:36.000000000 +0200
   5.248 ++++ binutils-2.19.1/ld/ldgram.y	2009-03-08 11:57:02.000000000 +0100
   5.249 +@@ -1112,6 +1112,8 @@
   5.250 + 			    $$ = exp_intop (0x6474e550);
   5.251 + 			  else if (strcmp (s, "PT_GNU_STACK") == 0)
   5.252 + 			    $$ = exp_intop (0x6474e551);
   5.253 ++			  else if (strcmp (s, "PT_PAX_FLAGS") == 0)
   5.254 ++			    $$ = exp_intop (0x65041580);
   5.255 + 			  else
   5.256 + 			    {
   5.257 + 			      einfo (_("\
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/patches/binutils/2.19.1/150-warn-textrel.patch	Sun Mar 08 11:14:03 2009 +0000
     6.3 @@ -0,0 +1,53 @@
     6.4 +Original patch from: ../crosstool-NG/ct-ng.trunk/patches/binutils/2.19/150-warn-textrel.patch
     6.5 +
     6.6 +-= BEGIN original header =-
     6.7 +Original patch from Gentoo:
     6.8 +gentoo/src/patchsets/binutils/2.19/66_all_binutils-2.18.50.0.2-warn-textrel.patch
     6.9 +
    6.10 +textrels are bad for forcing copy-on-write (this affects everyone),
    6.11 +and for security/runtime code generation, this affects security ppl.
    6.12 +But in either case, it doesn't matter who needs textrels, it's
    6.13 +the very fact that they're needed at all.
    6.14 +
    6.15 +-= END original header =-
    6.16 +
    6.17 +diff -durN binutils-2.19.1.orig/bfd/elflink.c binutils-2.19.1/bfd/elflink.c
    6.18 +--- binutils-2.19.1.orig/bfd/elflink.c	2009-03-08 11:57:02.000000000 +0100
    6.19 ++++ binutils-2.19.1/bfd/elflink.c	2009-03-08 11:57:02.000000000 +0100
    6.20 +@@ -10820,14 +10820,12 @@
    6.21 + 	goto error_return;
    6.22 + 
    6.23 +       /* Check for DT_TEXTREL (late, in case the backend removes it).  */
    6.24 +-      if (info->warn_shared_textrel && info->shared)
    6.25 ++      o = bfd_get_section_by_name (dynobj, ".dynamic");
    6.26 ++      if (info->warn_shared_textrel && o != NULL)
    6.27 + 	{
    6.28 + 	  bfd_byte *dyncon, *dynconend;
    6.29 + 
    6.30 + 	  /* Fix up .dynamic entries.  */
    6.31 +-	  o = bfd_get_section_by_name (dynobj, ".dynamic");
    6.32 +-	  BFD_ASSERT (o != NULL);
    6.33 +-
    6.34 + 	  dyncon = o->contents;
    6.35 + 	  dynconend = o->contents + o->size;
    6.36 + 	  for (; dyncon < dynconend; dyncon += bed->s->sizeof_dyn)
    6.37 +@@ -10839,7 +10837,7 @@
    6.38 + 	      if (dyn.d_tag == DT_TEXTREL)
    6.39 + 		{
    6.40 + 		 info->callbacks->einfo
    6.41 +-		    (_("%P: warning: creating a DT_TEXTREL in a shared object.\n"));
    6.42 ++		    (_("%P: warning: creating a DT_TEXTREL in object.\n"));
    6.43 + 		  break;
    6.44 + 		}
    6.45 + 	    }
    6.46 +diff -durN binutils-2.19.1.orig/ld/ldmain.c binutils-2.19.1/ld/ldmain.c
    6.47 +--- binutils-2.19.1.orig/ld/ldmain.c	2008-08-17 05:12:50.000000000 +0200
    6.48 ++++ binutils-2.19.1/ld/ldmain.c	2009-03-08 11:57:02.000000000 +0100
    6.49 +@@ -274,6 +274,7 @@
    6.50 +   link_info.relax_pass = 1;
    6.51 +   link_info.pei386_auto_import = -1;
    6.52 +   link_info.spare_dynamic_tags = 5;
    6.53 ++  link_info.warn_shared_textrel = TRUE;
    6.54 +   link_info.path_separator = ':';
    6.55 + 
    6.56 +   ldfile_add_arch ("");
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/patches/binutils/2.19.1/160-use-new-ld-dtags.patch	Sun Mar 08 11:14:03 2009 +0000
     7.3 @@ -0,0 +1,19 @@
     7.4 +Original patch from: ../crosstool-NG/ct-ng.trunk/patches/binutils/2.19/160-use-new-ld-dtags.patch
     7.5 +
     7.6 +-= BEGIN original header =-
     7.7 +Original patch from Gentoo:
     7.8 +gentoo/src/patchsets/binutils/2.19/76_all_use-new-ld-dtags.patch
     7.9 +
    7.10 +-= END original header =-
    7.11 +
    7.12 +diff -durN binutils-2.19.1.orig/ld/ldmain.c binutils-2.19.1/ld/ldmain.c
    7.13 +--- binutils-2.19.1.orig/ld/ldmain.c	2009-03-08 11:57:03.000000000 +0100
    7.14 ++++ binutils-2.19.1/ld/ldmain.c	2009-03-08 11:57:03.000000000 +0100
    7.15 +@@ -262,6 +262,7 @@
    7.16 + 
    7.17 +   link_info.allow_undefined_version = TRUE;
    7.18 +   link_info.keep_memory = TRUE;
    7.19 ++  link_info.new_dtags = TRUE;
    7.20 +   link_info.combreloc = TRUE;
    7.21 +   link_info.strip_discarded = TRUE;
    7.22 +   link_info.emit_hash = TRUE;
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/patches/binutils/2.19.1/170-use-relro.patch	Sun Mar 08 11:14:03 2009 +0000
     8.3 @@ -0,0 +1,19 @@
     8.4 +Original patch from: ../crosstool-NG/ct-ng.trunk/patches/binutils/2.19/170-use-relro.patch
     8.5 +
     8.6 +-= BEGIN original header =-
     8.7 +Original patch from Gentoo:
     8.8 +gentoo/src/patchsets/binutils/2.19/78_all_use-relro.patch
     8.9 +
    8.10 +-= END original header =-
    8.11 +
    8.12 +diff -durN binutils-2.19.1.orig/ld/ldmain.c binutils-2.19.1/ld/ldmain.c
    8.13 +--- binutils-2.19.1.orig/ld/ldmain.c	2009-03-08 11:57:03.000000000 +0100
    8.14 ++++ binutils-2.19.1/ld/ldmain.c	2009-03-08 11:57:03.000000000 +0100
    8.15 +@@ -264,6 +264,7 @@
    8.16 +   link_info.keep_memory = TRUE;
    8.17 +   link_info.new_dtags = TRUE;
    8.18 +   link_info.combreloc = TRUE;
    8.19 ++  link_info.relro = TRUE;
    8.20 +   link_info.strip_discarded = TRUE;
    8.21 +   link_info.emit_hash = TRUE;
    8.22 +   link_info.callbacks = &link_callbacks;
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/patches/binutils/2.19.1/180-libiberty-pic.patch	Sun Mar 08 11:14:03 2009 +0000
     9.3 @@ -0,0 +1,19 @@
     9.4 +Original patch from: ../crosstool-NG/ct-ng.trunk/patches/binutils/2.19/180-libiberty-pic.patch
     9.5 +
     9.6 +-= BEGIN original header =-
     9.7 +Original patch from Gentoo:
     9.8 +gentoo/src/patchsets/binutils/2.19/91_all_libiberty-pic.patch
     9.9 +
    9.10 +-= END original header =-
    9.11 +
    9.12 +diff -durN binutils-2.19.1.orig/libiberty/Makefile.in binutils-2.19.1/libiberty/Makefile.in
    9.13 +--- binutils-2.19.1.orig/libiberty/Makefile.in	2008-07-24 15:51:49.000000000 +0200
    9.14 ++++ binutils-2.19.1/libiberty/Makefile.in	2009-03-08 11:57:03.000000000 +0100
    9.15 +@@ -227,6 +227,7 @@
    9.16 + 	  $(AR) $(AR_FLAGS) $(TARGETLIB) \
    9.17 + 	    $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS); \
    9.18 + 	  $(RANLIB) $(TARGETLIB); \
    9.19 ++	  cp $(TARGETLIB) ../ ; \
    9.20 + 	  cd ..; \
    9.21 + 	else true; fi
    9.22 +