Deleted Added
full compact
peXXigen.c (85815) peXXigen.c (89857)
1/* Support for the generic parts of PE/PEI; the common executable parts.
2 Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001
3 Free Software Foundation, Inc.
4 Written by Cygnus Solutions.
5
6This file is part of BFD, the Binary File Descriptor library.
7
8This program is free software; you can redistribute it and/or modify

--- 81 unchanged lines hidden (view full) ---

90 the code is in peigen.c. PowerPC NT is said to be dead. If
91 anybody wants to revive the code, you will have to figure out how
92 to handle those issues. */
93
94static void add_data_entry
95 PARAMS ((bfd *, struct internal_extra_pe_aouthdr *, int, char *, bfd_vma));
96static boolean pe_print_pdata PARAMS ((bfd *, PTR));
97static boolean pe_print_reloc PARAMS ((bfd *, PTR));
1/* Support for the generic parts of PE/PEI; the common executable parts.
2 Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001
3 Free Software Foundation, Inc.
4 Written by Cygnus Solutions.
5
6This file is part of BFD, the Binary File Descriptor library.
7
8This program is free software; you can redistribute it and/or modify

--- 81 unchanged lines hidden (view full) ---

90 the code is in peigen.c. PowerPC NT is said to be dead. If
91 anybody wants to revive the code, you will have to figure out how
92 to handle those issues. */
93
94static void add_data_entry
95 PARAMS ((bfd *, struct internal_extra_pe_aouthdr *, int, char *, bfd_vma));
96static boolean pe_print_pdata PARAMS ((bfd *, PTR));
97static boolean pe_print_reloc PARAMS ((bfd *, PTR));
98static boolean pe_print_idata PARAMS ((bfd *, PTR));
99static boolean pe_print_edata PARAMS ((bfd *, PTR));
100
98
101
99/**********************************************************************/
100
101void
102_bfd_XXi_swap_sym_in (abfd, ext1, in1)
103 bfd *abfd;
104 PTR ext1;
105 PTR in1;
106{
107 SYMENT *ext = (SYMENT *) ext1;
108 struct internal_syment *in = (struct internal_syment *) in1;
109
110 if (ext->e.e_name[0] == 0)
111 {
112 in->_n._n_n._n_zeroes = 0;
102void
103_bfd_XXi_swap_sym_in (abfd, ext1, in1)
104 bfd *abfd;
105 PTR ext1;
106 PTR in1;
107{
108 SYMENT *ext = (SYMENT *) ext1;
109 struct internal_syment *in = (struct internal_syment *) in1;
110
111 if (ext->e.e_name[0] == 0)
112 {
113 in->_n._n_n._n_zeroes = 0;
113 in->_n._n_n._n_offset =
114 bfd_h_get_32 (abfd, (bfd_byte *) ext->e.e.e_offset);
114 in->_n._n_n._n_offset = H_GET_32 (abfd, ext->e.e.e_offset);
115 }
116 else
115 }
116 else
117 {
118 memcpy (in->_n._n_name, ext->e.e_name, SYMNMLEN);
119 }
117 memcpy (in->_n._n_name, ext->e.e_name, SYMNMLEN);
120
118
121 in->n_value = bfd_h_get_32 (abfd, (bfd_byte *) ext->e_value);
122 in->n_scnum = bfd_h_get_16 (abfd, (bfd_byte *) ext->e_scnum);
119 in->n_value = H_GET_32 (abfd, ext->e_value);
120 in->n_scnum = H_GET_16 (abfd, ext->e_scnum);
121
123 if (sizeof (ext->e_type) == 2)
122 if (sizeof (ext->e_type) == 2)
124 {
125 in->n_type = bfd_h_get_16 (abfd, (bfd_byte *) ext->e_type);
126 }
123 in->n_type = H_GET_16 (abfd, ext->e_type);
127 else
124 else
128 {
129 in->n_type = bfd_h_get_32 (abfd, (bfd_byte *) ext->e_type);
130 }
131 in->n_sclass = bfd_h_get_8 (abfd, ext->e_sclass);
132 in->n_numaux = bfd_h_get_8 (abfd, ext->e_numaux);
125 in->n_type = H_GET_32 (abfd, ext->e_type);
133
126
127 in->n_sclass = H_GET_8 (abfd, ext->e_sclass);
128 in->n_numaux = H_GET_8 (abfd, ext->e_numaux);
129
134#ifndef STRICT_PE_FORMAT
135 /* This is for Gnu-created DLLs. */
136
137 /* The section symbols for the .idata$ sections have class 0x68
138 (C_SECTION), which MS documentation indicates is a section
139 symbol. Unfortunately, the value field in the symbol is simply a
140 copy of the .idata section's flags rather than something useful.
141 When these symbols are encountered, change the value to 0 so that

--- 19 unchanged lines hidden (view full) ---

161 else
162 in->n_scnum = 2;
163#endif
164#else
165 /* Create synthetic empty sections as needed. DJ */
166 if (in->n_scnum == 0)
167 {
168 asection *sec;
130#ifndef STRICT_PE_FORMAT
131 /* This is for Gnu-created DLLs. */
132
133 /* The section symbols for the .idata$ sections have class 0x68
134 (C_SECTION), which MS documentation indicates is a section
135 symbol. Unfortunately, the value field in the symbol is simply a
136 copy of the .idata section's flags rather than something useful.
137 When these symbols are encountered, change the value to 0 so that

--- 19 unchanged lines hidden (view full) ---

157 else
158 in->n_scnum = 2;
159#endif
160#else
161 /* Create synthetic empty sections as needed. DJ */
162 if (in->n_scnum == 0)
163 {
164 asection *sec;
165
169 for (sec = abfd->sections; sec; sec = sec->next)
170 {
171 if (strcmp (sec->name, in->n_name) == 0)
172 {
173 in->n_scnum = sec->target_index;
174 break;
175 }
176 }
177 }
166 for (sec = abfd->sections; sec; sec = sec->next)
167 {
168 if (strcmp (sec->name, in->n_name) == 0)
169 {
170 in->n_scnum = sec->target_index;
171 break;
172 }
173 }
174 }
175
178 if (in->n_scnum == 0)
179 {
180 int unused_section_number = 0;
181 asection *sec;
182 char *name;
176 if (in->n_scnum == 0)
177 {
178 int unused_section_number = 0;
179 asection *sec;
180 char *name;
181
183 for (sec = abfd->sections; sec; sec = sec->next)
184 if (unused_section_number <= sec->target_index)
185 unused_section_number = sec->target_index + 1;
186
182 for (sec = abfd->sections; sec; sec = sec->next)
183 if (unused_section_number <= sec->target_index)
184 unused_section_number = sec->target_index + 1;
185
187 name = bfd_alloc (abfd, strlen (in->n_name) + 10);
186 name = bfd_alloc (abfd, (bfd_size_type) strlen (in->n_name) + 10);
188 if (name == NULL)
189 return;
190 strcpy (name, in->n_name);
191 sec = bfd_make_section_anyway (abfd, name);
192
193 sec->vma = 0;
194 sec->lma = 0;
195 sec->_cooked_size = 0;

--- 28 unchanged lines hidden (view full) ---

224unsigned int
225_bfd_XXi_swap_sym_out (abfd, inp, extp)
226 bfd *abfd;
227 PTR inp;
228 PTR extp;
229{
230 struct internal_syment *in = (struct internal_syment *) inp;
231 SYMENT *ext = (SYMENT *) extp;
187 if (name == NULL)
188 return;
189 strcpy (name, in->n_name);
190 sec = bfd_make_section_anyway (abfd, name);
191
192 sec->vma = 0;
193 sec->lma = 0;
194 sec->_cooked_size = 0;

--- 28 unchanged lines hidden (view full) ---

223unsigned int
224_bfd_XXi_swap_sym_out (abfd, inp, extp)
225 bfd *abfd;
226 PTR inp;
227 PTR extp;
228{
229 struct internal_syment *in = (struct internal_syment *) inp;
230 SYMENT *ext = (SYMENT *) extp;
231
232 if (in->_n._n_name[0] == 0)
233 {
232 if (in->_n._n_name[0] == 0)
233 {
234 bfd_h_put_32 (abfd, 0, (bfd_byte *) ext->e.e.e_zeroes);
235 bfd_h_put_32 (abfd, in->_n._n_n._n_offset, (bfd_byte *) ext->e.e.e_offset);
234 H_PUT_32 (abfd, 0, ext->e.e.e_zeroes);
235 H_PUT_32 (abfd, in->_n._n_n._n_offset, ext->e.e.e_offset);
236 }
237 else
236 }
237 else
238 {
239 memcpy (ext->e.e_name, in->_n._n_name, SYMNMLEN);
240 }
238 memcpy (ext->e.e_name, in->_n._n_name, SYMNMLEN);
241
239
242 bfd_h_put_32 (abfd, in->n_value, (bfd_byte *) ext->e_value);
243 bfd_h_put_16 (abfd, in->n_scnum, (bfd_byte *) ext->e_scnum);
240 H_PUT_32 (abfd, in->n_value, ext->e_value);
241 H_PUT_16 (abfd, in->n_scnum, ext->e_scnum);
242
244 if (sizeof (ext->e_type) == 2)
243 if (sizeof (ext->e_type) == 2)
245 {
246 bfd_h_put_16 (abfd, in->n_type, (bfd_byte *) ext->e_type);
247 }
244 H_PUT_16 (abfd, in->n_type, ext->e_type);
248 else
245 else
249 {
250 bfd_h_put_32 (abfd, in->n_type, (bfd_byte *) ext->e_type);
251 }
252 bfd_h_put_8 (abfd, in->n_sclass, ext->e_sclass);
253 bfd_h_put_8 (abfd, in->n_numaux, ext->e_numaux);
246 H_PUT_32 (abfd, in->n_type, ext->e_type);
254
247
248 H_PUT_8 (abfd, in->n_sclass, ext->e_sclass);
249 H_PUT_8 (abfd, in->n_numaux, ext->e_numaux);
250
255 return SYMESZ;
256}
257
258void
259_bfd_XXi_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1)
260 bfd *abfd;
261 PTR ext1;
262 int type;

--- 6 unchanged lines hidden (view full) ---

269 union internal_auxent *in = (union internal_auxent *) in1;
270
271 switch (class)
272 {
273 case C_FILE:
274 if (ext->x_file.x_fname[0] == 0)
275 {
276 in->x_file.x_n.x_zeroes = 0;
251 return SYMESZ;
252}
253
254void
255_bfd_XXi_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1)
256 bfd *abfd;
257 PTR ext1;
258 int type;

--- 6 unchanged lines hidden (view full) ---

265 union internal_auxent *in = (union internal_auxent *) in1;
266
267 switch (class)
268 {
269 case C_FILE:
270 if (ext->x_file.x_fname[0] == 0)
271 {
272 in->x_file.x_n.x_zeroes = 0;
277 in->x_file.x_n.x_offset =
278 bfd_h_get_32 (abfd, (bfd_byte *) ext->x_file.x_n.x_offset);
273 in->x_file.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
279 }
280 else
274 }
275 else
281 {
282 memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
283 }
276 memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
284 return;
285
286 case C_STAT:
287 case C_LEAFSTAT:
288 case C_HIDDEN:
289 if (type == T_NULL)
290 {
291 in->x_scn.x_scnlen = GET_SCN_SCNLEN (abfd, ext);
292 in->x_scn.x_nreloc = GET_SCN_NRELOC (abfd, ext);
293 in->x_scn.x_nlinno = GET_SCN_NLINNO (abfd, ext);
277 return;
278
279 case C_STAT:
280 case C_LEAFSTAT:
281 case C_HIDDEN:
282 if (type == T_NULL)
283 {
284 in->x_scn.x_scnlen = GET_SCN_SCNLEN (abfd, ext);
285 in->x_scn.x_nreloc = GET_SCN_NRELOC (abfd, ext);
286 in->x_scn.x_nlinno = GET_SCN_NLINNO (abfd, ext);
294 in->x_scn.x_checksum =
295 bfd_h_get_32 (abfd, (bfd_byte *) ext->x_scn.x_checksum);
296 in->x_scn.x_associated =
297 bfd_h_get_16 (abfd, (bfd_byte *) ext->x_scn.x_associated);
298 in->x_scn.x_comdat =
299 bfd_h_get_8 (abfd, (bfd_byte *) ext->x_scn.x_comdat);
287 in->x_scn.x_checksum = H_GET_32 (abfd, ext->x_scn.x_checksum);
288 in->x_scn.x_associated = H_GET_16 (abfd, ext->x_scn.x_associated);
289 in->x_scn.x_comdat = H_GET_8 (abfd, ext->x_scn.x_comdat);
300 return;
301 }
302 break;
303 }
304
290 return;
291 }
292 break;
293 }
294
305 in->x_sym.x_tagndx.l = bfd_h_get_32 (abfd, (bfd_byte *) ext->x_sym.x_tagndx);
306 in->x_sym.x_tvndx = bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_tvndx);
295 in->x_sym.x_tagndx.l = H_GET_32 (abfd, ext->x_sym.x_tagndx);
296 in->x_sym.x_tvndx = H_GET_16 (abfd, ext->x_sym.x_tvndx);
307
308 if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
309 {
310 in->x_sym.x_fcnary.x_fcn.x_lnnoptr = GET_FCN_LNNOPTR (abfd, ext);
311 in->x_sym.x_fcnary.x_fcn.x_endndx.l = GET_FCN_ENDNDX (abfd, ext);
312 }
313 else
314 {
315 in->x_sym.x_fcnary.x_ary.x_dimen[0] =
297
298 if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
299 {
300 in->x_sym.x_fcnary.x_fcn.x_lnnoptr = GET_FCN_LNNOPTR (abfd, ext);
301 in->x_sym.x_fcnary.x_fcn.x_endndx.l = GET_FCN_ENDNDX (abfd, ext);
302 }
303 else
304 {
305 in->x_sym.x_fcnary.x_ary.x_dimen[0] =
316 bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
306 H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
317 in->x_sym.x_fcnary.x_ary.x_dimen[1] =
307 in->x_sym.x_fcnary.x_ary.x_dimen[1] =
318 bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
308 H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
319 in->x_sym.x_fcnary.x_ary.x_dimen[2] =
309 in->x_sym.x_fcnary.x_ary.x_dimen[2] =
320 bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
310 H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
321 in->x_sym.x_fcnary.x_ary.x_dimen[3] =
311 in->x_sym.x_fcnary.x_ary.x_dimen[3] =
322 bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
312 H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
323 }
324
325 if (ISFCN (type))
326 {
313 }
314
315 if (ISFCN (type))
316 {
327 in->x_sym.x_misc.x_fsize =
328 bfd_h_get_32 (abfd, (bfd_byte *) ext->x_sym.x_misc.x_fsize);
317 in->x_sym.x_misc.x_fsize = H_GET_32 (abfd, ext->x_sym.x_misc.x_fsize);
329 }
330 else
331 {
332 in->x_sym.x_misc.x_lnsz.x_lnno = GET_LNSZ_LNNO (abfd, ext);
333 in->x_sym.x_misc.x_lnsz.x_size = GET_LNSZ_SIZE (abfd, ext);
334 }
335}
336

--- 11 unchanged lines hidden (view full) ---

348 AUXENT *ext = (AUXENT *) extp;
349
350 memset ((PTR) ext, 0, AUXESZ);
351 switch (class)
352 {
353 case C_FILE:
354 if (in->x_file.x_fname[0] == 0)
355 {
318 }
319 else
320 {
321 in->x_sym.x_misc.x_lnsz.x_lnno = GET_LNSZ_LNNO (abfd, ext);
322 in->x_sym.x_misc.x_lnsz.x_size = GET_LNSZ_SIZE (abfd, ext);
323 }
324}
325

--- 11 unchanged lines hidden (view full) ---

337 AUXENT *ext = (AUXENT *) extp;
338
339 memset ((PTR) ext, 0, AUXESZ);
340 switch (class)
341 {
342 case C_FILE:
343 if (in->x_file.x_fname[0] == 0)
344 {
356 bfd_h_put_32 (abfd, 0, (bfd_byte *) ext->x_file.x_n.x_zeroes);
357 bfd_h_put_32 (abfd,
358 in->x_file.x_n.x_offset,
359 (bfd_byte *) ext->x_file.x_n.x_offset);
345 H_PUT_32 (abfd, 0, ext->x_file.x_n.x_zeroes);
346 H_PUT_32 (abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset);
360 }
361 else
347 }
348 else
362 {
363 memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
364 }
349 memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
350
365 return AUXESZ;
366
367 case C_STAT:
368 case C_LEAFSTAT:
369 case C_HIDDEN:
370 if (type == T_NULL)
371 {
372 PUT_SCN_SCNLEN (abfd, in->x_scn.x_scnlen, ext);
373 PUT_SCN_NRELOC (abfd, in->x_scn.x_nreloc, ext);
374 PUT_SCN_NLINNO (abfd, in->x_scn.x_nlinno, ext);
351 return AUXESZ;
352
353 case C_STAT:
354 case C_LEAFSTAT:
355 case C_HIDDEN:
356 if (type == T_NULL)
357 {
358 PUT_SCN_SCNLEN (abfd, in->x_scn.x_scnlen, ext);
359 PUT_SCN_NRELOC (abfd, in->x_scn.x_nreloc, ext);
360 PUT_SCN_NLINNO (abfd, in->x_scn.x_nlinno, ext);
375 bfd_h_put_32 (abfd, in->x_scn.x_checksum,
376 (bfd_byte *) ext->x_scn.x_checksum);
377 bfd_h_put_16 (abfd, in->x_scn.x_associated,
378 (bfd_byte *) ext->x_scn.x_associated);
379 bfd_h_put_8 (abfd, in->x_scn.x_comdat,
380 (bfd_byte *) ext->x_scn.x_comdat);
361 H_PUT_32 (abfd, in->x_scn.x_checksum, ext->x_scn.x_checksum);
362 H_PUT_16 (abfd, in->x_scn.x_associated, ext->x_scn.x_associated);
363 H_PUT_8 (abfd, in->x_scn.x_comdat, ext->x_scn.x_comdat);
381 return AUXESZ;
382 }
383 break;
384 }
385
364 return AUXESZ;
365 }
366 break;
367 }
368
386 bfd_h_put_32 (abfd, in->x_sym.x_tagndx.l, (bfd_byte *) ext->x_sym.x_tagndx);
387 bfd_h_put_16 (abfd, in->x_sym.x_tvndx, (bfd_byte *) ext->x_sym.x_tvndx);
369 H_PUT_32 (abfd, in->x_sym.x_tagndx.l, ext->x_sym.x_tagndx);
370 H_PUT_16 (abfd, in->x_sym.x_tvndx, ext->x_sym.x_tvndx);
388
389 if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
390 {
391 PUT_FCN_LNNOPTR (abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext);
392 PUT_FCN_ENDNDX (abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l, ext);
393 }
394 else
395 {
371
372 if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
373 {
374 PUT_FCN_LNNOPTR (abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext);
375 PUT_FCN_ENDNDX (abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l, ext);
376 }
377 else
378 {
396 bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],
397 (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
398 bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],
399 (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
400 bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],
401 (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
402 bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],
403 (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
379 H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],
380 ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
381 H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],
382 ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
383 H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],
384 ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
385 H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],
386 ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
404 }
405
406 if (ISFCN (type))
387 }
388
389 if (ISFCN (type))
407 bfd_h_put_32 (abfd, in->x_sym.x_misc.x_fsize,
408 (bfd_byte *) ext->x_sym.x_misc.x_fsize);
390 H_PUT_32 (abfd, in->x_sym.x_misc.x_fsize, ext->x_sym.x_misc.x_fsize);
409 else
410 {
411 PUT_LNSZ_LNNO (abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext);
412 PUT_LNSZ_SIZE (abfd, in->x_sym.x_misc.x_lnsz.x_size, ext);
413 }
414
415 return AUXESZ;
416}
417
418void
419_bfd_XXi_swap_lineno_in (abfd, ext1, in1)
420 bfd *abfd;
421 PTR ext1;
422 PTR in1;
423{
424 LINENO *ext = (LINENO *) ext1;
425 struct internal_lineno *in = (struct internal_lineno *) in1;
426
391 else
392 {
393 PUT_LNSZ_LNNO (abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext);
394 PUT_LNSZ_SIZE (abfd, in->x_sym.x_misc.x_lnsz.x_size, ext);
395 }
396
397 return AUXESZ;
398}
399
400void
401_bfd_XXi_swap_lineno_in (abfd, ext1, in1)
402 bfd *abfd;
403 PTR ext1;
404 PTR in1;
405{
406 LINENO *ext = (LINENO *) ext1;
407 struct internal_lineno *in = (struct internal_lineno *) in1;
408
427 in->l_addr.l_symndx = bfd_h_get_32 (abfd, (bfd_byte *) ext->l_addr.l_symndx);
409 in->l_addr.l_symndx = H_GET_32 (abfd, ext->l_addr.l_symndx);
428 in->l_lnno = GET_LINENO_LNNO (abfd, ext);
429}
430
431unsigned int
432_bfd_XXi_swap_lineno_out (abfd, inp, outp)
433 bfd *abfd;
434 PTR inp;
435 PTR outp;
436{
437 struct internal_lineno *in = (struct internal_lineno *) inp;
438 struct external_lineno *ext = (struct external_lineno *) outp;
410 in->l_lnno = GET_LINENO_LNNO (abfd, ext);
411}
412
413unsigned int
414_bfd_XXi_swap_lineno_out (abfd, inp, outp)
415 bfd *abfd;
416 PTR inp;
417 PTR outp;
418{
419 struct internal_lineno *in = (struct internal_lineno *) inp;
420 struct external_lineno *ext = (struct external_lineno *) outp;
439 bfd_h_put_32 (abfd, in->l_addr.l_symndx, (bfd_byte *)
440 ext->l_addr.l_symndx);
421 H_PUT_32 (abfd, in->l_addr.l_symndx, ext->l_addr.l_symndx);
441
442 PUT_LINENO_LNNO (abfd, in->l_lnno, ext);
443 return LINESZ;
444}
445
446void
447_bfd_XXi_swap_aouthdr_in (abfd, aouthdr_ext1, aouthdr_int1)
448 bfd *abfd;
449 PTR aouthdr_ext1;
450 PTR aouthdr_int1;
451{
452 struct internal_extra_pe_aouthdr *a;
453 PEAOUTHDR *src = (PEAOUTHDR *) (aouthdr_ext1);
454 AOUTHDR *aouthdr_ext = (AOUTHDR *) aouthdr_ext1;
455 struct internal_aouthdr *aouthdr_int = (struct internal_aouthdr *)aouthdr_int1;
456
422
423 PUT_LINENO_LNNO (abfd, in->l_lnno, ext);
424 return LINESZ;
425}
426
427void
428_bfd_XXi_swap_aouthdr_in (abfd, aouthdr_ext1, aouthdr_int1)
429 bfd *abfd;
430 PTR aouthdr_ext1;
431 PTR aouthdr_int1;
432{
433 struct internal_extra_pe_aouthdr *a;
434 PEAOUTHDR *src = (PEAOUTHDR *) (aouthdr_ext1);
435 AOUTHDR *aouthdr_ext = (AOUTHDR *) aouthdr_ext1;
436 struct internal_aouthdr *aouthdr_int = (struct internal_aouthdr *)aouthdr_int1;
437
457 aouthdr_int->magic = bfd_h_get_16 (abfd, (bfd_byte *) aouthdr_ext->magic);
458 aouthdr_int->vstamp = bfd_h_get_16 (abfd, (bfd_byte *) aouthdr_ext->vstamp);
459 aouthdr_int->tsize =
460 GET_AOUTHDR_TSIZE (abfd, (bfd_byte *) aouthdr_ext->tsize);
461 aouthdr_int->dsize =
462 GET_AOUTHDR_DSIZE (abfd, (bfd_byte *) aouthdr_ext->dsize);
463 aouthdr_int->bsize =
464 GET_AOUTHDR_BSIZE (abfd, (bfd_byte *) aouthdr_ext->bsize);
465 aouthdr_int->entry =
466 GET_AOUTHDR_ENTRY (abfd, (bfd_byte *) aouthdr_ext->entry);
438 aouthdr_int->magic = H_GET_16 (abfd, aouthdr_ext->magic);
439 aouthdr_int->vstamp = H_GET_16 (abfd, aouthdr_ext->vstamp);
440 aouthdr_int->tsize = GET_AOUTHDR_TSIZE (abfd, aouthdr_ext->tsize);
441 aouthdr_int->dsize = GET_AOUTHDR_DSIZE (abfd, aouthdr_ext->dsize);
442 aouthdr_int->bsize = GET_AOUTHDR_BSIZE (abfd, aouthdr_ext->bsize);
443 aouthdr_int->entry = GET_AOUTHDR_ENTRY (abfd, aouthdr_ext->entry);
467 aouthdr_int->text_start =
444 aouthdr_int->text_start =
468 GET_AOUTHDR_TEXT_START (abfd, (bfd_byte *) aouthdr_ext->text_start);
445 GET_AOUTHDR_TEXT_START (abfd, aouthdr_ext->text_start);
469#ifndef COFF_WITH_pep
470 /* PE32+ does not have data_start member! */
471 aouthdr_int->data_start =
446#ifndef COFF_WITH_pep
447 /* PE32+ does not have data_start member! */
448 aouthdr_int->data_start =
472 GET_AOUTHDR_DATA_START (abfd, (bfd_byte *) aouthdr_ext->data_start);
449 GET_AOUTHDR_DATA_START (abfd, aouthdr_ext->data_start);
473#endif
474
475 a = &aouthdr_int->pe;
450#endif
451
452 a = &aouthdr_int->pe;
476 a->ImageBase = GET_OPTHDR_IMAGE_BASE (abfd, (bfd_byte *) src->ImageBase);
477 a->SectionAlignment = bfd_h_get_32 (abfd, (bfd_byte *) src->SectionAlignment);
478 a->FileAlignment = bfd_h_get_32 (abfd, (bfd_byte *) src->FileAlignment);
453 a->ImageBase = GET_OPTHDR_IMAGE_BASE (abfd, src->ImageBase);
454 a->SectionAlignment = H_GET_32 (abfd, src->SectionAlignment);
455 a->FileAlignment = H_GET_32 (abfd, src->FileAlignment);
479 a->MajorOperatingSystemVersion =
456 a->MajorOperatingSystemVersion =
480 bfd_h_get_16 (abfd, (bfd_byte *) src->MajorOperatingSystemVersion);
457 H_GET_16 (abfd, src->MajorOperatingSystemVersion);
481 a->MinorOperatingSystemVersion =
458 a->MinorOperatingSystemVersion =
482 bfd_h_get_16 (abfd, (bfd_byte *) src->MinorOperatingSystemVersion);
483 a->MajorImageVersion = bfd_h_get_16 (abfd, (bfd_byte *) src->MajorImageVersion);
484 a->MinorImageVersion = bfd_h_get_16 (abfd, (bfd_byte *) src->MinorImageVersion);
485 a->MajorSubsystemVersion = bfd_h_get_16 (abfd, (bfd_byte *) src->MajorSubsystemVersion);
486 a->MinorSubsystemVersion = bfd_h_get_16 (abfd, (bfd_byte *) src->MinorSubsystemVersion);
487 a->Reserved1 = bfd_h_get_32 (abfd, (bfd_byte *) src->Reserved1);
488 a->SizeOfImage = bfd_h_get_32 (abfd, (bfd_byte *) src->SizeOfImage);
489 a->SizeOfHeaders = bfd_h_get_32 (abfd, (bfd_byte *) src->SizeOfHeaders);
490 a->CheckSum = bfd_h_get_32 (abfd, (bfd_byte *) src->CheckSum);
491 a->Subsystem = bfd_h_get_16 (abfd, (bfd_byte *) src->Subsystem);
492 a->DllCharacteristics = bfd_h_get_16 (abfd, (bfd_byte *) src->DllCharacteristics);
493 a->SizeOfStackReserve = GET_OPTHDR_SIZE_OF_STACK_RESERVE (abfd, (bfd_byte *) src->SizeOfStackReserve);
494 a->SizeOfStackCommit = GET_OPTHDR_SIZE_OF_STACK_COMMIT (abfd, (bfd_byte *) src->SizeOfStackCommit);
495 a->SizeOfHeapReserve = GET_OPTHDR_SIZE_OF_HEAP_RESERVE (abfd, (bfd_byte *) src->SizeOfHeapReserve);
496 a->SizeOfHeapCommit = GET_OPTHDR_SIZE_OF_HEAP_COMMIT (abfd, (bfd_byte *) src->SizeOfHeapCommit);
497 a->LoaderFlags = bfd_h_get_32 (abfd, (bfd_byte *) src->LoaderFlags);
498 a->NumberOfRvaAndSizes = bfd_h_get_32 (abfd, (bfd_byte *) src->NumberOfRvaAndSizes);
459 H_GET_16 (abfd, src->MinorOperatingSystemVersion);
460 a->MajorImageVersion = H_GET_16 (abfd, src->MajorImageVersion);
461 a->MinorImageVersion = H_GET_16 (abfd, src->MinorImageVersion);
462 a->MajorSubsystemVersion = H_GET_16 (abfd, src->MajorSubsystemVersion);
463 a->MinorSubsystemVersion = H_GET_16 (abfd, src->MinorSubsystemVersion);
464 a->Reserved1 = H_GET_32 (abfd, src->Reserved1);
465 a->SizeOfImage = H_GET_32 (abfd, src->SizeOfImage);
466 a->SizeOfHeaders = H_GET_32 (abfd, src->SizeOfHeaders);
467 a->CheckSum = H_GET_32 (abfd, src->CheckSum);
468 a->Subsystem = H_GET_16 (abfd, src->Subsystem);
469 a->DllCharacteristics = H_GET_16 (abfd, src->DllCharacteristics);
470 a->SizeOfStackReserve =
471 GET_OPTHDR_SIZE_OF_STACK_RESERVE (abfd, src->SizeOfStackReserve);
472 a->SizeOfStackCommit =
473 GET_OPTHDR_SIZE_OF_STACK_COMMIT (abfd, src->SizeOfStackCommit);
474 a->SizeOfHeapReserve =
475 GET_OPTHDR_SIZE_OF_HEAP_RESERVE (abfd, src->SizeOfHeapReserve);
476 a->SizeOfHeapCommit =
477 GET_OPTHDR_SIZE_OF_HEAP_COMMIT (abfd, src->SizeOfHeapCommit);
478 a->LoaderFlags = H_GET_32 (abfd, src->LoaderFlags);
479 a->NumberOfRvaAndSizes = H_GET_32 (abfd, src->NumberOfRvaAndSizes);
499
500 {
501 int idx;
480
481 {
482 int idx;
483
502 for (idx = 0; idx < 16; idx++)
503 {
504 /* If data directory is empty, rva also should be 0. */
505 int size =
484 for (idx = 0; idx < 16; idx++)
485 {
486 /* If data directory is empty, rva also should be 0. */
487 int size =
506 bfd_h_get_32 (abfd, (bfd_byte *) src->DataDirectory[idx][1]);
488 H_GET_32 (abfd, src->DataDirectory[idx][1]);
507 a->DataDirectory[idx].Size = size;
508
509 if (size)
489 a->DataDirectory[idx].Size = size;
490
491 if (size)
510 {
511 a->DataDirectory[idx].VirtualAddress =
512 bfd_h_get_32 (abfd, (bfd_byte *) src->DataDirectory[idx][0]);
513 }
492 a->DataDirectory[idx].VirtualAddress =
493 H_GET_32 (abfd, src->DataDirectory[idx][0]);
514 else
515 a->DataDirectory[idx].VirtualAddress = 0;
516 }
517 }
518
519 if (aouthdr_int->entry)
520 {
521 aouthdr_int->entry += a->ImageBase;
522#ifndef COFF_WITH_pep
523 aouthdr_int->entry &= 0xffffffff;
524#endif
525 }
494 else
495 a->DataDirectory[idx].VirtualAddress = 0;
496 }
497 }
498
499 if (aouthdr_int->entry)
500 {
501 aouthdr_int->entry += a->ImageBase;
502#ifndef COFF_WITH_pep
503 aouthdr_int->entry &= 0xffffffff;
504#endif
505 }
506
526 if (aouthdr_int->tsize)
527 {
528 aouthdr_int->text_start += a->ImageBase;
529#ifndef COFF_WITH_pep
530 aouthdr_int->text_start &= 0xffffffff;
531#endif
532 }
507 if (aouthdr_int->tsize)
508 {
509 aouthdr_int->text_start += a->ImageBase;
510#ifndef COFF_WITH_pep
511 aouthdr_int->text_start &= 0xffffffff;
512#endif
513 }
514
533#ifndef COFF_WITH_pep
534 /* PE32+ does not have data_start member! */
535 if (aouthdr_int->dsize)
536 {
537 aouthdr_int->data_start += a->ImageBase;
538 aouthdr_int->data_start &= 0xffffffff;
539 }
540#endif
541
542#ifdef POWERPC_LE_PE
543 /* These three fields are normally set up by ppc_relocate_section.
544 In the case of reading a file in, we can pick them up from the
545 DataDirectory. */
546 first_thunk_address = a->DataDirectory[12].VirtualAddress;
547 thunk_size = a->DataDirectory[12].Size;
548 import_table_size = a->DataDirectory[1].Size;
549#endif
515#ifndef COFF_WITH_pep
516 /* PE32+ does not have data_start member! */
517 if (aouthdr_int->dsize)
518 {
519 aouthdr_int->data_start += a->ImageBase;
520 aouthdr_int->data_start &= 0xffffffff;
521 }
522#endif
523
524#ifdef POWERPC_LE_PE
525 /* These three fields are normally set up by ppc_relocate_section.
526 In the case of reading a file in, we can pick them up from the
527 DataDirectory. */
528 first_thunk_address = a->DataDirectory[12].VirtualAddress;
529 thunk_size = a->DataDirectory[12].Size;
530 import_table_size = a->DataDirectory[1].Size;
531#endif
550
551}
552
553/* A support function for below. */
554
555static void
556add_data_entry (abfd, aout, idx, name, base)
557 bfd *abfd;
558 struct internal_extra_pe_aouthdr *aout;
559 int idx;
560 char *name;
561 bfd_vma base;
562{
563 asection *sec = bfd_get_section_by_name (abfd, name);
564
532}
533
534/* A support function for below. */
535
536static void
537add_data_entry (abfd, aout, idx, name, base)
538 bfd *abfd;
539 struct internal_extra_pe_aouthdr *aout;
540 int idx;
541 char *name;
542 bfd_vma base;
543{
544 asection *sec = bfd_get_section_by_name (abfd, name);
545
565 /* add import directory information if it exists */
546 /* Add import directory information if it exists. */
566 if ((sec != NULL)
567 && (coff_section_data (abfd, sec) != NULL)
568 && (pei_section_data (abfd, sec) != NULL))
569 {
547 if ((sec != NULL)
548 && (coff_section_data (abfd, sec) != NULL)
549 && (pei_section_data (abfd, sec) != NULL))
550 {
570 /* If data directory is empty, rva also should be 0 */
551 /* If data directory is empty, rva also should be 0. */
571 int size = pei_section_data (abfd, sec)->virt_size;
572 aout->DataDirectory[idx].Size = size;
573
574 if (size)
575 {
576 aout->DataDirectory[idx].VirtualAddress =
577 (sec->vma - base) & 0xffffffff;
578 sec->flags |= SEC_DATA;

--- 30 unchanged lines hidden (view full) ---

609
610 if (aouthdr_in->tsize)
611 {
612 aouthdr_in->text_start -= ib;
613#ifndef COFF_WITH_pep
614 aouthdr_in->text_start &= 0xffffffff;
615#endif
616 }
552 int size = pei_section_data (abfd, sec)->virt_size;
553 aout->DataDirectory[idx].Size = size;
554
555 if (size)
556 {
557 aout->DataDirectory[idx].VirtualAddress =
558 (sec->vma - base) & 0xffffffff;
559 sec->flags |= SEC_DATA;

--- 30 unchanged lines hidden (view full) ---

590
591 if (aouthdr_in->tsize)
592 {
593 aouthdr_in->text_start -= ib;
594#ifndef COFF_WITH_pep
595 aouthdr_in->text_start &= 0xffffffff;
596#endif
597 }
598
617 if (aouthdr_in->dsize)
618 {
619 aouthdr_in->data_start -= ib;
620#ifndef COFF_WITH_pep
621 aouthdr_in->data_start &= 0xffffffff;
622#endif
623 }
599 if (aouthdr_in->dsize)
600 {
601 aouthdr_in->data_start -= ib;
602#ifndef COFF_WITH_pep
603 aouthdr_in->data_start &= 0xffffffff;
604#endif
605 }
606
624 if (aouthdr_in->entry)
625 {
626 aouthdr_in->entry -= ib;
627#ifndef COFF_WITH_pep
628 aouthdr_in->entry &= 0xffffffff;
629#endif
630 }
631

--- 54 unchanged lines hidden (view full) ---

686 }
687
688 aouthdr_in->dsize = dsize;
689 aouthdr_in->tsize = tsize;
690 extra->SizeOfImage = isize;
691 }
692
693 extra->SizeOfHeaders = abfd->sections->filepos;
607 if (aouthdr_in->entry)
608 {
609 aouthdr_in->entry -= ib;
610#ifndef COFF_WITH_pep
611 aouthdr_in->entry &= 0xffffffff;
612#endif
613 }
614

--- 54 unchanged lines hidden (view full) ---

669 }
670
671 aouthdr_in->dsize = dsize;
672 aouthdr_in->tsize = tsize;
673 extra->SizeOfImage = isize;
674 }
675
676 extra->SizeOfHeaders = abfd->sections->filepos;
694 bfd_h_put_16 (abfd, aouthdr_in->magic, (bfd_byte *) aouthdr_out->standard.magic);
677 H_PUT_16 (abfd, aouthdr_in->magic, aouthdr_out->standard.magic);
695
696#define LINKER_VERSION 256 /* That is, 2.56 */
697
698 /* This piece of magic sets the "linker version" field to
699 LINKER_VERSION. */
678
679#define LINKER_VERSION 256 /* That is, 2.56 */
680
681 /* This piece of magic sets the "linker version" field to
682 LINKER_VERSION. */
700 bfd_h_put_16 (abfd,
701 LINKER_VERSION / 100 + (LINKER_VERSION % 100) * 256,
702 (bfd_byte *) aouthdr_out->standard.vstamp);
683 H_PUT_16 (abfd, (LINKER_VERSION / 100 + (LINKER_VERSION % 100) * 256),
684 aouthdr_out->standard.vstamp);
703
685
704 PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, (bfd_byte *) aouthdr_out->standard.tsize);
705 PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, (bfd_byte *) aouthdr_out->standard.dsize);
706 PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, (bfd_byte *) aouthdr_out->standard.bsize);
707 PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, (bfd_byte *) aouthdr_out->standard.entry);
686 PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, aouthdr_out->standard.tsize);
687 PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, aouthdr_out->standard.dsize);
688 PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, aouthdr_out->standard.bsize);
689 PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, aouthdr_out->standard.entry);
708 PUT_AOUTHDR_TEXT_START (abfd, aouthdr_in->text_start,
690 PUT_AOUTHDR_TEXT_START (abfd, aouthdr_in->text_start,
709 (bfd_byte *) aouthdr_out->standard.text_start);
691 aouthdr_out->standard.text_start);
710
711#ifndef COFF_WITH_pep
712 /* PE32+ does not have data_start member! */
713 PUT_AOUTHDR_DATA_START (abfd, aouthdr_in->data_start,
692
693#ifndef COFF_WITH_pep
694 /* PE32+ does not have data_start member! */
695 PUT_AOUTHDR_DATA_START (abfd, aouthdr_in->data_start,
714 (bfd_byte *) aouthdr_out->standard.data_start);
696 aouthdr_out->standard.data_start);
715#endif
716
697#endif
698
717 PUT_OPTHDR_IMAGE_BASE (abfd, extra->ImageBase,
718 (bfd_byte *) aouthdr_out->ImageBase);
719 bfd_h_put_32 (abfd, extra->SectionAlignment,
720 (bfd_byte *) aouthdr_out->SectionAlignment);
721 bfd_h_put_32 (abfd, extra->FileAlignment,
722 (bfd_byte *) aouthdr_out->FileAlignment);
723 bfd_h_put_16 (abfd, extra->MajorOperatingSystemVersion,
724 (bfd_byte *) aouthdr_out->MajorOperatingSystemVersion);
725 bfd_h_put_16 (abfd, extra->MinorOperatingSystemVersion,
726 (bfd_byte *) aouthdr_out->MinorOperatingSystemVersion);
727 bfd_h_put_16 (abfd, extra->MajorImageVersion,
728 (bfd_byte *) aouthdr_out->MajorImageVersion);
729 bfd_h_put_16 (abfd, extra->MinorImageVersion,
730 (bfd_byte *) aouthdr_out->MinorImageVersion);
731 bfd_h_put_16 (abfd, extra->MajorSubsystemVersion,
732 (bfd_byte *) aouthdr_out->MajorSubsystemVersion);
733 bfd_h_put_16 (abfd, extra->MinorSubsystemVersion,
734 (bfd_byte *) aouthdr_out->MinorSubsystemVersion);
735 bfd_h_put_32 (abfd, extra->Reserved1,
736 (bfd_byte *) aouthdr_out->Reserved1);
737 bfd_h_put_32 (abfd, extra->SizeOfImage,
738 (bfd_byte *) aouthdr_out->SizeOfImage);
739 bfd_h_put_32 (abfd, extra->SizeOfHeaders,
740 (bfd_byte *) aouthdr_out->SizeOfHeaders);
741 bfd_h_put_32 (abfd, extra->CheckSum,
742 (bfd_byte *) aouthdr_out->CheckSum);
743 bfd_h_put_16 (abfd, extra->Subsystem,
744 (bfd_byte *) aouthdr_out->Subsystem);
745 bfd_h_put_16 (abfd, extra->DllCharacteristics,
746 (bfd_byte *) aouthdr_out->DllCharacteristics);
699 PUT_OPTHDR_IMAGE_BASE (abfd, extra->ImageBase, aouthdr_out->ImageBase);
700 H_PUT_32 (abfd, extra->SectionAlignment, aouthdr_out->SectionAlignment);
701 H_PUT_32 (abfd, extra->FileAlignment, aouthdr_out->FileAlignment);
702 H_PUT_16 (abfd, extra->MajorOperatingSystemVersion,
703 aouthdr_out->MajorOperatingSystemVersion);
704 H_PUT_16 (abfd, extra->MinorOperatingSystemVersion,
705 aouthdr_out->MinorOperatingSystemVersion);
706 H_PUT_16 (abfd, extra->MajorImageVersion, aouthdr_out->MajorImageVersion);
707 H_PUT_16 (abfd, extra->MinorImageVersion, aouthdr_out->MinorImageVersion);
708 H_PUT_16 (abfd, extra->MajorSubsystemVersion,
709 aouthdr_out->MajorSubsystemVersion);
710 H_PUT_16 (abfd, extra->MinorSubsystemVersion,
711 aouthdr_out->MinorSubsystemVersion);
712 H_PUT_32 (abfd, extra->Reserved1, aouthdr_out->Reserved1);
713 H_PUT_32 (abfd, extra->SizeOfImage, aouthdr_out->SizeOfImage);
714 H_PUT_32 (abfd, extra->SizeOfHeaders, aouthdr_out->SizeOfHeaders);
715 H_PUT_32 (abfd, extra->CheckSum, aouthdr_out->CheckSum);
716 H_PUT_16 (abfd, extra->Subsystem, aouthdr_out->Subsystem);
717 H_PUT_16 (abfd, extra->DllCharacteristics, aouthdr_out->DllCharacteristics);
747 PUT_OPTHDR_SIZE_OF_STACK_RESERVE (abfd, extra->SizeOfStackReserve,
718 PUT_OPTHDR_SIZE_OF_STACK_RESERVE (abfd, extra->SizeOfStackReserve,
748 (bfd_byte *) aouthdr_out->SizeOfStackReserve);
719 aouthdr_out->SizeOfStackReserve);
749 PUT_OPTHDR_SIZE_OF_STACK_COMMIT (abfd, extra->SizeOfStackCommit,
720 PUT_OPTHDR_SIZE_OF_STACK_COMMIT (abfd, extra->SizeOfStackCommit,
750 (bfd_byte *) aouthdr_out->SizeOfStackCommit);
721 aouthdr_out->SizeOfStackCommit);
751 PUT_OPTHDR_SIZE_OF_HEAP_RESERVE (abfd, extra->SizeOfHeapReserve,
722 PUT_OPTHDR_SIZE_OF_HEAP_RESERVE (abfd, extra->SizeOfHeapReserve,
752 (bfd_byte *) aouthdr_out->SizeOfHeapReserve);
723 aouthdr_out->SizeOfHeapReserve);
753 PUT_OPTHDR_SIZE_OF_HEAP_COMMIT (abfd, extra->SizeOfHeapCommit,
724 PUT_OPTHDR_SIZE_OF_HEAP_COMMIT (abfd, extra->SizeOfHeapCommit,
754 (bfd_byte *) aouthdr_out->SizeOfHeapCommit);
755 bfd_h_put_32 (abfd, extra->LoaderFlags,
756 (bfd_byte *) aouthdr_out->LoaderFlags);
757 bfd_h_put_32 (abfd, extra->NumberOfRvaAndSizes,
758 (bfd_byte *) aouthdr_out->NumberOfRvaAndSizes);
725 aouthdr_out->SizeOfHeapCommit);
726 H_PUT_32 (abfd, extra->LoaderFlags, aouthdr_out->LoaderFlags);
727 H_PUT_32 (abfd, extra->NumberOfRvaAndSizes,
728 aouthdr_out->NumberOfRvaAndSizes);
759 {
760 int idx;
729 {
730 int idx;
731
761 for (idx = 0; idx < 16; idx++)
762 {
732 for (idx = 0; idx < 16; idx++)
733 {
763 bfd_h_put_32 (abfd, extra->DataDirectory[idx].VirtualAddress,
764 (bfd_byte *) aouthdr_out->DataDirectory[idx][0]);
765 bfd_h_put_32 (abfd, extra->DataDirectory[idx].Size,
766 (bfd_byte *) aouthdr_out->DataDirectory[idx][1]);
734 H_PUT_32 (abfd, extra->DataDirectory[idx].VirtualAddress,
735 aouthdr_out->DataDirectory[idx][0]);
736 H_PUT_32 (abfd, extra->DataDirectory[idx].Size,
737 aouthdr_out->DataDirectory[idx][1]);
767 }
768 }
769
770 return AOUTSZ;
771}
772
773unsigned int
774_bfd_XXi_only_swap_filehdr_out (abfd, in, out)

--- 52 unchanged lines hidden (view full) ---

827 filehdr_in->pe.dos_message[10] = 0x206e6920;
828 filehdr_in->pe.dos_message[11] = 0x20534f44;
829 filehdr_in->pe.dos_message[12] = 0x65646f6d;
830 filehdr_in->pe.dos_message[13] = 0x0a0d0d2e;
831 filehdr_in->pe.dos_message[14] = 0x24;
832 filehdr_in->pe.dos_message[15] = 0x0;
833 filehdr_in->pe.nt_signature = NT_SIGNATURE;
834
738 }
739 }
740
741 return AOUTSZ;
742}
743
744unsigned int
745_bfd_XXi_only_swap_filehdr_out (abfd, in, out)

