]> git.pld-linux.org Git - packages/crossppc-binutils.git/blame - binutils-pt_pax_flags.patch
- degrade it to warning once again (C++ problems in gcc without comdat support)
[packages/crossppc-binutils.git] / binutils-pt_pax_flags.patch
CommitLineData
ac02597b
PS
1diff -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;
af80d06b
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
ac02597b
PS
14diff -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
139ae873 17@@ -1028,6 +1028,7 @@
af80d06b
PS
18 case PT_GNU_EH_FRAME: pt = "EH_FRAME"; break;
19 case PT_GNU_STACK: pt = "STACK"; break;
f50e652f 20 case PT_GNU_RELRO: pt = "RELRO"; break;
af80d06b
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);
139ae873 25@@ -2376,6 +2377,9 @@
f50e652f
JB
26 case PT_GNU_RELRO:
27 return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "relro");
af80d06b
PS
28
29+ case PT_PAX_FLAGS:
30+ return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "pax_flags");
31+
32 default:
139ae873
PS
33 /* Check for any processor-specific program segment types. */
34 bed = get_elf_backend_data (abfd);
35@@ -3720,6 +3724,20 @@
af80d06b
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
139ae873 56@@ -4424,6 +4442,11 @@
af80d06b
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
139ae873 68@@ -4958,7 +4981,8 @@
ac02597b
PS
69 5. PT_GNU_STACK segments do not include any sections.
70 6. PT_TLS segment includes only SHF_TLS sections.
139ae873
PS
71 7. SHF_TLS sections are only in PT_TLS or PT_LOAD segments.
72- 8. PT_DYNAMIC should not contain empty sections at the beginning
73+ 8. PT_PAX_FLAGS segments do not include any sections.
74+ 9. PT_DYNAMIC should not contain empty sections at the beginning
75 (with the possible exception of .dynamic). */
ac02597b
PS
76 #define INCLUDE_SECTION_IN_SEGMENT(section, segment, bed) \
77 ((((segment->p_paddr \
139ae873 78@@ -4968,6 +4992,7 @@
af80d06b
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 \
ac02597b
PS
86diff -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))
af80d06b
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+
ac02597b 100 elf_tdata (output_bfd)->relro = info->relro;
af80d06b 101 if (info->execstack)
ac02597b
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+ }
af80d06b 107 else if (info->noexecstack)
ac02597b
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+ }
af80d06b
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)
ac02597b 123@@ -4780,7 +4794,11 @@
af80d06b
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
ac02597b
PS
136diff -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 @@
af80d06b 140 return "GNU_EH_FRAME";
ac02597b 141 case PT_GNU_STACK: return "GNU_STACK";
f50e652f 142 case PT_GNU_RELRO: return "GNU_RELRO";
af80d06b
PS
143+ case PT_PAX_FLAGS: return "PAX_FLAGS";
144
145 default:
146 if ((p_type >= PT_LOPROC) && (p_type <= PT_HIPROC))
ac02597b
PS
147diff -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 @@
af80d06b
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+
ac02597b
PS
162 /* TRUE if PT_GNU_RELRO segment should be created. */
163 unsigned int relro: 1;
164
165diff -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 */
f50e652f
JB
170 #define PT_GNU_STACK (PT_LOOS + 0x474e551) /* Stack flags */
171 #define PT_GNU_RELRO (PT_LOOS + 0x474e552) /* Read-only after relocation */
ac02597b 172+#define PT_PAX_FLAGS (PT_LOOS + 0x5041580) /* PaX flags */
af80d06b
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 */
ac02597b
PS
196diff -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)
af80d06b
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+ }
ac02597b
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 @@
af80d06b
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"));
ac02597b 224@@ -1740,6 +1751,7 @@
af80d06b
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"));
ac02597b 228+ fprintf (file, _(" -z noexecheap\tMark executable as not requiring executable heap\n"));
f50e652f 229 fprintf (file, _(" -z norelro\t\tDon't create RELRO program header\n"));
af80d06b
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"));
ac02597b
PS
232diff -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 @@
af80d06b
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 (_("\
This page took 0.172553 seconds and 4 git commands to generate.