1 diff -uNr binutils-2.15.90.0.1.1.orig/bfd/elf-bfd.h binutils-2.15.90.0.1.1/bfd/elf-bfd.h
2 --- binutils-2.15.90.0.1.1.orig/bfd/elf-bfd.h 2004-03-03 21:24:33.000000000 +0100
3 +++ binutils-2.15.90.0.1.1/bfd/elf-bfd.h 2004-03-17 11:51:20.951912544 +0100
5 /* Segment flags for the PT_GNU_STACK segment. */
6 unsigned int stack_flags;
8 + /* Segment flags for the PT_PAX_FLAGS segment. */
9 + unsigned int pax_flags;
11 /* Symbol version definitions in external objects. */
12 Elf_Internal_Verdef *verdef;
14 diff -uNr binutils-2.15.90.0.1.1.orig/bfd/elf.c binutils-2.15.90.0.1.1/bfd/elf.c
15 --- binutils-2.15.90.0.1.1.orig/bfd/elf.c 2004-03-03 21:24:33.000000000 +0100
16 +++ binutils-2.15.90.0.1.1/bfd/elf.c 2004-03-17 11:57:20.657229024 +0100
18 case PT_TLS: pt = "TLS"; break;
19 case PT_GNU_EH_FRAME: pt = "EH_FRAME"; break;
20 case PT_GNU_STACK: pt = "STACK"; break;
21 + case PT_PAX_FLAGS: pt = "PAX_FLAGS"; break;
22 default: sprintf (buf, "0x%lx", p->p_type); pt = buf; break;
24 fprintf (f, "%8s off 0x", pt);
27 return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "stack");
30 + return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "pax_flags");
33 /* Check for any processor-specific program segment types.
34 If no handler for them, default to making "segment" sections. */
35 @@ -3502,6 +3506,20 @@
40 + amt = sizeof (struct elf_segment_map);
41 + m = bfd_zalloc (abfd, amt);
45 + m->p_type = PT_PAX_FLAGS;
46 + m->p_flags = elf_tdata (abfd)->pax_flags;
47 + m->p_flags_valid = 1;
56 @@ -4123,6 +4141,11 @@
61 + /* We need a PT_PAX_FLAGS segment. */
65 for (s = abfd->sections; s != NULL; s = s->next)
67 if ((s->flags & SEC_LOAD) != 0
69 || IS_COREFILE_NOTE (segment, section)) \
70 && section->output_section != NULL \
71 && segment->p_type != PT_GNU_STACK \
72 + && segment->p_type != PT_PAX_FLAGS \
73 && (segment->p_type != PT_TLS \
74 || (section->flags & SEC_THREAD_LOCAL)) \
75 && (segment->p_type == PT_LOAD \
76 diff -uNr binutils-2.15.90.0.1.1.orig/bfd/elflink.h binutils-2.15.90.0.1.1/bfd/elflink.h
77 --- binutils-2.15.90.0.1.1.orig/bfd/elflink.h 2004-03-03 21:24:33.000000000 +0100
78 +++ binutils-2.15.90.0.1.1/bfd/elflink.h 2004-03-17 12:05:53.403279776 +0100
79 @@ -1654,16 +1654,30 @@
80 if (!is_elf_hash_table (info->hash))
83 + elf_tdata (output_bfd)->pax_flags = PF_NORANDEXEC;
86 + elf_tdata (output_bfd)->pax_flags |= PF_NOMPROTECT;
87 + else if (info->noexecheap)
88 + elf_tdata (output_bfd)->pax_flags |= PF_MPROTECT;
92 elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X;
93 + elf_tdata (output_bfd)->pax_flags |= PF_EMUTRAMP;
95 else if (info->noexecstack)
97 elf_tdata (output_bfd)->stack_flags = PF_R | PF_W;
98 + elf_tdata (output_bfd)->pax_flags |= PF_NOEMUTRAMP;
103 asection *notesec = NULL;
106 + elf_tdata (output_bfd)->pax_flags |= PF_NOEMUTRAMP;
107 for (inputobj = info->input_bfds;
109 inputobj = inputobj->link_next)
110 @@ -1676,7 +1690,11 @@
113 if (s->flags & SEC_CODE)
116 + elf_tdata (output_bfd)->pax_flags &= ~PF_NOEMUTRAMP;
117 + elf_tdata (output_bfd)->pax_flags |= PF_EMUTRAMP;
123 diff -uNr binutils-2.15.90.0.1.1.orig/binutils/readelf.c binutils-2.15.90.0.1.1/binutils/readelf.c
124 --- binutils-2.15.90.0.1.1.orig/binutils/readelf.c 2004-03-03 21:24:34.000000000 +0100
125 +++ binutils-2.15.90.0.1.1/binutils/readelf.c 2004-03-17 12:07:27.989900424 +0100
126 @@ -2144,6 +2144,7 @@
127 case PT_GNU_EH_FRAME:
128 return "GNU_EH_FRAME";
129 case PT_GNU_STACK: return "STACK";
130 + case PT_PAX_FLAGS: return "PAX_FLAGS";
133 if ((p_type >= PT_LOPROC) && (p_type <= PT_HIPROC))
134 diff -uNr binutils-2.15.90.0.1.1.orig/include/bfdlink.h binutils-2.15.90.0.1.1/include/bfdlink.h
135 --- binutils-2.15.90.0.1.1.orig/include/bfdlink.h 2004-01-14 22:07:51.000000000 +0100
136 +++ binutils-2.15.90.0.1.1/include/bfdlink.h 2004-03-17 11:51:21.109888528 +0100
139 unsigned int noexecstack: 1;
141 + /* TRUE if PT_PAX_FLAGS segment should be created with PF_NOMPROTECT
143 + unsigned int execheap: 1;
145 + /* TRUE if PT_PAX_FLAGS segment should be created with PF_MPROTECT
147 + unsigned int noexecheap: 1;
149 /* What to do with unresolved symbols in an object file.
150 When producing static binaries the default is GENERATE_ERROR.
151 When producing dynamic binaries the default is IGNORE. The
152 diff -uNr binutils-2.15.90.0.1.1.orig/include/elf/common.h binutils-2.15.90.0.1.1/include/elf/common.h
153 --- binutils-2.15.90.0.1.1.orig/include/elf/common.h 2004-03-03 21:24:34.000000000 +0100
154 +++ binutils-2.15.90.0.1.1/include/elf/common.h 2004-03-17 11:55:02.074296832 +0100
155 @@ -289,12 +289,27 @@
157 #define PT_GNU_EH_FRAME (PT_LOOS + 0x474e550)
158 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
159 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
161 /* Program segment permissions, in program header p_flags field. */
163 #define PF_X (1 << 0) /* Segment is executable */
164 #define PF_W (1 << 1) /* Segment is writable */
165 #define PF_R (1 << 2) /* Segment is readable */
167 +#define PF_PAGEEXEC (1 << 4) /* Enable PAGEEXEC */
168 +#define PF_NOPAGEEXEC (1 << 5) /* Disable PAGEEXEC */
169 +#define PF_SEGMEXEC (1 << 6) /* Enable SEGMEXEC */
170 +#define PF_NOSEGMEXEC (1 << 7) /* Disable SEGMEXEC */
171 +#define PF_MPROTECT (1 << 8) /* Enable MPROTECT */
172 +#define PF_NOMPROTECT (1 << 9) /* Disable MPROTECT */
173 +#define PF_RANDEXEC (1 << 10) /* Enable RANDEXEC */
174 +#define PF_NORANDEXEC (1 << 11) /* Disable RANDEXEC */
175 +#define PF_EMUTRAMP (1 << 12) /* Enable EMUTRAMP */
176 +#define PF_NOEMUTRAMP (1 << 13) /* Disable EMUTRAMP */
177 +#define PF_RANDMMAP (1 << 14) /* Enable RANDMMAP */
178 +#define PF_NORANDMMAP (1 << 15) /* Disable RANDMMAP */
180 /* #define PF_MASKOS 0x0F000000 *//* OS-specific reserved bits */
181 #define PF_MASKOS 0x0FF00000 /* New value, Oct 4, 1999 Draft */
182 #define PF_MASKPROC 0xF0000000 /* Processor-specific reserved bits */
183 diff -uNr binutils-2.15.90.0.1.1.orig/ld/emultempl/elf32.em binutils-2.15.90.0.1.1/ld/emultempl/elf32.em
184 --- binutils-2.15.90.0.1.1.orig/ld/emultempl/elf32.em 2004-01-14 22:07:53.000000000 +0100
185 +++ binutils-2.15.90.0.1.1/ld/emultempl/elf32.em 2004-03-17 12:12:08.072321424 +0100
186 @@ -1645,6 +1645,16 @@
187 link_info.noexecstack = TRUE;
188 link_info.execstack = FALSE;
190 + else if (strcmp (optarg, "execheap") == 0)
192 + link_info.execheap = TRUE;
193 + link_info.noexecheap = FALSE;
195 + else if (strcmp (optarg, "noexecheap") == 0)
197 + link_info.noexecheap = TRUE;
198 + link_info.execheap = FALSE;
200 /* What about the other Solaris -z options? FIXME. */
203 @@ -1681,6 +1691,7 @@
204 fprintf (file, _(" -z combreloc\t\tMerge dynamic relocs into one section and sort\n"));
205 fprintf (file, _(" -z defs\t\tReport unresolved symbols in object files.\n"));
206 fprintf (file, _(" -z execstack\t\tMark executable as requiring executable stack\n"));
207 + fprintf (file, _(" -z execheap\t\tMark executable as requiring executable heap\n"));
208 fprintf (file, _(" -z initfirst\t\tMark DSO to be initialized first at runtime\n"));
209 fprintf (file, _(" -z interpose\t\tMark object to interpose all DSOs but executable\n"));
210 fprintf (file, _(" -z loadfltr\t\tMark object requiring immediate process\n"));
211 @@ -1692,6 +1703,7 @@
212 fprintf (file, _(" -z nodlopen\t\tMark DSO not available to dlopen\n"));
213 fprintf (file, _(" -z nodump\t\tMark DSO not available to dldump\n"));
214 fprintf (file, _(" -z noexecstack\tMark executable as not requiring executable stack\n"));
215 + fprintf (file, _(" -z noexecheap\t\tMark executable as not requiring executable heap\n"));
216 fprintf (file, _(" -z now\t\tMark object non-lazy runtime binding\n"));
217 fprintf (file, _(" -z origin\t\tMark object requiring immediate \$ORIGIN processing\n\t\t\t at runtime\n"));
218 fprintf (file, _(" -z KEYWORD\t\tIgnored for Solaris compatibility\n"));
219 diff -uNr binutils-2.15.90.0.1.1.orig/ld/ldgram.y binutils-2.15.90.0.1.1/ld/ldgram.y
220 --- binutils-2.15.90.0.1.1.orig/ld/ldgram.y 2004-03-03 21:24:34.000000000 +0100
221 +++ binutils-2.15.90.0.1.1/ld/ldgram.y 2004-03-17 11:51:21.123886400 +0100
222 @@ -1019,6 +1019,8 @@
223 $$ = exp_intop (0x6474e550);
224 else if (strcmp (s, "PT_GNU_STACK") == 0)
225 $$ = exp_intop (0x6474e551);
226 + else if (strcmp (s, "PT_PAX_FLAGS") == 0)
227 + $$ = exp_intop (0x65041580);