--- 52 unchanged lines hidden (view full) ---

798 filehdr_in->pe.dos_message[10] = 0x206e6920;
799 filehdr_in->pe.dos_message[11] = 0x20534f44;
800 filehdr_in->pe.dos_message[12] = 0x65646f6d;
801 filehdr_in->pe.dos_message[13] = 0x0a0d0d2e;
802 filehdr_in->pe.dos_message[14] = 0x24;
803 filehdr_in->pe.dos_message[15] = 0x0;
804 filehdr_in->pe.nt_signature = NT_SIGNATURE;
805
835 bfd_h_put_16 (abfd, filehdr_in->f_magic, (bfd_byte *) filehdr_out->f_magic);
836 bfd_h_put_16 (abfd, filehdr_in->f_nscns, (bfd_byte *) filehdr_out->f_nscns);
806 H_PUT_16 (abfd, filehdr_in->f_magic, filehdr_out->f_magic);
807 H_PUT_16 (abfd, filehdr_in->f_nscns, filehdr_out->f_nscns);
837
808
838 bfd_h_put_32 (abfd, time (0), (bfd_byte *) filehdr_out->f_timdat);
839 PUT_FILEHDR_SYMPTR (abfd, (bfd_vma) filehdr_in->f_symptr,
840 (bfd_byte *) filehdr_out->f_symptr);
841 bfd_h_put_32 (abfd, filehdr_in->f_nsyms, (bfd_byte *) filehdr_out->f_nsyms);
842 bfd_h_put_16 (abfd, filehdr_in->f_opthdr, (bfd_byte *) filehdr_out->f_opthdr);
843 bfd_h_put_16 (abfd, filehdr_in->f_flags, (bfd_byte *) filehdr_out->f_flags);
809 H_PUT_32 (abfd, time (0), filehdr_out->f_timdat);
810 PUT_FILEHDR_SYMPTR (abfd, filehdr_in->f_symptr,
811 filehdr_out->f_symptr);
812 H_PUT_32 (abfd, filehdr_in->f_nsyms, filehdr_out->f_nsyms);
813 H_PUT_16 (abfd, filehdr_in->f_opthdr, filehdr_out->f_opthdr);
814 H_PUT_16 (abfd, filehdr_in->f_flags, filehdr_out->f_flags);
844
815
845 /* put in extra dos header stuff. This data remains essentially
816 /* Put in extra dos header stuff. This data remains essentially
846 constant, it just has to be tacked on to the beginning of all exes
817 constant, it just has to be tacked on to the beginning of all exes
847 for NT */
848 bfd_h_put_16 (abfd, filehdr_in->pe.e_magic, (bfd_byte *) filehdr_out->e_magic);
849 bfd_h_put_16 (abfd, filehdr_in->pe.e_cblp, (bfd_byte *) filehdr_out->e_cblp);
850 bfd_h_put_16 (abfd, filehdr_in->pe.e_cp, (bfd_byte *) filehdr_out->e_cp);
851 bfd_h_put_16 (abfd, filehdr_in->pe.e_crlc, (bfd_byte *) filehdr_out->e_crlc);
852 bfd_h_put_16 (abfd, filehdr_in->pe.e_cparhdr,
853 (bfd_byte *) filehdr_out->e_cparhdr);
854 bfd_h_put_16 (abfd, filehdr_in->pe.e_minalloc,
855 (bfd_byte *) filehdr_out->e_minalloc);
856 bfd_h_put_16 (abfd, filehdr_in->pe.e_maxalloc,
857 (bfd_byte *) filehdr_out->e_maxalloc);
858 bfd_h_put_16 (abfd, filehdr_in->pe.e_ss, (bfd_byte *) filehdr_out->e_ss);
859 bfd_h_put_16 (abfd, filehdr_in->pe.e_sp, (bfd_byte *) filehdr_out->e_sp);
860 bfd_h_put_16 (abfd, filehdr_in->pe.e_csum, (bfd_byte *) filehdr_out->e_csum);
861 bfd_h_put_16 (abfd, filehdr_in->pe.e_ip, (bfd_byte *) filehdr_out->e_ip);
862 bfd_h_put_16 (abfd, filehdr_in->pe.e_cs, (bfd_byte *) filehdr_out->e_cs);
863 bfd_h_put_16 (abfd, filehdr_in->pe.e_lfarlc, (bfd_byte *) filehdr_out->e_lfarlc);
864 bfd_h_put_16 (abfd, filehdr_in->pe.e_ovno, (bfd_byte *) filehdr_out->e_ovno);
865 {
866 int idx;
867 for (idx = 0; idx < 4; idx++)
868 bfd_h_put_16 (abfd, filehdr_in->pe.e_res[idx],
869 (bfd_byte *) filehdr_out->e_res[idx]);
870 }
871 bfd_h_put_16 (abfd, filehdr_in->pe.e_oemid, (bfd_byte *) filehdr_out->e_oemid);
872 bfd_h_put_16 (abfd, filehdr_in->pe.e_oeminfo,
873 (bfd_byte *) filehdr_out->e_oeminfo);
874 {
875 int idx;
876 for (idx = 0; idx < 10; idx++)
877 bfd_h_put_16 (abfd, filehdr_in->pe.e_res2[idx],
878 (bfd_byte *) filehdr_out->e_res2[idx]);
879 }
880 bfd_h_put_32 (abfd, filehdr_in->pe.e_lfanew, (bfd_byte *) filehdr_out->e_lfanew);
818 for NT. */
819 H_PUT_16 (abfd, filehdr_in->pe.e_magic, filehdr_out->e_magic);
820 H_PUT_16 (abfd, filehdr_in->pe.e_cblp, filehdr_out->e_cblp);
821 H_PUT_16 (abfd, filehdr_in->pe.e_cp, filehdr_out->e_cp);
822 H_PUT_16 (abfd, filehdr_in->pe.e_crlc, filehdr_out->e_crlc);
823 H_PUT_16 (abfd, filehdr_in->pe.e_cparhdr, filehdr_out->e_cparhdr);
824 H_PUT_16 (abfd, filehdr_in->pe.e_minalloc, filehdr_out->e_minalloc);
825 H_PUT_16 (abfd, filehdr_in->pe.e_maxalloc, filehdr_out->e_maxalloc);
826 H_PUT_16 (abfd, filehdr_in->pe.e_ss, filehdr_out->e_ss);
827 H_PUT_16 (abfd, filehdr_in->pe.e_sp, filehdr_out->e_sp);
828 H_PUT_16 (abfd, filehdr_in->pe.e_csum, filehdr_out->e_csum);
829 H_PUT_16 (abfd, filehdr_in->pe.e_ip, filehdr_out->e_ip);
830 H_PUT_16 (abfd, filehdr_in->pe.e_cs, filehdr_out->e_cs);
831 H_PUT_16 (abfd, filehdr_in->pe.e_lfarlc, filehdr_out->e_lfarlc);
832 H_PUT_16 (abfd, filehdr_in->pe.e_ovno, filehdr_out->e_ovno);
881
833
882 {
883 int idx;
884 for (idx = 0; idx < 16; idx++)
885 bfd_h_put_32 (abfd, filehdr_in->pe.dos_message[idx],
886 (bfd_byte *) filehdr_out->dos_message[idx]);
887 }
834 for (idx = 0; idx < 4; idx++)
835 H_PUT_16 (abfd, filehdr_in->pe.e_res[idx], filehdr_out->e_res[idx]);
888
836
837 H_PUT_16 (abfd, filehdr_in->pe.e_oemid, filehdr_out->e_oemid);
838 H_PUT_16 (abfd, filehdr_in->pe.e_oeminfo, filehdr_out->e_oeminfo);
839
840 for (idx = 0; idx < 10; idx++)
841 H_PUT_16 (abfd, filehdr_in->pe.e_res2[idx], filehdr_out->e_res2[idx]);
842
843 H_PUT_32 (abfd, filehdr_in->pe.e_lfanew, filehdr_out->e_lfanew);
844
845 for (idx = 0; idx < 16; idx++)
846 H_PUT_32 (abfd, filehdr_in->pe.dos_message[idx],
847 filehdr_out->dos_message[idx]);
848
889 /* Also put in the NT signature. */
849 /* Also put in the NT signature. */
890 bfd_h_put_32 (abfd, filehdr_in->pe.nt_signature,
891 (bfd_byte *) filehdr_out->nt_signature);
850 H_PUT_32 (abfd, filehdr_in->pe.nt_signature, filehdr_out->nt_signature);
892
893 return FILHSZ;
894}
895
896unsigned int
897_bfd_XX_only_swap_filehdr_out (abfd, in, out)
898 bfd *abfd;
899 PTR in;
900 PTR out;
901{
902 struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in;
903 FILHDR *filehdr_out = (FILHDR *) out;
904
851
852 return FILHSZ;
853}
854
855unsigned int
856_bfd_XX_only_swap_filehdr_out (abfd, in, out)
857 bfd *abfd;
858 PTR in;
859 PTR out;
860{
861 struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in;
862 FILHDR *filehdr_out = (FILHDR *) out;
863
905 bfd_h_put_16 (abfd, filehdr_in->f_magic, (bfd_byte *) filehdr_out->f_magic);
906 bfd_h_put_16 (abfd, filehdr_in->f_nscns, (bfd_byte *) filehdr_out->f_nscns);
907 bfd_h_put_32 (abfd, filehdr_in->f_timdat, (bfd_byte *) filehdr_out->f_timdat);
908 PUT_FILEHDR_SYMPTR (abfd, (bfd_vma) filehdr_in->f_symptr,
909 (bfd_byte *) filehdr_out->f_symptr);
910 bfd_h_put_32 (abfd, filehdr_in->f_nsyms, (bfd_byte *) filehdr_out->f_nsyms);
911 bfd_h_put_16 (abfd, filehdr_in->f_opthdr, (bfd_byte *) filehdr_out->f_opthdr);
912 bfd_h_put_16 (abfd, filehdr_in->f_flags, (bfd_byte *) filehdr_out->f_flags);
864 H_PUT_16 (abfd, filehdr_in->f_magic, filehdr_out->f_magic);
865 H_PUT_16 (abfd, filehdr_in->f_nscns, filehdr_out->f_nscns);
866 H_PUT_32 (abfd, filehdr_in->f_timdat, filehdr_out->f_timdat);
867 PUT_FILEHDR_SYMPTR (abfd, filehdr_in->f_symptr, filehdr_out->f_symptr);
868 H_PUT_32 (abfd, filehdr_in->f_nsyms, filehdr_out->f_nsyms);
869 H_PUT_16 (abfd, filehdr_in->f_opthdr, filehdr_out->f_opthdr);
870 H_PUT_16 (abfd, filehdr_in->f_flags, filehdr_out->f_flags);
913
914 return FILHSZ;
915}
916
917unsigned int
918_bfd_XXi_swap_scnhdr_out (abfd, in, out)
919 bfd *abfd;
920 PTR in;

