]> git.pld-linux.org Git - packages/binutils.git/blame - binutils-pt_pax_flags.patch
- obsolete
[packages/binutils.git] / binutils-pt_pax_flags.patch
CommitLineData
60005366
PS
1diff -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
4@@ -1225,6 +1225,9 @@
5 /* Segment flags for the PT_GNU_STACK segment. */
6 unsigned int stack_flags;
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
14diff -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
17@@ -968,6 +968,7 @@
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;
23 }
24 fprintf (f, "%8s off 0x", pt);
25@@ -2292,6 +2293,9 @@
26 case PT_GNU_STACK:
27 return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "stack");
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. */
35@@ -3502,6 +3506,20 @@
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
56@@ -4123,6 +4141,11 @@
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
68@@ -4672,6 +4695,7 @@
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 \
eb6f6ce5
JB
76--- binutils-2.15.90.0.3.orig/bfd/elflink.c 2004-03-03 21:24:33.000000000 +0100
77+++ binutils-2.15.90.0.3/bfd/elflink.c 2004-03-17 12:05:53.403279776 +0100
60005366
PS
78@@ -1654,16 +1654,30 @@
79 if (!is_elf_hash_table (info->hash))
80 return TRUE;
81
82+ elf_tdata (output_bfd)->pax_flags = PF_NORANDEXEC;
83+
84+ if (info->execheap)
85+ elf_tdata (output_bfd)->pax_flags |= PF_NOMPROTECT;
86+ else if (info->noexecheap)
87+ elf_tdata (output_bfd)->pax_flags |= PF_MPROTECT;
88+
89 if (info->execstack)
90+ {
91 elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X;
92+ elf_tdata (output_bfd)->pax_flags |= PF_EMUTRAMP;
93+ }
94 else if (info->noexecstack)
95+ {
96 elf_tdata (output_bfd)->stack_flags = PF_R | PF_W;
97+ elf_tdata (output_bfd)->pax_flags |= PF_NOEMUTRAMP;
98+ }
99 else
100 {
101 bfd *inputobj;
102 asection *notesec = NULL;
103 int exec = 0;
104
105+ elf_tdata (output_bfd)->pax_flags |= PF_NOEMUTRAMP;
106 for (inputobj = info->input_bfds;
107 inputobj;
108 inputobj = inputobj->link_next)
109@@ -1676,7 +1690,11 @@
110 if (s)
111 {
112 if (s->flags & SEC_CODE)
113- exec = PF_X;
114+ {
115+ elf_tdata (output_bfd)->pax_flags &= ~PF_NOEMUTRAMP;
116+ elf_tdata (output_bfd)->pax_flags |= PF_EMUTRAMP;
117+ exec = PF_X;
118+ }
119 notesec = s;
120 }
121 else
122diff -uNr binutils-2.15.90.0.1.1.orig/binutils/readelf.c binutils-2.15.90.0.1.1/binutils/readelf.c
123--- binutils-2.15.90.0.1.1.orig/binutils/readelf.c 2004-03-03 21:24:34.000000000 +0100
124+++ binutils-2.15.90.0.1.1/binutils/readelf.c 2004-03-17 12:07:27.989900424 +0100
125@@ -2144,6 +2144,7 @@
126 case PT_GNU_EH_FRAME:
127 return "GNU_EH_FRAME";
128 case PT_GNU_STACK: return "STACK";
129+ case PT_PAX_FLAGS: return "PAX_FLAGS";
130
131 default:
132 if ((p_type >= PT_LOPROC) && (p_type <= PT_HIPROC))
133diff -uNr binutils-2.15.90.0.1.1.orig/include/bfdlink.h binutils-2.15.90.0.1.1/include/bfdlink.h
134--- binutils-2.15.90.0.1.1.orig/include/bfdlink.h 2004-01-14 22:07:51.000000000 +0100
135+++ binutils-2.15.90.0.1.1/include/bfdlink.h 2004-03-17 11:51:21.109888528 +0100
136@@ -302,6 +302,14 @@
137 flags. */
138 unsigned int noexecstack: 1;
139
140+ /* TRUE if PT_PAX_FLAGS segment should be created with PF_NOMPROTECT
141+ flags. */
142+ unsigned int execheap: 1;
143+
144+ /* TRUE if PT_PAX_FLAGS segment should be created with PF_MPROTECT
145+ flags. */
146+ unsigned int noexecheap: 1;
147+
148 /* What to do with unresolved symbols in an object file.
149 When producing static binaries the default is GENERATE_ERROR.
150 When producing dynamic binaries the default is IGNORE. The
151diff -uNr binutils-2.15.90.0.1.1.orig/include/elf/common.h binutils-2.15.90.0.1.1/include/elf/common.h
152--- binutils-2.15.90.0.1.1.orig/include/elf/common.h 2004-03-03 21:24:34.000000000 +0100
153+++ binutils-2.15.90.0.1.1/include/elf/common.h 2004-03-17 11:55:02.074296832 +0100
154@@ -289,12 +289,27 @@
155
156 #define PT_GNU_EH_FRAME (PT_LOOS + 0x474e550)
157 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
158+#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
159
160 /* Program segment permissions, in program header p_flags field. */
161
162 #define PF_X (1 << 0) /* Segment is executable */
163 #define PF_W (1 << 1) /* Segment is writable */
164 #define PF_R (1 << 2) /* Segment is readable */
165+
166+#define PF_PAGEEXEC (1 << 4) /* Enable PAGEEXEC */
167+#define PF_NOPAGEEXEC (1 << 5) /* Disable PAGEEXEC */
168+#define PF_SEGMEXEC (1 << 6) /* Enable SEGMEXEC */
169+#define PF_NOSEGMEXEC (1 << 7) /* Disable SEGMEXEC */
170+#define PF_MPROTECT (1 << 8) /* Enable MPROTECT */
171+#define PF_NOMPROTECT (1 << 9) /* Disable MPROTECT */
172+#define PF_RANDEXEC (1 << 10) /* Enable RANDEXEC */
173+#define PF_NORANDEXEC (1 << 11) /* Disable RANDEXEC */
174+#define PF_EMUTRAMP (1 << 12) /* Enable EMUTRAMP */
175+#define PF_NOEMUTRAMP (1 << 13) /* Disable EMUTRAMP */
176+#define PF_RANDMMAP (1 << 14) /* Enable RANDMMAP */
177+#define PF_NORANDMMAP (1 << 15) /* Disable RANDMMAP */
178+
179 /* #define PF_MASKOS 0x0F000000 *//* OS-specific reserved bits */
180 #define PF_MASKOS 0x0FF00000 /* New value, Oct 4, 1999 Draft */
181 #define PF_MASKPROC 0xF0000000 /* Processor-specific reserved bits */
182diff -uNr binutils-2.15.90.0.1.1.orig/ld/emultempl/elf32.em binutils-2.15.90.0.1.1/ld/emultempl/elf32.em
183--- binutils-2.15.90.0.1.1.orig/ld/emultempl/elf32.em 2004-01-14 22:07:53.000000000 +0100
184+++ binutils-2.15.90.0.1.1/ld/emultempl/elf32.em 2004-03-17 12:12:08.072321424 +0100
185@@ -1645,6 +1645,16 @@
186 link_info.noexecstack = TRUE;
187 link_info.execstack = FALSE;
188 }
189+ else if (strcmp (optarg, "execheap") == 0)
190+ {
191+ link_info.execheap = TRUE;
192+ link_info.noexecheap = FALSE;
193+ }
194+ else if (strcmp (optarg, "noexecheap") == 0)
195+ {
196+ link_info.noexecheap = TRUE;
197+ link_info.execheap = FALSE;
198+ }
199 /* What about the other Solaris -z options? FIXME. */
200 break;
201 EOF
202@@ -1681,6 +1691,7 @@
203 fprintf (file, _(" -z combreloc\t\tMerge dynamic relocs into one section and sort\n"));
204 fprintf (file, _(" -z defs\t\tReport unresolved symbols in object files.\n"));
205 fprintf (file, _(" -z execstack\t\tMark executable as requiring executable stack\n"));
206+ fprintf (file, _(" -z execheap\t\tMark executable as requiring executable heap\n"));
207 fprintf (file, _(" -z initfirst\t\tMark DSO to be initialized first at runtime\n"));
208 fprintf (file, _(" -z interpose\t\tMark object to interpose all DSOs but executable\n"));
209 fprintf (file, _(" -z loadfltr\t\tMark object requiring immediate process\n"));
210@@ -1692,6 +1703,7 @@
211 fprintf (file, _(" -z nodlopen\t\tMark DSO not available to dlopen\n"));
212 fprintf (file, _(" -z nodump\t\tMark DSO not available to dldump\n"));
213 fprintf (file, _(" -z noexecstack\tMark executable as not requiring executable stack\n"));
214+ fprintf (file, _(" -z noexecheap\t\tMark executable as not requiring executable heap\n"));
215 fprintf (file, _(" -z now\t\tMark object non-lazy runtime binding\n"));
216 fprintf (file, _(" -z origin\t\tMark object requiring immediate \$ORIGIN processing\n\t\t\t at runtime\n"));
217 fprintf (file, _(" -z KEYWORD\t\tIgnored for Solaris compatibility\n"));
218diff -uNr binutils-2.15.90.0.1.1.orig/ld/ldgram.y binutils-2.15.90.0.1.1/ld/ldgram.y
219--- binutils-2.15.90.0.1.1.orig/ld/ldgram.y 2004-03-03 21:24:34.000000000 +0100
220+++ binutils-2.15.90.0.1.1/ld/ldgram.y 2004-03-17 11:51:21.123886400 +0100
221@@ -1019,6 +1019,8 @@
222 $$ = exp_intop (0x6474e550);
223 else if (strcmp (s, "PT_GNU_STACK") == 0)
224 $$ = exp_intop (0x6474e551);
225+ else if (strcmp (s, "PT_PAX_FLAGS") == 0)
226+ $$ = exp_intop (0x65041580);
227 else
228 {
229 einfo (_("\
This page took 0.088158 seconds and 4 git commands to generate.