Mercurial > emacs
comparison src/unexelf.c @ 48592:d2f5d3e1c0cc
Comments.
author | Dave Love <fx@gnu.org> |
---|---|
date | Fri, 29 Nov 2002 16:57:43 +0000 |
parents | d43916bc2d4f |
children | 2710810008b2 d7ddb3e565de |
comparison
equal
deleted
inserted
replaced
48591:afd7191c989c | 48592:d2f5d3e1c0cc |
---|---|
87 raid:/nfs/raid/src/dist-18.56/src> dump -h temacs | 87 raid:/nfs/raid/src/dist-18.56/src> dump -h temacs |
88 | 88 |
89 temacs: | 89 temacs: |
90 | 90 |
91 **** SECTION HEADER TABLE **** | 91 **** SECTION HEADER TABLE **** |
92 [No] Type Flags Addr Offset Size Name | 92 [No] Type Flags Addr Offset Size Name |
93 Link Info Adralgn Entsize | 93 Link Info Adralgn Entsize |
94 | 94 |
95 [1] 1 2 0x80480d4 0xd4 0x13 .interp | 95 [1] 1 2 0x80480d4 0xd4 0x13 .interp |
96 0 0 0x1 0 | 96 0 0 0x1 0 |
97 | 97 |
98 [2] 5 2 0x80480e8 0xe8 0x388 .hash | 98 [2] 5 2 0x80480e8 0xe8 0x388 .hash |
99 3 0 0x4 0x4 | 99 3 0 0x4 0x4 |
100 | 100 |
101 [3] 11 2 0x8048470 0x470 0x7f0 .dynsym | 101 [3] 11 2 0x8048470 0x470 0x7f0 .dynsym |
102 4 1 0x4 0x10 | 102 4 1 0x4 0x10 |
103 | 103 |
104 [4] 3 2 0x8048c60 0xc60 0x3ad .dynstr | 104 [4] 3 2 0x8048c60 0xc60 0x3ad .dynstr |
105 0 0 0x1 0 | 105 0 0 0x1 0 |
106 | 106 |
107 [5] 9 2 0x8049010 0x1010 0x338 .rel.plt | 107 [5] 9 2 0x8049010 0x1010 0x338 .rel.plt |
108 3 7 0x4 0x8 | 108 3 7 0x4 0x8 |
109 | 109 |
110 [6] 1 6 0x8049348 0x1348 0x3 .init | 110 [6] 1 6 0x8049348 0x1348 0x3 .init |
111 0 0 0x4 0 | 111 0 0 0x4 0 |
112 | 112 |
113 [7] 1 6 0x804934c 0x134c 0x680 .plt | 113 [7] 1 6 0x804934c 0x134c 0x680 .plt |
114 0 0 0x4 0x4 | 114 0 0 0x4 0x4 |
115 | 115 |
116 [8] 1 6 0x80499cc 0x19cc 0x3c56f .text | 116 [8] 1 6 0x80499cc 0x19cc 0x3c56f .text |
117 0 0 0x4 0 | 117 0 0 0x4 0 |
118 | 118 |
119 [9] 1 6 0x8085f3c 0x3df3c 0x3 .fini | 119 [9] 1 6 0x8085f3c 0x3df3c 0x3 .fini |
120 0 0 0x4 0 | 120 0 0 0x4 0 |
121 | 121 |
122 [10] 1 2 0x8085f40 0x3df40 0x69c .rodata | 122 [10] 1 2 0x8085f40 0x3df40 0x69c .rodata |
123 0 0 0x4 0 | 123 0 0 0x4 0 |
124 | 124 |
125 [11] 1 2 0x80865dc 0x3e5dc 0xd51 .rodata1 | 125 [11] 1 2 0x80865dc 0x3e5dc 0xd51 .rodata1 |
126 0 0 0x4 0 | 126 0 0 0x4 0 |
127 | 127 |
128 [12] 1 3 0x8088330 0x3f330 0x20afc .data | 128 [12] 1 3 0x8088330 0x3f330 0x20afc .data |
129 0 0 0x4 0 | 129 0 0 0x4 0 |
130 | 130 |
131 [13] 1 3 0x80a8e2c 0x5fe2c 0x89d .data1 | 131 [13] 1 3 0x80a8e2c 0x5fe2c 0x89d .data1 |
132 0 0 0x4 0 | 132 0 0 0x4 0 |
133 | 133 |
134 [14] 1 3 0x80a96cc 0x606cc 0x1a8 .got | 134 [14] 1 3 0x80a96cc 0x606cc 0x1a8 .got |
135 0 0 0x4 0x4 | 135 0 0 0x4 0x4 |
136 | 136 |
137 [15] 6 3 0x80a9874 0x60874 0x80 .dynamic | 137 [15] 6 3 0x80a9874 0x60874 0x80 .dynamic |
138 4 0 0x4 0x8 | 138 4 0 0x4 0x8 |
139 | 139 |
140 [16] 8 3 0x80a98f4 0x608f4 0x449c .bss | 140 [16] 8 3 0x80a98f4 0x608f4 0x449c .bss |
141 0 0 0x4 0 | 141 0 0 0x4 0 |
142 | 142 |
143 [17] 2 0 0 0x608f4 0x9b90 .symtab | 143 [17] 2 0 0 0x608f4 0x9b90 .symtab |
144 18 371 0x4 0x10 | 144 18 371 0x4 0x10 |
145 | 145 |
146 [18] 3 0 0 0x6a484 0x8526 .strtab | 146 [18] 3 0 0 0x6a484 0x8526 .strtab |
147 0 0 0x1 0 | 147 0 0 0x1 0 |
148 | 148 |
149 [19] 3 0 0 0x729aa 0x93 .shstrtab | 149 [19] 3 0 0 0x729aa 0x93 .shstrtab |
150 0 0 0x1 0 | 150 0 0 0x1 0 |
151 | 151 |
152 [20] 1 0 0 0x72a3d 0x68b7 .comment | 152 [20] 1 0 0 0x72a3d 0x68b7 .comment |
153 0 0 0x1 0 | 153 0 0 0x1 0 |
154 | 154 |
155 raid:/nfs/raid/src/dist-18.56/src> dump -h xemacs | 155 raid:/nfs/raid/src/dist-18.56/src> dump -h xemacs |
156 | 156 |
157 xemacs: | 157 xemacs: |
158 | 158 |
159 **** SECTION HEADER TABLE **** | 159 **** SECTION HEADER TABLE **** |
160 [No] Type Flags Addr Offset Size Name | 160 [No] Type Flags Addr Offset Size Name |
161 Link Info Adralgn Entsize | 161 Link Info Adralgn Entsize |
162 | 162 |
163 [1] 1 2 0x80480d4 0xd4 0x13 .interp | 163 [1] 1 2 0x80480d4 0xd4 0x13 .interp |
164 0 0 0x1 0 | 164 0 0 0x1 0 |
165 | 165 |
166 [2] 5 2 0x80480e8 0xe8 0x388 .hash | 166 [2] 5 2 0x80480e8 0xe8 0x388 .hash |
167 3 0 0x4 0x4 | 167 3 0 0x4 0x4 |
168 | 168 |
169 [3] 11 2 0x8048470 0x470 0x7f0 .dynsym | 169 [3] 11 2 0x8048470 0x470 0x7f0 .dynsym |
170 4 1 0x4 0x10 | 170 4 1 0x4 0x10 |
171 | 171 |
172 [4] 3 2 0x8048c60 0xc60 0x3ad .dynstr | 172 [4] 3 2 0x8048c60 0xc60 0x3ad .dynstr |
173 0 0 0x1 0 | 173 0 0 0x1 0 |
174 | 174 |
175 [5] 9 2 0x8049010 0x1010 0x338 .rel.plt | 175 [5] 9 2 0x8049010 0x1010 0x338 .rel.plt |
176 3 7 0x4 0x8 | 176 3 7 0x4 0x8 |
177 | 177 |
178 [6] 1 6 0x8049348 0x1348 0x3 .init | 178 [6] 1 6 0x8049348 0x1348 0x3 .init |
179 0 0 0x4 0 | 179 0 0 0x4 0 |
180 | 180 |
181 [7] 1 6 0x804934c 0x134c 0x680 .plt | 181 [7] 1 6 0x804934c 0x134c 0x680 .plt |
182 0 0 0x4 0x4 | 182 0 0 0x4 0x4 |
183 | 183 |
184 [8] 1 6 0x80499cc 0x19cc 0x3c56f .text | 184 [8] 1 6 0x80499cc 0x19cc 0x3c56f .text |
185 0 0 0x4 0 | 185 0 0 0x4 0 |
186 | 186 |
187 [9] 1 6 0x8085f3c 0x3df3c 0x3 .fini | 187 [9] 1 6 0x8085f3c 0x3df3c 0x3 .fini |
188 0 0 0x4 0 | 188 0 0 0x4 0 |
189 | 189 |
190 [10] 1 2 0x8085f40 0x3df40 0x69c .rodata | 190 [10] 1 2 0x8085f40 0x3df40 0x69c .rodata |
191 0 0 0x4 0 | 191 0 0 0x4 0 |
192 | 192 |
193 [11] 1 2 0x80865dc 0x3e5dc 0xd51 .rodata1 | 193 [11] 1 2 0x80865dc 0x3e5dc 0xd51 .rodata1 |
194 0 0 0x4 0 | 194 0 0 0x4 0 |
195 | 195 |
196 [12] 1 3 0x8088330 0x3f330 0x20afc .data | 196 [12] 1 3 0x8088330 0x3f330 0x20afc .data |
197 0 0 0x4 0 | 197 0 0 0x4 0 |
198 | 198 |
199 [13] 1 3 0x80a8e2c 0x5fe2c 0x89d .data1 | 199 [13] 1 3 0x80a8e2c 0x5fe2c 0x89d .data1 |
200 0 0 0x4 0 | 200 0 0 0x4 0 |
201 | 201 |
202 [14] 1 3 0x80a96cc 0x606cc 0x1a8 .got | 202 [14] 1 3 0x80a96cc 0x606cc 0x1a8 .got |
203 0 0 0x4 0x4 | 203 0 0 0x4 0x4 |
204 | 204 |
205 [15] 6 3 0x80a9874 0x60874 0x80 .dynamic | 205 [15] 6 3 0x80a9874 0x60874 0x80 .dynamic |
206 4 0 0x4 0x8 | 206 4 0 0x4 0x8 |
207 | 207 |
208 [16] 8 3 0x80c6800 0x7d800 0 .bss | 208 [16] 8 3 0x80c6800 0x7d800 0 .bss |
209 0 0 0x4 0 | 209 0 0 0x4 0 |
210 | 210 |
211 [17] 2 0 0 0x7d800 0x9b90 .symtab | 211 [17] 2 0 0 0x7d800 0x9b90 .symtab |
212 18 371 0x4 0x10 | 212 18 371 0x4 0x10 |
213 | 213 |
214 [18] 3 0 0 0x87390 0x8526 .strtab | 214 [18] 3 0 0 0x87390 0x8526 .strtab |
215 0 0 0x1 0 | 215 0 0 0x1 0 |
216 | 216 |
217 [19] 3 0 0 0x8f8b6 0x93 .shstrtab | 217 [19] 3 0 0 0x8f8b6 0x93 .shstrtab |
218 0 0 0x1 0 | 218 0 0 0x1 0 |
219 | 219 |
220 [20] 1 0 0 0x8f949 0x68b7 .comment | 220 [20] 1 0 0 0x8f949 0x68b7 .comment |
221 0 0 0x1 0 | 221 0 0 0x1 0 |
222 | 222 |
223 [21] 1 3 0x80a98f4 0x608f4 0x1cf0c .data | 223 [21] 1 3 0x80a98f4 0x608f4 0x1cf0c .data |
224 0 0 0x4 0 | 224 0 0 0x4 0 |
225 | 225 |
226 * This is an example of how the file header is changed. "Shoff" is | 226 * This is an example of how the file header is changed. "Shoff" is |
227 * the section header offset within the file. Since that table is | 227 * the section header offset within the file. Since that table is |
228 * after the new .data section, it is moved. "Shnum" is the number of | 228 * after the new .data section, it is moved. "Shnum" is the number of |
229 * sections, which we increment. | 229 * sections, which we increment. |
230 * | 230 * |
231 * "Phoff" is the file offset to the program header. "Phentsize" and | 231 * "Phoff" is the file offset to the program header. "Phentsize" and |
232 * "Shentsz" are the program and section header entries sizes respectively. | 232 * "Shentsz" are the program and section header entries sizes respectively. |
233 * These can be larger than the apparent struct sizes. | 233 * These can be larger than the apparent struct sizes. |
234 | 234 |
235 raid:/nfs/raid/src/dist-18.56/src> dump -f temacs | 235 raid:/nfs/raid/src/dist-18.56/src> dump -f temacs |
236 | 236 |
237 temacs: | 237 temacs: |
238 | 238 |
239 **** ELF HEADER **** | 239 **** ELF HEADER **** |
240 Class Data Type Machine Version | 240 Class Data Type Machine Version |
241 Entry Phoff Shoff Flags Ehsize | 241 Entry Phoff Shoff Flags Ehsize |
242 Phentsize Phnum Shentsz Shnum Shstrndx | 242 Phentsize Phnum Shentsz Shnum Shstrndx |
243 | 243 |
244 1 1 2 3 1 | 244 1 1 2 3 1 |
245 0x80499cc 0x34 0x792f4 0 0x34 | 245 0x80499cc 0x34 0x792f4 0 0x34 |
246 0x20 5 0x28 21 19 | 246 0x20 5 0x28 21 19 |
247 | 247 |
248 raid:/nfs/raid/src/dist-18.56/src> dump -f xemacs | 248 raid:/nfs/raid/src/dist-18.56/src> dump -f xemacs |
249 | 249 |
250 xemacs: | 250 xemacs: |
251 | 251 |
252 **** ELF HEADER **** | 252 **** ELF HEADER **** |
253 Class Data Type Machine Version | 253 Class Data Type Machine Version |
254 Entry Phoff Shoff Flags Ehsize | 254 Entry Phoff Shoff Flags Ehsize |
255 Phentsize Phnum Shentsz Shnum Shstrndx | 255 Phentsize Phnum Shentsz Shnum Shstrndx |
256 | 256 |
257 1 1 2 3 1 | 257 1 1 2 3 1 |
258 0x80499cc 0x34 0x96200 0 0x34 | 258 0x80499cc 0x34 0x96200 0 0x34 |
259 0x20 5 0x28 22 19 | 259 0x20 5 0x28 22 19 |
260 | 260 |
261 * These are the program headers. "Offset" is the file offset to the | 261 * These are the program headers. "Offset" is the file offset to the |
262 * segment. "Vaddr" is the memory load address. "Filesz" is the | 262 * segment. "Vaddr" is the memory load address. "Filesz" is the |
263 * segment size as it appears in the file, and "Memsz" is the size in | 263 * segment size as it appears in the file, and "Memsz" is the size in |
264 * memory. Below, the third segment is the code and the fourth is the | 264 * memory. Below, the third segment is the code and the fourth is the |
265 * data: the difference between Filesz and Memsz is .bss | 265 * data: the difference between Filesz and Memsz is .bss |
266 | 266 |
267 raid:/nfs/raid/src/dist-18.56/src> dump -o temacs | 267 raid:/nfs/raid/src/dist-18.56/src> dump -o temacs |
268 | 268 |
269 temacs: | 269 temacs: |
270 ***** PROGRAM EXECUTION HEADER ***** | 270 ***** PROGRAM EXECUTION HEADER ***** |
271 Type Offset Vaddr Paddr | 271 Type Offset Vaddr Paddr |
272 Filesz Memsz Flags Align | 272 Filesz Memsz Flags Align |
273 | 273 |
274 6 0x34 0x8048034 0 | 274 6 0x34 0x8048034 0 |
275 0xa0 0xa0 5 0 | 275 0xa0 0xa0 5 0 |
276 | 276 |
277 3 0xd4 0 0 | 277 3 0xd4 0 0 |
278 0x13 0 4 0 | 278 0x13 0 4 0 |
279 | 279 |
280 1 0x34 0x8048034 0 | 280 1 0x34 0x8048034 0 |
281 0x3f2f9 0x3f2f9 5 0x1000 | 281 0x3f2f9 0x3f2f9 5 0x1000 |
282 | 282 |
283 1 0x3f330 0x8088330 0 | 283 1 0x3f330 0x8088330 0 |
284 0x215c4 0x25a60 7 0x1000 | 284 0x215c4 0x25a60 7 0x1000 |
285 | 285 |
286 2 0x60874 0x80a9874 0 | 286 2 0x60874 0x80a9874 0 |
287 0x80 0 7 0 | 287 0x80 0 7 0 |
288 | 288 |
289 raid:/nfs/raid/src/dist-18.56/src> dump -o xemacs | 289 raid:/nfs/raid/src/dist-18.56/src> dump -o xemacs |
290 | 290 |
291 xemacs: | 291 xemacs: |
292 ***** PROGRAM EXECUTION HEADER ***** | 292 ***** PROGRAM EXECUTION HEADER ***** |
293 Type Offset Vaddr Paddr | 293 Type Offset Vaddr Paddr |
294 Filesz Memsz Flags Align | 294 Filesz Memsz Flags Align |
295 | 295 |
296 6 0x34 0x8048034 0 | 296 6 0x34 0x8048034 0 |
297 0xa0 0xa0 5 0 | 297 0xa0 0xa0 5 0 |
298 | 298 |
299 3 0xd4 0 0 | 299 3 0xd4 0 0 |
300 0x13 0 4 0 | 300 0x13 0 4 0 |
301 | 301 |
302 1 0x34 0x8048034 0 | 302 1 0x34 0x8048034 0 |
303 0x3f2f9 0x3f2f9 5 0x1000 | 303 0x3f2f9 0x3f2f9 5 0x1000 |
304 | 304 |
305 1 0x3f330 0x8088330 0 | 305 1 0x3f330 0x8088330 0 |
306 0x3e4d0 0x3e4d0 7 0x1000 | 306 0x3e4d0 0x3e4d0 7 0x1000 |
307 | 307 |
308 2 0x60874 0x80a9874 0 | 308 2 0x60874 0x80a9874 0 |
309 0x80 0 7 0 | 309 0x80 0 7 0 |
310 | 310 |
311 | 311 |
312 */ | 312 */ |
313 | 313 |
314 /* Modified by wtien@urbana.mcd.mot.com of Motorola Inc. | 314 /* Modified by wtien@urbana.mcd.mot.com of Motorola Inc. |
334 * 3. symbol table entry st_shndx field. | 334 * 3. symbol table entry st_shndx field. |
335 * | 335 * |
336 * The above example now should look like: | 336 * The above example now should look like: |
337 | 337 |
338 **** SECTION HEADER TABLE **** | 338 **** SECTION HEADER TABLE **** |
339 [No] Type Flags Addr Offset Size Name | 339 [No] Type Flags Addr Offset Size Name |
340 Link Info Adralgn Entsize | 340 Link Info Adralgn Entsize |
341 | 341 |
342 [1] 1 2 0x80480d4 0xd4 0x13 .interp | 342 [1] 1 2 0x80480d4 0xd4 0x13 .interp |
343 0 0 0x1 0 | 343 0 0 0x1 0 |
344 | 344 |
345 [2] 5 2 0x80480e8 0xe8 0x388 .hash | 345 [2] 5 2 0x80480e8 0xe8 0x388 .hash |
346 3 0 0x4 0x4 | 346 3 0 0x4 0x4 |
347 | 347 |
348 [3] 11 2 0x8048470 0x470 0x7f0 .dynsym | 348 [3] 11 2 0x8048470 0x470 0x7f0 .dynsym |
349 4 1 0x4 0x10 | 349 4 1 0x4 0x10 |
350 | 350 |
351 [4] 3 2 0x8048c60 0xc60 0x3ad .dynstr | 351 [4] 3 2 0x8048c60 0xc60 0x3ad .dynstr |
352 0 0 0x1 0 | 352 0 0 0x1 0 |
353 | 353 |
354 [5] 9 2 0x8049010 0x1010 0x338 .rel.plt | 354 [5] 9 2 0x8049010 0x1010 0x338 .rel.plt |
355 3 7 0x4 0x8 | 355 3 7 0x4 0x8 |
356 | 356 |
357 [6] 1 6 0x8049348 0x1348 0x3 .init | 357 [6] 1 6 0x8049348 0x1348 0x3 .init |
358 0 0 0x4 0 | 358 0 0 0x4 0 |
359 | 359 |
360 [7] 1 6 0x804934c 0x134c 0x680 .plt | 360 [7] 1 6 0x804934c 0x134c 0x680 .plt |
361 0 0 0x4 0x4 | 361 0 0 0x4 0x4 |
362 | 362 |
363 [8] 1 6 0x80499cc 0x19cc 0x3c56f .text | 363 [8] 1 6 0x80499cc 0x19cc 0x3c56f .text |
364 0 0 0x4 0 | 364 0 0 0x4 0 |
365 | 365 |
366 [9] 1 6 0x8085f3c 0x3df3c 0x3 .fini | 366 [9] 1 6 0x8085f3c 0x3df3c 0x3 .fini |
367 0 0 0x4 0 | 367 0 0 0x4 0 |
368 | 368 |
369 [10] 1 2 0x8085f40 0x3df40 0x69c .rodata | 369 [10] 1 2 0x8085f40 0x3df40 0x69c .rodata |
370 0 0 0x4 0 | 370 0 0 0x4 0 |
371 | 371 |
372 [11] 1 2 0x80865dc 0x3e5dc 0xd51 .rodata1 | 372 [11] 1 2 0x80865dc 0x3e5dc 0xd51 .rodata1 |
373 0 0 0x4 0 | 373 0 0 0x4 0 |
374 | 374 |
375 [12] 1 3 0x8088330 0x3f330 0x20afc .data | 375 [12] 1 3 0x8088330 0x3f330 0x20afc .data |
376 0 0 0x4 0 | 376 0 0 0x4 0 |
377 | 377 |
378 [13] 1 3 0x80a8e2c 0x5fe2c 0x89d .data1 | 378 [13] 1 3 0x80a8e2c 0x5fe2c 0x89d .data1 |
379 0 0 0x4 0 | 379 0 0 0x4 0 |
380 | 380 |
381 [14] 1 3 0x80a96cc 0x606cc 0x1a8 .got | 381 [14] 1 3 0x80a96cc 0x606cc 0x1a8 .got |
382 0 0 0x4 0x4 | 382 0 0 0x4 0x4 |
383 | 383 |
384 [15] 6 3 0x80a9874 0x60874 0x80 .dynamic | 384 [15] 6 3 0x80a9874 0x60874 0x80 .dynamic |
385 4 0 0x4 0x8 | 385 4 0 0x4 0x8 |
386 | 386 |
387 [16] 1 3 0x80a98f4 0x608f4 0x1cf0c .data | 387 [16] 1 3 0x80a98f4 0x608f4 0x1cf0c .data |
388 0 0 0x4 0 | 388 0 0 0x4 0 |
389 | 389 |
390 [17] 8 3 0x80c6800 0x7d800 0 .bss | 390 [17] 8 3 0x80c6800 0x7d800 0 .bss |
391 0 0 0x4 0 | 391 0 0 0x4 0 |
392 | 392 |
393 [18] 2 0 0 0x7d800 0x9b90 .symtab | 393 [18] 2 0 0 0x7d800 0x9b90 .symtab |
394 19 371 0x4 0x10 | 394 19 371 0x4 0x10 |
395 | 395 |
396 [19] 3 0 0 0x87390 0x8526 .strtab | 396 [19] 3 0 0 0x87390 0x8526 .strtab |
397 0 0 0x1 0 | 397 0 0 0x1 0 |
398 | 398 |
399 [20] 3 0 0 0x8f8b6 0x93 .shstrtab | 399 [20] 3 0 0 0x8f8b6 0x93 .shstrtab |
400 0 0 0x1 0 | 400 0 0 0x1 0 |
401 | 401 |
402 [21] 1 0 0 0x8f949 0x68b7 .comment | 402 [21] 1 0 0 0x8f949 0x68b7 .comment |
403 0 0 0x1 0 | 403 0 0 0x1 0 |
404 | 404 |
405 */ | 405 */ |
406 | 406 |
407 /* We do not use mmap because that fails with NFS. | 407 /* We do not use mmap because that fails with NFS. |
408 Instead we read the whole file, modify it, and write it out. */ | 408 Instead we read the whole file, modify it, and write it out. */ |
474 long cbSsOffset; | 474 long cbSsOffset; |
475 long cbSsExtOffset; | 475 long cbSsExtOffset; |
476 long cbFdOffset; | 476 long cbFdOffset; |
477 long cbRfdOffset; | 477 long cbRfdOffset; |
478 long cbExtOffset; | 478 long cbExtOffset; |
479 } HDRR, *pHDRR; | 479 } HDRR, *pHDRR; |
480 #define cbHDRR sizeof(HDRR) | 480 #define cbHDRR sizeof(HDRR) |
481 #define hdrNil ((pHDRR)0) | 481 #define hdrNil ((pHDRR)0) |
482 #endif | 482 #endif |
483 | 483 |
484 #ifdef __NetBSD__ | 484 #ifdef __NetBSD__ |
928 nn++; | 928 nn++; |
929 } | 929 } |
930 | 930 |
931 memcpy (&NEW_SECTION_H (nn), &OLD_SECTION_H (n), | 931 memcpy (&NEW_SECTION_H (nn), &OLD_SECTION_H (n), |
932 old_file_h->e_shentsize); | 932 old_file_h->e_shentsize); |
933 | 933 |
934 if (n == old_bss_index | 934 if (n == old_bss_index |
935 /* The new bss and sbss section's size is zero, and its file offset | 935 /* The new bss and sbss section's size is zero, and its file offset |
936 and virtual address should be off by NEW_DATA2_SIZE. */ | 936 and virtual address should be off by NEW_DATA2_SIZE. */ |
937 || n == old_sbss_index | 937 || n == old_sbss_index |
938 ) | 938 ) |
985 /* For symbol tables, info is a symbol table index, | 985 /* For symbol tables, info is a symbol table index, |
986 so don't change it. */ | 986 so don't change it. */ |
987 if (NEW_SECTION_H (nn).sh_type != SHT_SYMTAB | 987 if (NEW_SECTION_H (nn).sh_type != SHT_SYMTAB |
988 && NEW_SECTION_H (nn).sh_type != SHT_DYNSYM) | 988 && NEW_SECTION_H (nn).sh_type != SHT_DYNSYM) |
989 PATCH_INDEX (NEW_SECTION_H (nn).sh_info); | 989 PATCH_INDEX (NEW_SECTION_H (nn).sh_info); |
990 | 990 |
991 if (old_sbss_index != -1) | 991 if (old_sbss_index != -1) |
992 if (!strcmp (old_section_names + NEW_SECTION_H (nn).sh_name, ".sbss")) | 992 if (!strcmp (old_section_names + NEW_SECTION_H (nn).sh_name, ".sbss")) |
993 { | 993 { |
994 NEW_SECTION_H (nn).sh_offset = | 994 NEW_SECTION_H (nn).sh_offset = |
995 round_up (NEW_SECTION_H (nn).sh_offset, | 995 round_up (NEW_SECTION_H (nn).sh_offset, |
996 NEW_SECTION_H (nn).sh_addralign); | 996 NEW_SECTION_H (nn).sh_addralign); |
997 NEW_SECTION_H (nn).sh_type = SHT_PROGBITS; | 997 NEW_SECTION_H (nn).sh_type = SHT_PROGBITS; |
998 } | 998 } |
999 | 999 |
1013 || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), | 1013 || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), |
1014 ".lit8") | 1014 ".lit8") |
1015 /* The conditional bit below was in Oliva's original code | 1015 /* The conditional bit below was in Oliva's original code |
1016 (1999-08-25) and seems to have been dropped by mistake | 1016 (1999-08-25) and seems to have been dropped by mistake |
1017 subsequently. It prevents a crash at startup under X in | 1017 subsequently. It prevents a crash at startup under X in |
1018 `IRIX64 6.5 6.5.17m' with c_dev 7.3.1.3m. It causes no | 1018 `IRIX64 6.5 6.5.17m', whether compiled on that relase or |
1019 trouble on the other ELF platforms I could test (Irix | 1019 an earlier one. It causes no trouble on the other ELF |
1020 6.5.15m, Solaris 8, Debian Potato x86, Debian Woody | 1020 platforms I could test (Irix 6.5.15m, Solaris 8, Debian |
1021 SPARC); however, it's reported to cause crashes under | 1021 Potato x86, Debian Woody SPARC); however, it's reported |
1022 some version of GNU/Linux. It's not yet clear what's | 1022 to cause crashes under some version of GNU/Linux. It's |
1023 changed in that Irix version to cause the problem, or why | 1023 not yet clear what's changed in that Irix version to |
1024 the fix sometimes fails under GNU/Linux. There's | 1024 cause the problem, or why the fix sometimes fails under |
1025 probably no good reason to have something Irix-specific | 1025 GNU/Linux. There's probably no good reason to have |
1026 here, but this will have to do for now. IRIX6_5 is the | 1026 something Irix-specific here, but this will have to do |
1027 most specific macro we have to test. -- fx 2002-10-01 */ | 1027 for now. IRIX6_5 is the most specific macro we have to |
1028 test. -- fx 2002-10-01 | |
1029 | |
1030 The issue _looks_ as though it's gone away on 6.5.18m, | |
1031 but maybe it's still lurking, to be triggered by some | |
1032 change in the binary. It appears to concern the dynamic | |
1033 loader, but I never got anywhere with an SGI support call | |
1034 seeking clues. -- fx 2002-11-29. */ | |
1028 #ifdef IRIX6_5 | 1035 #ifdef IRIX6_5 |
1029 || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), | 1036 || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), |
1030 ".got") | 1037 ".got") |
1031 #endif | 1038 #endif |
1032 || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), | 1039 || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), |
1063 } | 1070 } |
1064 #endif /* __alpha__ */ | 1071 #endif /* __alpha__ */ |
1065 | 1072 |
1066 #if defined (__sony_news) && defined (_SYSTYPE_SYSV) | 1073 #if defined (__sony_news) && defined (_SYSTYPE_SYSV) |
1067 if (NEW_SECTION_H (nn).sh_type == SHT_MIPS_DEBUG | 1074 if (NEW_SECTION_H (nn).sh_type == SHT_MIPS_DEBUG |
1068 && old_mdebug_index != -1) | 1075 && old_mdebug_index != -1) |
1069 { | 1076 { |
1070 int diff = NEW_SECTION_H(nn).sh_offset | 1077 int diff = NEW_SECTION_H(nn).sh_offset |
1071 - OLD_SECTION_H(old_mdebug_index).sh_offset; | 1078 - OLD_SECTION_H(old_mdebug_index).sh_offset; |
1072 HDRR *phdr = (HDRR *)(NEW_SECTION_H (nn).sh_offset + new_base); | 1079 HDRR *phdr = (HDRR *)(NEW_SECTION_H (nn).sh_offset + new_base); |
1073 | 1080 |
1074 if (diff) | 1081 if (diff) |
1075 { | 1082 { |
1087 } | 1094 } |
1088 } | 1095 } |
1089 #endif /* __sony_news && _SYSTYPE_SYSV */ | 1096 #endif /* __sony_news && _SYSTYPE_SYSV */ |
1090 | 1097 |
1091 #if __sgi | 1098 #if __sgi |
1092 /* Adjust the HDRR offsets in .mdebug and copy the | 1099 /* Adjust the HDRR offsets in .mdebug and copy the |
1093 line data if it's in its usual 'hole' in the object. | 1100 line data if it's in its usual 'hole' in the object. |
1094 Makes the new file debuggable with dbx. | 1101 Makes the new file debuggable with dbx. |
1095 patches up two problems: the absolute file offsets | 1102 patches up two problems: the absolute file offsets |
1096 in the HDRR record of .mdebug (see /usr/include/syms.h), and | 1103 in the HDRR record of .mdebug (see /usr/include/syms.h), and |
1097 the ld bug that gets the line table in a hole in the | 1104 the ld bug that gets the line table in a hole in the |
1193 ElfW(Shdr) section = NEW_SECTION_H (n); | 1200 ElfW(Shdr) section = NEW_SECTION_H (n); |
1194 | 1201 |
1195 /* Cause a compilation error if anyone uses n instead of nn below. */ | 1202 /* Cause a compilation error if anyone uses n instead of nn below. */ |
1196 struct {int a;} n; | 1203 struct {int a;} n; |
1197 | 1204 |
1198 switch (section.sh_type) | 1205 switch (section.sh_type) |
1199 { | 1206 { |
1200 default: | 1207 default: |
1201 break; | 1208 break; |
1202 case SHT_REL: | 1209 case SHT_REL: |
1203 case SHT_RELA: | 1210 case SHT_RELA: |
1243 } | 1250 } |
1244 | 1251 |
1245 /* Write out new_file, and free the buffers. */ | 1252 /* Write out new_file, and free the buffers. */ |
1246 | 1253 |
1247 if (write (new_file, new_base, new_file_size) != new_file_size) | 1254 if (write (new_file, new_base, new_file_size) != new_file_size) |
1248 fatal ("Didn't write %d bytes to %s: errno %d\n", | 1255 fatal ("Didn't write %d bytes to %s: errno %d\n", |
1249 new_file_size, new_base, errno); | 1256 new_file_size, new_base, errno); |
1250 | 1257 |
1251 munmap (old_base, old_file_size); | 1258 munmap (old_base, old_file_size); |
1252 munmap (new_base, new_file_size); | 1259 munmap (new_base, new_file_size); |
1253 | 1260 |