--- 6 unchanged lines hidden (view full) ---

927 bfd_vma ss;
928
929 memcpy (scnhdr_ext->s_name, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
930
931 PUT_SCNHDR_VADDR (abfd,
932 ((scnhdr_int->s_vaddr
933 - pe_data (abfd)->pe_opthdr.ImageBase)
934 & 0xffffffff),
871
872 return FILHSZ;
873}
874
875unsigned int
876_bfd_XXi_swap_scnhdr_out (abfd, in, out)
877 bfd *abfd;
878 PTR in;

--- 6 unchanged lines hidden (view full) ---

885 bfd_vma ss;
886
887 memcpy (scnhdr_ext->s_name, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
888
889 PUT_SCNHDR_VADDR (abfd,
890 ((scnhdr_int->s_vaddr
891 - pe_data (abfd)->pe_opthdr.ImageBase)
892 & 0xffffffff),
935 (bfd_byte *) scnhdr_ext->s_vaddr);
893 scnhdr_ext->s_vaddr);
936
937 /* NT wants the size data to be rounded up to the next
938 NT_FILE_ALIGNMENT, but zero if it has no content (as in .bss,
939 sometimes). */
894
895 /* NT wants the size data to be rounded up to the next
896 NT_FILE_ALIGNMENT, but zero if it has no content (as in .bss,
897 sometimes). */
940
941 if ((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0)
942 {
943 ps = scnhdr_int->s_size;
944 ss = 0;
945 }
946 else
947 {
948 ps = scnhdr_int->s_paddr;
949 ss = scnhdr_int->s_size;
950 }
951
952 PUT_SCNHDR_SIZE (abfd, ss,
898 if ((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0)
899 {
900 ps = scnhdr_int->s_size;
901 ss = 0;
902 }
903 else
904 {
905 ps = scnhdr_int->s_paddr;
906 ss = scnhdr_int->s_size;
907 }
908
909 PUT_SCNHDR_SIZE (abfd, ss,
953 (bfd_byte *) scnhdr_ext->s_size);
910 scnhdr_ext->s_size);
954
955 /* s_paddr in PE is really the virtual size. */
911
912 /* s_paddr in PE is really the virtual size. */
956 PUT_SCNHDR_PADDR (abfd, ps, (bfd_byte *) scnhdr_ext->s_paddr);
913 PUT_SCNHDR_PADDR (abfd, ps, scnhdr_ext->s_paddr);
957
958 PUT_SCNHDR_SCNPTR (abfd, scnhdr_int->s_scnptr,
914
915 PUT_SCNHDR_SCNPTR (abfd, scnhdr_int->s_scnptr,
959 (bfd_byte *) scnhdr_ext->s_scnptr);
916 scnhdr_ext->s_scnptr);
960 PUT_SCNHDR_RELPTR (abfd, scnhdr_int->s_relptr,
917 PUT_SCNHDR_RELPTR (abfd, scnhdr_int->s_relptr,
961 (bfd_byte *) scnhdr_ext->s_relptr);
918 scnhdr_ext->s_relptr);
962 PUT_SCNHDR_LNNOPTR (abfd, scnhdr_int->s_lnnoptr,
919 PUT_SCNHDR_LNNOPTR (abfd, scnhdr_int->s_lnnoptr,
963 (bfd_byte *) scnhdr_ext->s_lnnoptr);
920 scnhdr_ext->s_lnnoptr);
964
965 /* Extra flags must be set when dealing with NT. All sections should also
966 have the IMAGE_SCN_MEM_READ (0x40000000) flag set. In addition, the
967 .text section must have IMAGE_SCN_MEM_EXECUTE (0x20000000) and the data
968 sections (.idata, .data, .bss, .CRT) must have IMAGE_SCN_MEM_WRITE set
969 (this is especially important when dealing with the .idata section since
970 the addresses for routines from .dlls must be overwritten). If .reloc
971 section data is ever generated, we must add IMAGE_SCN_MEM_DISCARDABLE
972 (0x02000000). Also, the resource data should also be read and
973 writable. */
974
975 /* FIXME: alignment is also encoded in this field, at least on ppc (krk) */
976 /* FIXME: even worse, I don't see how to get the original alignment field*/
977 /* back... */
978
979 {
980 int flags = scnhdr_int->s_flags;
921
922 /* Extra flags must be set when dealing with NT. All sections should also
923 have the IMAGE_SCN_MEM_READ (0x40000000) flag set. In addition, the
924 .text section must have IMAGE_SCN_MEM_EXECUTE (0x20000000) and the data
925 sections (.idata, .data, .bss, .CRT) must have IMAGE_SCN_MEM_WRITE set
926 (this is especially important when dealing with the .idata section since
927 the addresses for routines from .dlls must be overwritten). If .reloc
928 section data is ever generated, we must add IMAGE_SCN_MEM_DISCARDABLE
929 (0x02000000). Also, the resource data should also be read and
930 writable. */
931
932 /* FIXME: alignment is also encoded in this field, at least on ppc (krk) */
933 /* FIXME: even worse, I don't see how to get the original alignment field*/
934 /* back... */
935
936 {
937 int flags = scnhdr_int->s_flags;
981 bfd_h_put_32 (abfd, flags, (bfd_byte *) scnhdr_ext->s_flags);
938
939 H_PUT_32 (abfd, flags, scnhdr_ext->s_flags);
982 }
983
984 if (coff_data (abfd)->link_info
985 && ! coff_data (abfd)->link_info->relocateable
986 && ! coff_data (abfd)->link_info->shared
987 && strcmp (scnhdr_int->s_name, ".text") == 0)
988 {
989 /* By inference from looking at MS output, the 32 bit field
990 which is the combintion of the number_of_relocs and
991 number_of_linenos is used for the line number count in
992 executables. A 16-bit field won't do for cc1. The MS
993 document says that the number of relocs is zero for
994 executables, but the 17-th bit has been observed to be there.
995 Overflow is not an issue: a 4G-line program will overflow a
996 bunch of other fields long before this! */
940 }
941
942 if (coff_data (abfd)->link_info
943 && ! coff_data (abfd)->link_info->relocateable
944 && ! coff_data (abfd)->link_info->shared
945 && strcmp (scnhdr_int->s_name, ".text") == 0)
946 {
947 /* By inference from looking at MS output, the 32 bit field
948 which is the combintion of the number_of_relocs and
949 number_of_linenos is used for the line number count in
950 executables. A 16-bit field won't do for cc1. The MS
951 document says that the number of relocs is zero for
952 executables, but the 17-th bit has been observed to be there.
953 Overflow is not an issue: a 4G-line program will overflow a
954 bunch of other fields long before this! */
997 bfd_h_put_16 (abfd, scnhdr_int->s_nlnno & 0xffff,
998 (bfd_byte *) scnhdr_ext->s_nlnno);
999 bfd_h_put_16 (abfd, scnhdr_int->s_nlnno >> 16,
1000 (bfd_byte *) scnhdr_ext->s_nreloc);
955 H_PUT_16 (abfd, (scnhdr_int->s_nlnno & 0xffff), scnhdr_ext->s_nlnno);
956 H_PUT_16 (abfd, (scnhdr_int->s_nlnno >> 16), scnhdr_ext->s_nreloc);
1001 }
1002 else
1003 {
1004 if (scnhdr_int->s_nlnno <= 0xffff)
957 }
958 else
959 {
960 if (scnhdr_int->s_nlnno <= 0xffff)
1005 bfd_h_put_16 (abfd, scnhdr_int->s_nlnno,
1006 (bfd_byte *) scnhdr_ext->s_nlnno);
961 H_PUT_16 (abfd, scnhdr_int->s_nlnno, scnhdr_ext->s_nlnno);
1007 else
1008 {
1009 (*_bfd_error_handler) (_("%s: line number overflow: 0x%lx > 0xffff"),
1010 bfd_get_filename (abfd),
1011 scnhdr_int->s_nlnno);
1012 bfd_set_error (bfd_error_file_truncated);
962 else
963 {
964 (*_bfd_error_handler) (_("%s: line number overflow: 0x%lx > 0xffff"),
965 bfd_get_filename (abfd),
966 scnhdr_int->s_nlnno);
967 bfd_set_error (bfd_error_file_truncated);
1013 bfd_h_put_16 (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nlnno);
968 H_PUT_16 (abfd, 0xffff, scnhdr_ext->s_nlnno);
1014 ret = 0;
1015 }
969 ret = 0;
970 }
971
1016 if (scnhdr_int->s_nreloc <= 0xffff)
972 if (scnhdr_int->s_nreloc <= 0xffff)
1017 bfd_h_put_16 (abfd, scnhdr_int->s_nreloc,
1018 (bfd_byte *) scnhdr_ext->s_nreloc);
973 H_PUT_16 (abfd, scnhdr_int->s_nreloc, scnhdr_ext->s_nreloc);
1019 else
1020 {
974 else
975 {
1021 /* PE can deal with large #s of relocs, but not here */
1022 bfd_h_put_16 (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nreloc);
976 /* PE can deal with large #s of relocs, but not here. */
977 H_PUT_16 (abfd, 0xffff, scnhdr_ext->s_nreloc);
1023 scnhdr_int->s_flags |= IMAGE_SCN_LNK_NRELOC_OVFL;
978 scnhdr_int->s_flags |= IMAGE_SCN_LNK_NRELOC_OVFL;
1024 bfd_h_put_32 (abfd, scnhdr_int->s_flags,
1025 (bfd_byte *) scnhdr_ext->s_flags);
979 H_PUT_32 (abfd, scnhdr_int->s_flags, scnhdr_ext->s_flags);
1026#if 0
1027 (*_bfd_error_handler) (_("%s: reloc overflow 1: 0x%lx > 0xffff"),
1028 bfd_get_filename (abfd),
1029 scnhdr_int->s_nreloc);
1030 bfd_set_error (bfd_error_file_truncated);
980#if 0
981 (*_bfd_error_handler) (_("%s: reloc overflow 1: 0x%lx > 0xffff"),
982 bfd_get_filename (abfd),
983 scnhdr_int->s_nreloc);
984 bfd_set_error (bfd_error_file_truncated);
1031 bfd_h_put_16 (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nreloc);
985 H_PUT_16 (abfd, 0xffff, scnhdr_ext->s_nreloc);
1032 ret = 0;
1033#endif
1034 }
1035 }
1036 return ret;
1037}
1038
986 ret = 0;
987#endif
988 }
989 }
990 return ret;
991}
992
1039static char * dir_names[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] = {
1040 N_("Export Directory [.edata (or where ever we found it)]"),
1041 N_("Import Directory [parts of .idata]"),
1042 N_("Resource Directory [.rsrc]"),
1043 N_("Exception Directory [.pdata]"),
1044 N_("Security Directory"),
1045 N_("Base Relocation Directory [.reloc]"),
1046 N_("Debug Directory"),
1047 N_("Description Directory"),
1048 N_("Special Directory"),
1049 N_("Thread Storage Directory [.tls]"),
1050 N_("Load Configuration Directory"),
1051 N_("Bound Import Directory"),
1052 N_("Import Address Table Directory"),
1053 N_("Delay Import Directory"),
1054 N_("Reserved"),
1055 N_("Reserved")
1056};
993static char * dir_names[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] =
994 {
995 N_("Export Directory [.edata (or where ever we found it)]"),
996 N_("Import Directory [parts of .idata]"),
997 N_("Resource Directory [.rsrc]"),
998 N_("Exception Directory [.pdata]"),
999 N_("Security Directory"),
1000 N_("Base Relocation Directory [.reloc]"),
1001 N_("Debug Directory"),
1002 N_("Description Directory"),
1003 N_("Special Directory"),
1004 N_("Thread Storage Directory [.tls]"),
1005 N_("Load Configuration Directory"),
1006 N_("Bound Import Directory"),
1007 N_("Import Address Table Directory"),
1008 N_("Delay Import Directory"),
1009 N_("Reserved"),
1010 N_("Reserved")
1011 };
1057
1012
1058/**********************************************************************/
1059#ifdef POWERPC_LE_PE
1060/* The code for the PPC really falls in the "architecture dependent"
1061 category. However, it's not clear that anyone will ever care, so
1062 we're ignoring the issue for now; if/when PPC matters, some of this
1063 may need to go into peicode.h, or arguments passed to enable the
1064 PPC- specific code. */
1065#endif
1066
1013#ifdef POWERPC_LE_PE
1014/* The code for the PPC really falls in the "architecture dependent"
1015 category. However, it's not clear that anyone will ever care, so
1016 we're ignoring the issue for now; if/when PPC matters, some of this
1017 may need to go into peicode.h, or arguments passed to enable the
1018 PPC- specific code. */
1019#endif
1020
1067/**********************************************************************/
1068static boolean
1069pe_print_idata (abfd, vfile)
1070 bfd *abfd;
1071 PTR vfile;
1072{
1073 FILE *file = (FILE *) vfile;
1074 bfd_byte *data;
1075 asection *section;
1076 bfd_signed_vma adj;
1077
1078#ifdef POWERPC_LE_PE
1079 asection *rel_section = bfd_get_section_by_name (abfd, ".reldata");
1080#endif
1081
1082 bfd_size_type datasize = 0;
1083 bfd_size_type dataoff;
1084 bfd_size_type i;
1021static boolean
1022pe_print_idata (abfd, vfile)
1023 bfd *abfd;
1024 PTR vfile;
1025{
1026 FILE *file = (FILE *) vfile;
1027 bfd_byte *data;
1028 asection *section;
1029 bfd_signed_vma adj;
1030
1031#ifdef POWERPC_LE_PE
1032 asection *rel_section = bfd_get_section_by_name (abfd, ".reldata");
1033#endif
1034
1035 bfd_size_type datasize = 0;
1036 bfd_size_type dataoff;
1037 bfd_size_type i;
1038 bfd_size_type amt;
1085 int onaline = 20;
1086
1087 pe_data_type *pe = pe_data (abfd);
1088 struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr;
1089
1090 bfd_vma addr;
1091
1092 addr = extra->DataDirectory[1].VirtualAddress;

--- 45 unchanged lines hidden (view full) ---

1138 .reldata section. */
1139
1140 bfd_vma loadable_toc_address;
1141 bfd_vma toc_address;
1142 bfd_vma start_address;
1143 bfd_byte *data = 0;
1144 int offset;
1145
1039 int onaline = 20;
1040
1041 pe_data_type *pe = pe_data (abfd);
1042 struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr;
1043
1044 bfd_vma addr;
1045
1046 addr = extra->DataDirectory[1].VirtualAddress;

--- 45 unchanged lines hidden (view full) ---

1092 .reldata section. */
1093
1094 bfd_vma loadable_toc_address;
1095 bfd_vma toc_address;
1096 bfd_vma start_address;
1097 bfd_byte *data = 0;
1098 int offset;
1099
1146 data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd,
1147 rel_section));
1148 if (data == NULL && bfd_section_size (abfd, rel_section) != 0)
1100 amt = bfd_section_size (abfd, rel_section);
1101 data = (bfd_byte *) bfd_malloc (amt);
1102 if (data == NULL && amt != 0)
1149 return false;
1150
1103 return false;
1104
1151 bfd_get_section_contents (abfd,
1152 rel_section,
1153 (PTR) data, 0,
1154 bfd_section_size (abfd, rel_section));
1105 bfd_get_section_contents (abfd, rel_section, (PTR) data, (bfd_vma) 0,
1106 amt);
1155
1156 offset = abfd->start_address - rel_section->vma;
1157
1158 start_address = bfd_get_32 (abfd, data + offset);
1159 loadable_toc_address = bfd_get_32 (abfd, data + offset + 4);
1160 toc_address = loadable_toc_address - 32768;
1161
1162 fprintf (file,

--- 13 unchanged lines hidden (view full) ---

1176 fprintf (file,
1177 _("\nThe Import Tables (interpreted %s section contents)\n"),
1178 section->name);
1179 fprintf (file,
1180 _(" vma: Hint Time Forward DLL First\n"));
1181 fprintf (file,
1182 _(" Table Stamp Chain Name Thunk\n"));
1183
1107
1108 offset = abfd->start_address - rel_section->vma;
1109
1110 start_address = bfd_get_32 (abfd, data + offset);
1111 loadable_toc_address = bfd_get_32 (abfd, data + offset + 4);
1112 toc_address = loadable_toc_address - 32768;
1113
1114 fprintf (file,

--- 13 unchanged lines hidden (view full) ---

1128 fprintf (file,
1129 _("\nThe Import Tables (interpreted %s section contents)\n"),
1130 section->name);
1131 fprintf (file,
1132 _(" vma: Hint Time Forward DLL First\n"));
1133 fprintf (file,
1134 _(" Table Stamp Chain Name Thunk\n"));
1135
1184 data = (bfd_byte *) bfd_malloc (dataoff + datasize);
1136 amt = dataoff + datasize;
1137 data = (bfd_byte *) bfd_malloc (amt);
1185 if (data == NULL)
1186 return false;
1187
1188 /* Read the whole section. Some of the fields might be before dataoff. */
1138 if (data == NULL)
1139 return false;
1140
1141 /* Read the whole section. Some of the fields might be before dataoff. */
1189 if (! bfd_get_section_contents (abfd, section, (PTR) data,
1190 0, dataoff + datasize))
1142 if (! bfd_get_section_contents (abfd, section, (PTR) data, (bfd_vma) 0, amt))
1191 return false;
1192
1193 adj = section->vma - extra->ImageBase;
1194
1195 for (i = 0; i < datasize; i += onaline)
1196 {
1197 bfd_vma hint_addr;
1198 bfd_vma time_stamp;
1199 bfd_vma forward_chain;
1200 bfd_vma dll_name;
1201 bfd_vma first_thunk;
1202 int idx = 0;
1203 bfd_size_type j;
1204 char *dll;
1205
1206 /* print (i + extra->DataDirectory[1].VirtualAddress) */
1207 fprintf (file, " %08lx\t", (unsigned long) (i + adj + dataoff));
1143 return false;
1144
1145 adj = section->vma - extra->ImageBase;
1146
1147 for (i = 0; i < datasize; i += onaline)
1148 {
1149 bfd_vma hint_addr;
1150 bfd_vma time_stamp;
1151 bfd_vma forward_chain;
1152 bfd_vma dll_name;
1153 bfd_vma first_thunk;
1154 int idx = 0;
1155 bfd_size_type j;
1156 char *dll;
1157
1158 /* print (i + extra->DataDirectory[1].VirtualAddress) */
1159 fprintf (file, " %08lx\t", (unsigned long) (i + adj + dataoff));
1208
1160#if 0
1209 if (i + 20 > datasize)
1161 if (i + 20 > datasize)
1210 {
1211 /* Check stuff. */
1212 ;
1213 }
1214
1162 /* Check stuff. */
1163 ;
1164#endif
1215 hint_addr = bfd_get_32 (abfd, data + i + dataoff);
1216 time_stamp = bfd_get_32 (abfd, data + i + 4 + dataoff);
1217 forward_chain = bfd_get_32 (abfd, data + i + 8 + dataoff);
1218 dll_name = bfd_get_32 (abfd, data + i + 12 + dataoff);
1219 first_thunk = bfd_get_32 (abfd, data + i + 16 + dataoff);
1220
1221 fprintf (file, "%08lx %08lx %08lx %08lx %08lx\n",
1222 (unsigned long) hint_addr,

--- 71 unchanged lines hidden (view full) ---

1294 {
1295 if (differ == 0)
1296 {
1297 fprintf (file,
1298 _("\tThe Import Address Table (difference found)\n"));
1299 fprintf (file, _("\tvma: Hint/Ord Member-Name\n"));
1300 differ = 1;
1301 }
1165 hint_addr = bfd_get_32 (abfd, data + i + dataoff);
1166 time_stamp = bfd_get_32 (abfd, data + i + 4 + dataoff);
1167 forward_chain = bfd_get_32 (abfd, data + i + 8 + dataoff);
1168 dll_name = bfd_get_32 (abfd, data + i + 12 + dataoff);
1169 first_thunk = bfd_get_32 (abfd, data + i + 16 + dataoff);
1170
1171 fprintf (file, "%08lx %08lx %08lx %08lx %08lx\n",
1172 (unsigned long) hint_addr,

--- 71 unchanged lines hidden (view full) ---

1244 {
1245 if (differ == 0)
1246 {
1247 fprintf (file,
1248 _("\tThe Import Address Table (difference found)\n"));
1249 fprintf (file, _("\tvma: Hint/Ord Member-Name\n"));
1250 differ = 1;
1251 }
1252
1302 if (iat_member == 0)
1253 if (iat_member == 0)
1303 {
1304 fprintf (file,
1305 _("\t>>> Ran out of IAT members!\n"));
1306 }
1254 fprintf (file,
1255 _("\t>>> Ran out of IAT members!\n"));
1307 else
1308 {
1309 ordinal = bfd_get_16 (abfd, data + iat_member - adj);
1310 member_name = (char *) data + iat_member - adj + 2;
1311 fprintf (file, "\t%04lx\t %4d %s\n",
1312 (unsigned long) iat_member,
1313 ordinal,
1314 member_name);
1315 }
1316 }
1317
1318 if (hint_addr != 0 && hint_member == 0)
1319 break;
1320 }
1256 else
1257 {
1258 ordinal = bfd_get_16 (abfd, data + iat_member - adj);
1259 member_name = (char *) data + iat_member - adj + 2;
1260 fprintf (file, "\t%04lx\t %4d %s\n",
1261 (unsigned long) iat_member,
1262 ordinal,
1263 member_name);
1264 }
1265 }
1266
1267 if (hint_addr != 0 && hint_member == 0)
1268 break;
1269 }
1270
1321 if (differ == 0)
1271 if (differ == 0)
1322 {
1323 fprintf (file,
1324 _("\tThe Import Address Table is identical\n"));
1325 }
1272 fprintf (file,
1273 _("\tThe Import Address Table is identical\n"));
1326 }
1327
1328 fprintf (file, "\n");
1274 }
1275
1276 fprintf (file, "\n");
1329
1330 }
1331
1332 free (data);
1333
1334 return true;
1335}
1336
1337static boolean
1338pe_print_edata (abfd, vfile)
1339 bfd *abfd;
1340 PTR vfile;
1341{
1342 FILE *file = (FILE *) vfile;
1343 bfd_byte *data;
1344 asection *section;
1277 }
1278
1279 free (data);
1280
1281 return true;
1282}
1283
1284static boolean
1285pe_print_edata (abfd, vfile)
1286 bfd *abfd;
1287 PTR vfile;
1288{
1289 FILE *file = (FILE *) vfile;
1290 bfd_byte *data;
1291 asection *section;
1345
1346 bfd_size_type datasize = 0;
1347 bfd_size_type dataoff;
1348 bfd_size_type i;
1292 bfd_size_type datasize = 0;
1293 bfd_size_type dataoff;
1294 bfd_size_type i;
1349
1350 bfd_signed_vma adj;
1295 bfd_signed_vma adj;
1351 struct EDT_type {
1352 long export_flags; /* reserved - should be zero */
1296 struct EDT_type
1297 {
1298 long export_flags; /* reserved - should be zero */
1353 long time_stamp;
1354 short major_ver;
1355 short minor_ver;
1299 long time_stamp;
1300 short major_ver;
1301 short minor_ver;
1356 bfd_vma name; /* rva - relative to image base */
1357 long base; /* ordinal base */
1358 unsigned long num_functions; /* Number in the export address table */
1359 unsigned long num_names; /* Number in the name pointer table */
1360 bfd_vma eat_addr; /* rva to the export address table */
1361 bfd_vma npt_addr; /* rva to the Export Name Pointer Table */
1362 bfd_vma ot_addr; /* rva to the Ordinal Table */
1302 bfd_vma name; /* rva - relative to image base */
1303 long base; /* ordinal base */
1304 unsigned long num_functions;/* Number in the export address table */
1305 unsigned long num_names; /* Number in the name pointer table */
1306 bfd_vma eat_addr; /* rva to the export address table */
1307 bfd_vma npt_addr; /* rva to the Export Name Pointer Table */
1308 bfd_vma ot_addr; /* rva to the Ordinal Table */
1363 } edt;
1364
1365 pe_data_type *pe = pe_data (abfd);
1366 struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr;
1367
1368 bfd_vma addr;
1369
1370 addr = extra->DataDirectory[0].VirtualAddress;

--- 8 unchanged lines hidden (view full) ---

1379 addr = section->vma;
1380 datasize = bfd_section_size (abfd, section);
1381 if (datasize == 0)
1382 return true;
1383 }
1384 else
1385 {
1386 addr += extra->ImageBase;
1309 } edt;
1310
1311 pe_data_type *pe = pe_data (abfd);
1312 struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr;
1313
1314 bfd_vma addr;
1315
1316 addr = extra->DataDirectory[0].VirtualAddress;

--- 8 unchanged lines hidden (view full) ---

1325 addr = section->vma;
1326 datasize = bfd_section_size (abfd, section);
1327 if (datasize == 0)
1328 return true;
1329 }
1330 else
1331 {
1332 addr += extra->ImageBase;
1333
1387 for (section = abfd->sections; section != NULL; section = section->next)
1388 {
1389 datasize = bfd_section_size (abfd, section);
1334 for (section = abfd->sections; section != NULL; section = section->next)
1335 {
1336 datasize = bfd_section_size (abfd, section);
1337
1390 if (addr >= section->vma && addr < section->vma + datasize)
1391 break;
1392 }
1393
1394 if (section == NULL)
1395 {
1396 fprintf (file,
1397 _("\nThere is an export table, but the section containing it could not be found\n"));

--- 6 unchanged lines hidden (view full) ---

1404
1405 dataoff = addr - section->vma;
1406 datasize -= dataoff;
1407
1408 data = (bfd_byte *) bfd_malloc (datasize);
1409 if (data == NULL)
1410 return false;
1411
1338 if (addr >= section->vma && addr < section->vma + datasize)
1339 break;
1340 }
1341
1342 if (section == NULL)
1343 {
1344 fprintf (file,
1345 _("\nThere is an export table, but the section containing it could not be found\n"));

--- 6 unchanged lines hidden (view full) ---

1352
1353 dataoff = addr - section->vma;
1354 datasize -= dataoff;
1355
1356 data = (bfd_byte *) bfd_malloc (datasize);
1357 if (data == NULL)
1358 return false;
1359
1412 if (! bfd_get_section_contents (abfd, section, (PTR) data, dataoff,
1413 datasize))
1360 if (! bfd_get_section_contents (abfd, section, (PTR) data,
1361 (file_ptr) dataoff, datasize))
1414 return false;
1415
1416 /* Go get Export Directory Table. */
1417 edt.export_flags = bfd_get_32 (abfd, data + 0);
1418 edt.time_stamp = bfd_get_32 (abfd, data + 4);
1419 edt.major_ver = bfd_get_16 (abfd, data + 8);
1420 edt.minor_ver = bfd_get_16 (abfd, data + 10);
1421 edt.name = bfd_get_32 (abfd, data + 12);
1422 edt.base = bfd_get_32 (abfd, data + 16);
1423 edt.num_functions = bfd_get_32 (abfd, data + 20);
1424 edt.num_names = bfd_get_32 (abfd, data + 24);
1425 edt.eat_addr = bfd_get_32 (abfd, data + 28);
1426 edt.npt_addr = bfd_get_32 (abfd, data + 32);
1427 edt.ot_addr = bfd_get_32 (abfd, data + 36);
1428
1429 adj = section->vma - extra->ImageBase + dataoff;
1430
1362 return false;
1363
1364 /* Go get Export Directory Table. */
1365 edt.export_flags = bfd_get_32 (abfd, data + 0);
1366 edt.time_stamp = bfd_get_32 (abfd, data + 4);
1367 edt.major_ver = bfd_get_16 (abfd, data + 8);
1368 edt.minor_ver = bfd_get_16 (abfd, data + 10);
1369 edt.name = bfd_get_32 (abfd, data + 12);
1370 edt.base = bfd_get_32 (abfd, data + 16);
1371 edt.num_functions = bfd_get_32 (abfd, data + 20);
1372 edt.num_names = bfd_get_32 (abfd, data + 24);
1373 edt.eat_addr = bfd_get_32 (abfd, data + 28);
1374 edt.npt_addr = bfd_get_32 (abfd, data + 32);
1375 edt.ot_addr = bfd_get_32 (abfd, data + 36);
1376
1377 adj = section->vma - extra->ImageBase + dataoff;
1378
1431 /* Dump the EDT first first */
1379 /* Dump the EDT first. */
1432 fprintf (file,
1433 _("\nThe Export Tables (interpreted %s section contents)\n\n"),
1434 section->name);
1435
1436 fprintf (file,
1437 _("Export Flags \t\t\t%lx\n"), (unsigned long) edt.export_flags);
1438
1439 fprintf (file,

--- 37 unchanged lines hidden (view full) ---

1477 fprintf (file,
1478 _("\tOrdinal Table \t\t\t"));
1479 fprintf_vma (file, edt.ot_addr);
1480 fprintf (file, "\n");
1481
1482 /* The next table to find is the Export Address Table. It's basically
1483 a list of pointers that either locate a function in this dll, or
1484 forward the call to another dll. Something like:
1380 fprintf (file,
1381 _("\nThe Export Tables (interpreted %s section contents)\n\n"),
1382 section->name);
1383
1384 fprintf (file,
1385 _("Export Flags \t\t\t%lx\n"), (unsigned long) edt.export_flags);
1386
1387 fprintf (file,

--- 37 unchanged lines hidden (view full) ---

1425 fprintf (file,
1426 _("\tOrdinal Table \t\t\t"));
1427 fprintf_vma (file, edt.ot_addr);
1428 fprintf (file, "\n");
1429
1430 /* The next table to find is the Export Address Table. It's basically
1431 a list of pointers that either locate a function in this dll, or
1432 forward the call to another dll. Something like:
1485 typedef union {
1433 typedef union
1434 {
1486 long export_rva;
1487 long forwarder_rva;
1488 } export_address_table_entry;
1489 */
1490
1491 fprintf (file,
1492 _("\nExport Address Table -- Ordinal Base %ld\n"),
1493 edt.base);

--- 97 unchanged lines hidden (view full) ---

1591 _(" vma:\t\t\tBegin Address End Address Unwind Info\n"));
1592#else
1593 fprintf (file,
1594 _(" vma:\t\tBegin End EH EH PrologEnd Exception\n"));
1595 fprintf (file,
1596 _(" \t\tAddress Address Handler Data Address Mask\n"));
1597#endif
1598
1435 long export_rva;
1436 long forwarder_rva;
1437 } export_address_table_entry;
1438 */
1439
1440 fprintf (file,
1441 _("\nExport Address Table -- Ordinal Base %ld\n"),
1442 edt.base);

--- 97 unchanged lines hidden (view full) ---

1540 _(" vma:\t\t\tBegin Address End Address Unwind Info\n"));
1541#else
1542 fprintf (file,
1543 _(" vma:\t\tBegin End EH EH PrologEnd Exception\n"));
1544 fprintf (file,
1545 _(" \t\tAddress Address Handler Data Address Mask\n"));
1546#endif
1547
1599 if (bfd_section_size (abfd, section) == 0)
1548 datasize = bfd_section_size (abfd, section);
1549 if (datasize == 0)
1600 return true;
1601
1550 return true;
1551
1602 data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd, section));
1603 datasize = bfd_section_size (abfd, section);
1552 data = (bfd_byte *) bfd_malloc (datasize);
1604 if (data == NULL && datasize != 0)
1605 return false;
1606
1553 if (data == NULL && datasize != 0)
1554 return false;
1555
1607 bfd_get_section_contents (abfd,
1608 section,
1609 (PTR) data, 0,
1610 bfd_section_size (abfd, section));
1556 bfd_get_section_contents (abfd, section, (PTR) data, (bfd_vma) 0,
1557 datasize);
1611
1612 start = 0;
1613
1614 for (i = start; i < stop; i += onaline)
1615 {
1616 bfd_vma begin_addr;
1617 bfd_vma end_addr;
1618 bfd_vma eh_handler;

--- 7 unchanged lines hidden (view full) ---

1626 begin_addr = GET_PDATA_ENTRY (abfd, data + i );
1627 end_addr = GET_PDATA_ENTRY (abfd, data + i + 4);
1628 eh_handler = GET_PDATA_ENTRY (abfd, data + i + 8);
1629 eh_data = GET_PDATA_ENTRY (abfd, data + i + 12);
1630 prolog_end_addr = GET_PDATA_ENTRY (abfd, data + i + 16);
1631
1632 if (begin_addr == 0 && end_addr == 0 && eh_handler == 0
1633 && eh_data == 0 && prolog_end_addr == 0)
1558
1559 start = 0;
1560
1561 for (i = start; i < stop; i += onaline)
1562 {
1563 bfd_vma begin_addr;
1564 bfd_vma end_addr;
1565 bfd_vma eh_handler;

--- 7 unchanged lines hidden (view full) ---

1573 begin_addr = GET_PDATA_ENTRY (abfd, data + i );
1574 end_addr = GET_PDATA_ENTRY (abfd, data + i + 4);
1575 eh_handler = GET_PDATA_ENTRY (abfd, data + i + 8);
1576 eh_data = GET_PDATA_ENTRY (abfd, data + i + 12);
1577 prolog_end_addr = GET_PDATA_ENTRY (abfd, data + i + 16);
1578
1579 if (begin_addr == 0 && end_addr == 0 && eh_handler == 0
1580 && eh_data == 0 && prolog_end_addr == 0)
1634 {
1635 /* We are probably into the padding of the section now. */
1636 break;
1637 }
1581 /* We are probably into the padding of the section now. */
1582 break;
1638
1639 em_data = ((eh_handler & 0x1) << 2) | (prolog_end_addr & 0x3);
1640 eh_handler &= ~(bfd_vma) 0x3;
1641 prolog_end_addr &= ~(bfd_vma) 0x3;
1642
1643 fputc (' ', file);
1644 fprintf_vma (file, i + section->vma); fputc ('\t', file);
1645 fprintf_vma (file, begin_addr); fputc (' ', file);

--- 36 unchanged lines hidden (view full) ---

1682 }
1683
1684 free (data);
1685
1686 return true;
1687}
1688
1689#define IMAGE_REL_BASED_HIGHADJ 4
1583
1584 em_data = ((eh_handler & 0x1) << 2) | (prolog_end_addr & 0x3);
1585 eh_handler &= ~(bfd_vma) 0x3;
1586 prolog_end_addr &= ~(bfd_vma) 0x3;
1587
1588 fputc (' ', file);
1589 fprintf_vma (file, i + section->vma); fputc ('\t', file);
1590 fprintf_vma (file, begin_addr); fputc (' ', file);

