]>
Commit | Line | Data |
---|---|---|
2b1d2907 PS |
1 | diff -uNr binutils-2.15.94.0.2.2.orig/bfd/elf-bfd.h binutils-2.15.94.0.2.2/bfd/elf-bfd.h |
2 | --- binutils-2.15.94.0.2.2.orig/bfd/elf-bfd.h 2005-02-07 20:42:44.000000000 +0100 | |
3 | +++ binutils-2.15.94.0.2.2/bfd/elf-bfd.h 2005-02-20 13:13:17.362558200 +0100 | |
4 | @@ -1266,6 +1266,9 @@ | |
5 | /* Should the PT_GNU_RELRO segment be emitted? */ | |
6 | bfd_boolean relro; | |
60005366 PS |
7 | |
8 | + /* Segment flags for the PT_PAX_FLAGS segment. */ | |
9 | + unsigned int pax_flags; | |
10 | + | |
11 | /* Symbol version definitions in external objects. */ | |
12 | Elf_Internal_Verdef *verdef; | |
13 | ||
2b1d2907 PS |
14 | diff -uNr binutils-2.15.94.0.2.2.orig/bfd/elf.c binutils-2.15.94.0.2.2/bfd/elf.c |
15 | --- binutils-2.15.94.0.2.2.orig/bfd/elf.c 2005-02-07 20:42:44.000000000 +0100 | |
16 | +++ binutils-2.15.94.0.2.2/bfd/elf.c 2005-02-20 13:13:17.397552880 +0100 | |
17 | @@ -1051,6 +1051,7 @@ | |
60005366 PS |
18 | case PT_GNU_EH_FRAME: pt = "EH_FRAME"; break; |
19 | case PT_GNU_STACK: pt = "STACK"; break; | |
0a05c5c3 | 20 | case PT_GNU_RELRO: pt = "RELRO"; break; |
60005366 PS |
21 | + case PT_PAX_FLAGS: pt = "PAX_FLAGS"; break; |
22 | default: sprintf (buf, "0x%lx", p->p_type); pt = buf; break; | |
23 | } | |
24 | fprintf (f, "%8s off 0x", pt); | |
2b1d2907 | 25 | @@ -2400,6 +2401,9 @@ |
0a05c5c3 JB |
26 | case PT_GNU_RELRO: |
27 | return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "relro"); | |
60005366 PS |
28 | |
29 | + case PT_PAX_FLAGS: | |
30 | + return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "pax_flags"); | |
31 | + | |
32 | default: | |
33 | /* Check for any processor-specific program segment types. | |
34 | If no handler for them, default to making "segment" sections. */ | |
2b1d2907 | 35 | @@ -3748,6 +3752,20 @@ |
60005366 PS |
36 | pm = &m->next; |
37 | } | |
38 | ||
39 | + { | |
40 | + amt = sizeof (struct elf_segment_map); | |
41 | + m = bfd_zalloc (abfd, amt); | |
42 | + if (m == NULL) | |
43 | + goto error_return; | |
44 | + m->next = NULL; | |
45 | + m->p_type = PT_PAX_FLAGS; | |
46 | + m->p_flags = elf_tdata (abfd)->pax_flags; | |
47 | + m->p_flags_valid = 1; | |
48 | + | |
49 | + *pm = m; | |
50 | + pm = &m->next; | |
51 | + } | |
52 | + | |
53 | free (sections); | |
54 | sections = NULL; | |
55 | ||
2b1d2907 | 56 | @@ -4446,6 +4464,11 @@ |
60005366 PS |
57 | ++segs; |
58 | } | |
59 | ||
60 | + { | |
61 | + /* We need a PT_PAX_FLAGS segment. */ | |
62 | + ++segs; | |
63 | + } | |
64 | + | |
65 | for (s = abfd->sections; s != NULL; s = s->next) | |
66 | { | |
67 | if ((s->flags & SEC_LOAD) != 0 | |
2b1d2907 PS |
68 | @@ -4989,7 +5012,8 @@ |
69 | 4. The section has not already been allocated to a previous segment. | |
70 | 5. PT_GNU_STACK segments do not include any sections. | |
71 | 6. PT_TLS segment includes only SHF_TLS sections. | |
72 | - 7. SHF_TLS sections are only in PT_TLS or PT_LOAD segments. */ | |
73 | + 7. SHF_TLS sections are only in PT_TLS or PT_LOAD segments. | |
74 | + 8. PT_PAX_FLAGS segments do not include any sections. */ | |
75 | #define INCLUDE_SECTION_IN_SEGMENT(section, segment, bed) \ | |
76 | ((((segment->p_paddr \ | |
77 | ? IS_CONTAINED_BY_LMA (section, segment, segment->p_paddr) \ | |
78 | @@ -4998,6 +5022,7 @@ | |
60005366 PS |
79 | || IS_COREFILE_NOTE (segment, section)) \ |
80 | && section->output_section != NULL \ | |
81 | && segment->p_type != PT_GNU_STACK \ | |
82 | + && segment->p_type != PT_PAX_FLAGS \ | |
83 | && (segment->p_type != PT_TLS \ | |
84 | || (section->flags & SEC_THREAD_LOCAL)) \ | |
85 | && (segment->p_type == PT_LOAD \ | |
2b1d2907 PS |
86 | diff -uNr binutils-2.15.94.0.2.2.orig/bfd/elflink.c binutils-2.15.94.0.2.2/bfd/elflink.c |
87 | --- binutils-2.15.94.0.2.2.orig/bfd/elflink.c 2005-02-07 20:42:44.000000000 +0100 | |
88 | +++ binutils-2.15.94.0.2.2/bfd/elflink.c 2005-02-20 13:13:17.432547560 +0100 | |
89 | @@ -4757,17 +4757,31 @@ | |
90 | if (!is_elf_hash_table (info->hash)) | |
60005366 PS |
91 | return TRUE; |
92 | ||
93 | + elf_tdata (output_bfd)->pax_flags = PF_NORANDEXEC; | |
94 | + | |
95 | + if (info->execheap) | |
96 | + elf_tdata (output_bfd)->pax_flags |= PF_NOMPROTECT; | |
97 | + else if (info->noexecheap) | |
98 | + elf_tdata (output_bfd)->pax_flags |= PF_MPROTECT; | |
99 | + | |
2b1d2907 | 100 | elf_tdata (output_bfd)->relro = info->relro; |
60005366 | 101 | if (info->execstack) |
2b1d2907 PS |
102 | - elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X; |
103 | + { | |
104 | + elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X; | |
105 | + elf_tdata (output_bfd)->pax_flags |= PF_EMUTRAMP; | |
106 | + } | |
60005366 | 107 | else if (info->noexecstack) |
2b1d2907 PS |
108 | - elf_tdata (output_bfd)->stack_flags = PF_R | PF_W; |
109 | + { | |
110 | + elf_tdata (output_bfd)->stack_flags = PF_R | PF_W; | |
111 | + elf_tdata (output_bfd)->pax_flags |= PF_NOEMUTRAMP; | |
112 | + } | |
60005366 PS |
113 | else |
114 | { | |
115 | bfd *inputobj; | |
116 | asection *notesec = NULL; | |
117 | int exec = 0; | |
118 | ||
119 | + elf_tdata (output_bfd)->pax_flags |= PF_NOEMUTRAMP; | |
120 | for (inputobj = info->input_bfds; | |
121 | inputobj; | |
122 | inputobj = inputobj->link_next) | |
2b1d2907 | 123 | @@ -4780,7 +4794,11 @@ |
60005366 PS |
124 | if (s) |
125 | { | |
126 | if (s->flags & SEC_CODE) | |
127 | - exec = PF_X; | |
128 | + { | |
129 | + elf_tdata (output_bfd)->pax_flags &= ~PF_NOEMUTRAMP; | |
130 | + elf_tdata (output_bfd)->pax_flags |= PF_EMUTRAMP; | |
131 | + exec = PF_X; | |
132 | + } | |
133 | notesec = s; | |
134 | } | |
135 | else | |
2b1d2907 PS |
136 | diff -uNr binutils-2.15.94.0.2.2.orig/binutils/readelf.c binutils-2.15.94.0.2.2/binutils/readelf.c |
137 | --- binutils-2.15.94.0.2.2.orig/binutils/readelf.c 2005-02-18 07:14:30.000000000 +0100 | |
138 | +++ binutils-2.15.94.0.2.2/binutils/readelf.c 2005-02-20 13:13:17.470541784 +0100 | |
139 | @@ -2293,6 +2293,7 @@ | |
60005366 | 140 | return "GNU_EH_FRAME"; |
2b1d2907 | 141 | case PT_GNU_STACK: return "GNU_STACK"; |
0a05c5c3 | 142 | case PT_GNU_RELRO: return "GNU_RELRO"; |
60005366 PS |
143 | + case PT_PAX_FLAGS: return "PAX_FLAGS"; |
144 | ||
145 | default: | |
146 | if ((p_type >= PT_LOPROC) && (p_type <= PT_HIPROC)) | |
2b1d2907 PS |
147 | diff -uNr binutils-2.15.94.0.2.2.orig/include/bfdlink.h binutils-2.15.94.0.2.2/include/bfdlink.h |
148 | --- binutils-2.15.94.0.2.2.orig/include/bfdlink.h 2004-11-22 21:33:32.000000000 +0100 | |
149 | +++ binutils-2.15.94.0.2.2/include/bfdlink.h 2005-02-20 13:13:17.476540872 +0100 | |
150 | @@ -313,6 +313,14 @@ | |
60005366 PS |
151 | flags. */ |
152 | unsigned int noexecstack: 1; | |
153 | ||
154 | + /* TRUE if PT_PAX_FLAGS segment should be created with PF_NOMPROTECT | |
155 | + flags. */ | |
156 | + unsigned int execheap: 1; | |
157 | + | |
158 | + /* TRUE if PT_PAX_FLAGS segment should be created with PF_MPROTECT | |
159 | + flags. */ | |
160 | + unsigned int noexecheap: 1; | |
161 | + | |
2b1d2907 PS |
162 | /* TRUE if PT_GNU_RELRO segment should be created. */ |
163 | unsigned int relro: 1; | |
164 | ||
165 | diff -uNr binutils-2.15.94.0.2.2.orig/include/elf/common.h binutils-2.15.94.0.2.2/include/elf/common.h | |
166 | --- binutils-2.15.94.0.2.2.orig/include/elf/common.h 2004-11-22 21:33:32.000000000 +0100 | |
167 | +++ binutils-2.15.94.0.2.2/include/elf/common.h 2005-02-20 13:13:17.482539960 +0100 | |
168 | @@ -293,12 +293,27 @@ | |
169 | #define PT_SUNW_EH_FRAME PT_GNU_EH_FRAME /* Solaris uses the same value */ | |
0a05c5c3 JB |
170 | #define PT_GNU_STACK (PT_LOOS + 0x474e551) /* Stack flags */ |
171 | #define PT_GNU_RELRO (PT_LOOS + 0x474e552) /* Read-only after relocation */ | |
2b1d2907 | 172 | +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580) /* PaX flags */ |
60005366 PS |
173 | |
174 | /* Program segment permissions, in program header p_flags field. */ | |
175 | ||
176 | #define PF_X (1 << 0) /* Segment is executable */ | |
177 | #define PF_W (1 << 1) /* Segment is writable */ | |
178 | #define PF_R (1 << 2) /* Segment is readable */ | |
179 | + | |
180 | +#define PF_PAGEEXEC (1 << 4) /* Enable PAGEEXEC */ | |
181 | +#define PF_NOPAGEEXEC (1 << 5) /* Disable PAGEEXEC */ | |
182 | +#define PF_SEGMEXEC (1 << 6) /* Enable SEGMEXEC */ | |
183 | +#define PF_NOSEGMEXEC (1 << 7) /* Disable SEGMEXEC */ | |
184 | +#define PF_MPROTECT (1 << 8) /* Enable MPROTECT */ | |
185 | +#define PF_NOMPROTECT (1 << 9) /* Disable MPROTECT */ | |
186 | +#define PF_RANDEXEC (1 << 10) /* Enable RANDEXEC */ | |
187 | +#define PF_NORANDEXEC (1 << 11) /* Disable RANDEXEC */ | |
188 | +#define PF_EMUTRAMP (1 << 12) /* Enable EMUTRAMP */ | |
189 | +#define PF_NOEMUTRAMP (1 << 13) /* Disable EMUTRAMP */ | |
190 | +#define PF_RANDMMAP (1 << 14) /* Enable RANDMMAP */ | |
191 | +#define PF_NORANDMMAP (1 << 15) /* Disable RANDMMAP */ | |
192 | + | |
193 | /* #define PF_MASKOS 0x0F000000 *//* OS-specific reserved bits */ | |
194 | #define PF_MASKOS 0x0FF00000 /* New value, Oct 4, 1999 Draft */ | |
195 | #define PF_MASKPROC 0xF0000000 /* Processor-specific reserved bits */ | |
2b1d2907 PS |
196 | diff -uNr binutils-2.15.94.0.2.2.orig/ld/emultempl/elf32.em binutils-2.15.94.0.2.2/ld/emultempl/elf32.em |
197 | --- binutils-2.15.94.0.2.2.orig/ld/emultempl/elf32.em 2004-11-22 21:33:33.000000000 +0100 | |
198 | +++ binutils-2.15.94.0.2.2/ld/emultempl/elf32.em 2005-02-20 13:13:17.492538440 +0100 | |
199 | @@ -1689,6 +1689,16 @@ | |
200 | link_info.noexecstack = TRUE; | |
201 | link_info.execstack = FALSE; | |
202 | } | |
203 | + else if (strcmp (optarg, "execheap") == 0) | |
60005366 PS |
204 | + { |
205 | + link_info.execheap = TRUE; | |
206 | + link_info.noexecheap = FALSE; | |
207 | + } | |
208 | + else if (strcmp (optarg, "noexecheap") == 0) | |
209 | + { | |
210 | + link_info.noexecheap = TRUE; | |
211 | + link_info.execheap = FALSE; | |
212 | + } | |
2b1d2907 PS |
213 | else if (strcmp (optarg, "relro") == 0) |
214 | link_info.relro = TRUE; | |
215 | else if (strcmp (optarg, "norelro") == 0) | |
216 | @@ -1729,6 +1739,7 @@ | |
60005366 PS |
217 | fprintf (file, _(" -z combreloc\t\tMerge dynamic relocs into one section and sort\n")); |
218 | fprintf (file, _(" -z defs\t\tReport unresolved symbols in object files.\n")); | |
219 | fprintf (file, _(" -z execstack\t\tMark executable as requiring executable stack\n")); | |
220 | + fprintf (file, _(" -z execheap\t\tMark executable as requiring executable heap\n")); | |
221 | fprintf (file, _(" -z initfirst\t\tMark DSO to be initialized first at runtime\n")); | |
222 | fprintf (file, _(" -z interpose\t\tMark object to interpose all DSOs but executable\n")); | |
223 | fprintf (file, _(" -z loadfltr\t\tMark object requiring immediate process\n")); | |
2b1d2907 | 224 | @@ -1740,6 +1751,7 @@ |
60005366 PS |
225 | fprintf (file, _(" -z nodlopen\t\tMark DSO not available to dlopen\n")); |
226 | fprintf (file, _(" -z nodump\t\tMark DSO not available to dldump\n")); | |
227 | fprintf (file, _(" -z noexecstack\tMark executable as not requiring executable stack\n")); | |
2b1d2907 | 228 | + fprintf (file, _(" -z noexecheap\tMark executable as not requiring executable heap\n")); |
0a05c5c3 | 229 | fprintf (file, _(" -z norelro\t\tDon't create RELRO program header\n")); |
60005366 PS |
230 | fprintf (file, _(" -z now\t\tMark object non-lazy runtime binding\n")); |
231 | fprintf (file, _(" -z origin\t\tMark object requiring immediate \$ORIGIN processing\n\t\t\t at runtime\n")); | |
2b1d2907 PS |
232 | diff -uNr binutils-2.15.94.0.2.2.orig/ld/ldgram.y binutils-2.15.94.0.2.2/ld/ldgram.y |
233 | --- binutils-2.15.94.0.2.2.orig/ld/ldgram.y 2004-11-22 21:33:32.000000000 +0100 | |
234 | +++ binutils-2.15.94.0.2.2/ld/ldgram.y 2005-02-20 13:13:17.499537376 +0100 | |
235 | @@ -1073,6 +1073,8 @@ | |
60005366 PS |
236 | $$ = exp_intop (0x6474e550); |
237 | else if (strcmp (s, "PT_GNU_STACK") == 0) | |
238 | $$ = exp_intop (0x6474e551); | |
239 | + else if (strcmp (s, "PT_PAX_FLAGS") == 0) | |
240 | + $$ = exp_intop (0x65041580); | |
241 | else | |
242 | { | |
243 | einfo (_("\ |