--- 36 unchanged lines hidden (view full) ---

1627 }
1628
1629 free (data);
1630
1631 return true;
1632}
1633
1634#define IMAGE_REL_BASED_HIGHADJ 4
1690static const char * const tbl[] = {
1691 "ABSOLUTE",
1692 "HIGH",
1693 "LOW",
1694 "HIGHLOW",
1695 "HIGHADJ",
1696 "MIPS_JMPADDR",
1697 "SECTION",
1698 "REL32",
1699 "RESERVED1",
1700 "MIPS_JMPADDR16",
1701 "DIR64",
1702 "HIGH3ADJ"
1703 "UNKNOWN", /* MUST be last */
1704};
1635static const char * const tbl[] =
1636 {
1637 "ABSOLUTE",
1638 "HIGH",
1639 "LOW",
1640 "HIGHLOW",
1641 "HIGHADJ",
1642 "MIPS_JMPADDR",
1643 "SECTION",
1644 "REL32",
1645 "RESERVED1",
1646 "MIPS_JMPADDR16",
1647 "DIR64",
1648 "HIGH3ADJ"
1649 "UNKNOWN", /* MUST be last */
1650 };
1705
1706static boolean
1707pe_print_reloc (abfd, vfile)
1708 bfd *abfd;
1709 PTR vfile;
1710{
1711 FILE *file = (FILE *) vfile;
1712 bfd_byte *data = 0;
1713 asection *section = bfd_get_section_by_name (abfd, ".reloc");
1651
1652static boolean
1653pe_print_reloc (abfd, vfile)
1654 bfd *abfd;
1655 PTR vfile;
1656{
1657 FILE *file = (FILE *) vfile;
1658 bfd_byte *data = 0;
1659 asection *section = bfd_get_section_by_name (abfd, ".reloc");
1714 bfd_size_type datasize = 0;
1660 bfd_size_type datasize;
1715 bfd_size_type i;
1716 bfd_size_type start, stop;
1717
1718 if (section == NULL)
1719 return true;
1720
1721 if (bfd_section_size (abfd, section) == 0)
1722 return true;
1723
1724 fprintf (file,
1725 _("\n\nPE File Base Relocations (interpreted .reloc section contents)\n"));
1726
1661 bfd_size_type i;
1662 bfd_size_type start, stop;
1663
1664 if (section == NULL)
1665 return true;
1666
1667 if (bfd_section_size (abfd, section) == 0)
1668 return true;
1669
1670 fprintf (file,
1671 _("\n\nPE File Base Relocations (interpreted .reloc section contents)\n"));
1672
1727 data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd, section));
1728 datasize = bfd_section_size (abfd, section);
1673 datasize = bfd_section_size (abfd, section);
1674 data = (bfd_byte *) bfd_malloc (datasize);
1729 if (data == NULL && datasize != 0)
1730 return false;
1731
1675 if (data == NULL && datasize != 0)
1676 return false;
1677
1732 bfd_get_section_contents (abfd,
1733 section,
1734 (PTR) data, 0,
1735 bfd_section_size (abfd, section));
1678 bfd_get_section_contents (abfd, section, (PTR) data, (bfd_vma) 0,
1679 datasize);
1736
1737 start = 0;
1738
1739 stop = bfd_section_size (abfd, section);
1740
1741 for (i = start; i < stop;)
1742 {
1743 int j;
1744 bfd_vma virtual_address;
1745 long number, size;
1746
1747 /* The .reloc section is a sequence of blocks, with a header consisting
1680
1681 start = 0;
1682
1683 stop = bfd_section_size (abfd, section);
1684
1685 for (i = start; i < stop;)
1686 {
1687 int j;
1688 bfd_vma virtual_address;
1689 long number, size;
1690
1691 /* The .reloc section is a sequence of blocks, with a header consisting
1748 of two 32 bit quantities, followed by a number of 16 bit entries */
1749
1692 of two 32 bit quantities, followed by a number of 16 bit entries. */
1750 virtual_address = bfd_get_32 (abfd, data+i);
1751 size = bfd_get_32 (abfd, data+i+4);
1752 number = (size - 8) / 2;
1753
1754 if (size == 0)
1693 virtual_address = bfd_get_32 (abfd, data+i);
1694 size = bfd_get_32 (abfd, data+i+4);
1695 number = (size - 8) / 2;
1696
1697 if (size == 0)
1755 {
1756 break;
1757 }
1698 break;
1758
1759 fprintf (file,
1760 _("\nVirtual Address: %08lx Chunk size %ld (0x%lx) Number of fixups %ld\n"),
1761 (unsigned long) virtual_address, size, size, number);
1762
1763 for (j = 0; j < number; ++j)
1764 {
1765 unsigned short e = bfd_get_16 (abfd, data + i + 8 + j * 2);

--- 14 unchanged lines hidden (view full) ---

1780 fprintf (file, " (%4x)",
1781 ((unsigned int)
1782 bfd_get_16 (abfd, data + i + 8 + j * 2 + 2)));
1783 j++;
1784 }
1785
1786 fprintf (file, "\n");
1787 }
1699
1700 fprintf (file,
1701 _("\nVirtual Address: %08lx Chunk size %ld (0x%lx) Number of fixups %ld\n"),
1702 (unsigned long) virtual_address, size, size, number);
1703
1704 for (j = 0; j < number; ++j)
1705 {
1706 unsigned short e = bfd_get_16 (abfd, data + i + 8 + j * 2);

--- 14 unchanged lines hidden (view full) ---

1721 fprintf (file, " (%4x)",
1722 ((unsigned int)
1723 bfd_get_16 (abfd, data + i + 8 + j * 2 + 2)));
1724 j++;
1725 }
1726
1727 fprintf (file, "\n");
1728 }
1729
1788 i += size;
1789 }
1790
1791 free (data);
1792
1793 return true;
1794}
1795

--- 44 unchanged lines hidden (view full) ---

1840 fprintf (file, "MajorImageVersion\t%d\n", i->MajorImageVersion);
1841 fprintf (file, "MinorImageVersion\t%d\n", i->MinorImageVersion);
1842 fprintf (file, "MajorSubsystemVersion\t%d\n", i->MajorSubsystemVersion);
1843 fprintf (file, "MinorSubsystemVersion\t%d\n", i->MinorSubsystemVersion);
1844 fprintf (file, "Win32Version\t\t%08lx\n", i->Reserved1);
1845 fprintf (file, "SizeOfImage\t\t%08lx\n", i->SizeOfImage);
1846 fprintf (file, "SizeOfHeaders\t\t%08lx\n", i->SizeOfHeaders);
1847 fprintf (file, "CheckSum\t\t%08lx\n", i->CheckSum);
1730 i += size;
1731 }
1732
1733 free (data);
1734
1735 return true;
1736}
1737

--- 44 unchanged lines hidden (view full) ---

1782 fprintf (file, "MajorImageVersion\t%d\n", i->MajorImageVersion);
1783 fprintf (file, "MinorImageVersion\t%d\n", i->MinorImageVersion);
1784 fprintf (file, "MajorSubsystemVersion\t%d\n", i->MajorSubsystemVersion);
1785 fprintf (file, "MinorSubsystemVersion\t%d\n", i->MinorSubsystemVersion);
1786 fprintf (file, "Win32Version\t\t%08lx\n", i->Reserved1);
1787 fprintf (file, "SizeOfImage\t\t%08lx\n", i->SizeOfImage);
1788 fprintf (file, "SizeOfHeaders\t\t%08lx\n", i->SizeOfHeaders);
1789 fprintf (file, "CheckSum\t\t%08lx\n", i->CheckSum);
1790
1848 switch (i->Subsystem)
1849 {
1850 case IMAGE_SUBSYSTEM_UNKNOWN:
1851 subsystem_name = "unspecified";
1852 break;
1853 case IMAGE_SUBSYSTEM_NATIVE:
1854 subsystem_name = "NT native";
1855 break;

--- 14 unchanged lines hidden (view full) ---

1870 break;
1871 case IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER:
1872 subsystem_name = "EFI boot service driver";
1873 break;
1874 case IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER:
1875 subsystem_name = "EFI runtime driver";
1876 break;
1877 }
1791 switch (i->Subsystem)
1792 {
1793 case IMAGE_SUBSYSTEM_UNKNOWN:
1794 subsystem_name = "unspecified";
1795 break;
1796 case IMAGE_SUBSYSTEM_NATIVE:
1797 subsystem_name = "NT native";
1798 break;

--- 14 unchanged lines hidden (view full) ---

1813 break;
1814 case IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER:
1815 subsystem_name = "EFI boot service driver";
1816 break;
1817 case IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER:
1818 subsystem_name = "EFI runtime driver";
1819 break;
1820 }
1821
1878 fprintf (file, "Subsystem\t\t%08x", i->Subsystem);
1879 if (subsystem_name)
1880 fprintf (file, "\t(%s)", subsystem_name);
1881 fprintf (file, "\nDllCharacteristics\t%08x\n", i->DllCharacteristics);
1882 fprintf (file, "SizeOfStackReserve\t");
1883 fprintf_vma (file, i->SizeOfStackReserve);
1884 fprintf (file, "\nSizeOfStackCommit\t");
1885 fprintf_vma (file, i->SizeOfStackCommit);

--- 31 unchanged lines hidden (view full) ---

1917 /* One day we may try to grok other private data. */
1918 if (ibfd->xvec->flavour != bfd_target_coff_flavour
1919 || obfd->xvec->flavour != bfd_target_coff_flavour)
1920 return true;
1921
1922 pe_data (obfd)->pe_opthdr = pe_data (ibfd)->pe_opthdr;
1923 pe_data (obfd)->dll = pe_data (ibfd)->dll;
1924
1822 fprintf (file, "Subsystem\t\t%08x", i->Subsystem);
1823 if (subsystem_name)
1824 fprintf (file, "\t(%s)", subsystem_name);
1825 fprintf (file, "\nDllCharacteristics\t%08x\n", i->DllCharacteristics);
1826 fprintf (file, "SizeOfStackReserve\t");
1827 fprintf_vma (file, i->SizeOfStackReserve);
1828 fprintf (file, "\nSizeOfStackCommit\t");
1829 fprintf_vma (file, i->SizeOfStackCommit);

--- 31 unchanged lines hidden (view full) ---

1861 /* One day we may try to grok other private data. */
1862 if (ibfd->xvec->flavour != bfd_target_coff_flavour
1863 || obfd->xvec->flavour != bfd_target_coff_flavour)
1864 return true;
1865
1866 pe_data (obfd)->pe_opthdr = pe_data (ibfd)->pe_opthdr;
1867 pe_data (obfd)->dll = pe_data (ibfd)->dll;
1868
1925 /* for strip: if we removed .reloc, we'll make a real mess of things
1869 /* For strip: if we removed .reloc, we'll make a real mess of things
1926 if we don't remove this entry as well. */
1927 if (! pe_data (obfd)->has_reloc_section)
1928 {
1929 pe_data (obfd)->pe_opthdr.DataDirectory[5].VirtualAddress = 0;
1930 pe_data (obfd)->pe_opthdr.DataDirectory[5].Size = 0;
1931 }
1932 return true;
1933}
1934
1935/* Copy private section data. */
1870 if we don't remove this entry as well. */
1871 if (! pe_data (obfd)->has_reloc_section)
1872 {
1873 pe_data (obfd)->pe_opthdr.DataDirectory[5].VirtualAddress = 0;
1874 pe_data (obfd)->pe_opthdr.DataDirectory[5].Size = 0;
1875 }
1876 return true;
1877}
1878
1879/* Copy private section data. */
1880
1936boolean
1937_bfd_XX_bfd_copy_private_section_data (ibfd, isec, obfd, osec)
1938 bfd *ibfd;
1939 asection *isec;
1940 bfd *obfd;
1941 asection *osec;
1942{
1943 if (bfd_get_flavour (ibfd) != bfd_target_coff_flavour
1944 || bfd_get_flavour (obfd) != bfd_target_coff_flavour)
1945 return true;
1946
1947 if (coff_section_data (ibfd, isec) != NULL
1948 && pei_section_data (ibfd, isec) != NULL)
1949 {
1950 if (coff_section_data (obfd, osec) == NULL)
1951 {
1881boolean
1882_bfd_XX_bfd_copy_private_section_data (ibfd, isec, obfd, osec)
1883 bfd *ibfd;
1884 asection *isec;
1885 bfd *obfd;
1886 asection *osec;
1887{
1888 if (bfd_get_flavour (ibfd) != bfd_target_coff_flavour
1889 || bfd_get_flavour (obfd) != bfd_target_coff_flavour)
1890 return true;
1891
1892 if (coff_section_data (ibfd, isec) != NULL
1893 && pei_section_data (ibfd, isec) != NULL)
1894 {
1895 if (coff_section_data (obfd, osec) == NULL)
1896 {
1952 osec->used_by_bfd =
1953 (PTR) bfd_zalloc (obfd, sizeof (struct coff_section_tdata));
1897 bfd_size_type amt = sizeof (struct coff_section_tdata);
1898 osec->used_by_bfd = (PTR) bfd_zalloc (obfd, amt);
1954 if (osec->used_by_bfd == NULL)
1955 return false;
1956 }
1899 if (osec->used_by_bfd == NULL)
1900 return false;
1901 }
1902
1957 if (pei_section_data (obfd, osec) == NULL)
1958 {
1903 if (pei_section_data (obfd, osec) == NULL)
1904 {
1959 coff_section_data (obfd, osec)->tdata =
1960 (PTR) bfd_zalloc (obfd, sizeof (struct pei_section_tdata));
1905 bfd_size_type amt = sizeof (struct pei_section_tdata);
1906 coff_section_data (obfd, osec)->tdata = (PTR) bfd_zalloc (obfd, amt);
1961 if (coff_section_data (obfd, osec)->tdata == NULL)
1962 return false;
1963 }
1907 if (coff_section_data (obfd, osec)->tdata == NULL)
1908 return false;
1909 }
1910
1964 pei_section_data (obfd, osec)->virt_size =
1965 pei_section_data (ibfd, isec)->virt_size;
1966 pei_section_data (obfd, osec)->pe_flags =
1967 pei_section_data (ibfd, isec)->pe_flags;
1968 }
1969
1970 return true;
1971}

--- 75 unchanged lines hidden ---
1911 pei_section_data (obfd, osec)->virt_size =
1912 pei_section_data (ibfd, isec)->virt_size;
1913 pei_section_data (obfd, osec)->pe_flags =
1914 pei_section_data (ibfd, isec)->pe_flags;
1915 }
1916
1917 return true;
1918}

--- 75 unchanged lines hidden ---