Changeset 609 for branches/GNU/src/binutils/bfd/peXXigen.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/peXXigen.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* Support for the generic parts of PE/PEI; the common executable parts. 2 Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001 2 Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 3 3 Free Software Foundation, Inc. 4 4 Written by Cygnus Solutions. 5 5 6 This file is part of BFD, the Binary File Descriptor library.7 8 This program is free software; you can redistribute it and/or modify9 it under the terms of the GNU General Public License as published by10 the Free Software Foundation; either version 2 of the License, or11 (at your option) any later version.12 13 This program is distributed in the hope that it will be useful,14 but WITHOUT ANY WARRANTY; without even the implied warranty of15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16 GNU General Public License for more details.17 18 You should have received a copy of the GNU General Public License19 along with this program; if not, write to the Free Software20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */6 This file is part of BFD, the Binary File Descriptor library. 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 2 of the License, or 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 21 21 22 22 /* Most of this hacked by Steve Chamberlain <sac@cygnus.com>. 23 23 24 24 PE/PEI rearrangement (and code added): Donn Terry 25 Softway Systems, Inc. 26 */ 25 Softway Systems, Inc. */ 27 26 28 27 /* Hey look, some documentation [and in a place you expect to find it]! … … 52 51 FIXME: Please add more docs here so the next poor fool that has to hack 53 52 on this code has a chance of getting something accomplished without 54 wasting too much time. 55 */ 53 wasting too much time. */ 56 54 57 55 /* This expands into COFF_WITH_pe or COFF_WITH_pep depending on whether … … 94 92 static void add_data_entry 95 93 PARAMS ((bfd *, struct internal_extra_pe_aouthdr *, int, char *, bfd_vma)); 96 static boolean pe_print_pdata PARAMS ((bfd *, PTR)); 97 static boolean pe_print_reloc PARAMS ((bfd *, PTR)); 98 99 /**********************************************************************/ 94 static bfd_boolean pe_print_pdata PARAMS ((bfd *, PTR)); 95 static bfd_boolean pe_print_reloc PARAMS ((bfd *, PTR)); 96 static bfd_boolean pe_print_idata PARAMS ((bfd *, PTR)); 97 static bfd_boolean pe_print_edata PARAMS ((bfd *, PTR)); 98 99 100 100 101 101 void … … 111 111 { 112 112 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); 113 in->_n._n_n._n_offset = H_GET_32 (abfd, ext->e.e.e_offset); 115 114 } 116 115 else 117 { 118 memcpy (in->_n._n_name, ext->e.e_name, SYMNMLEN); 119 } 120 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); 116 memcpy (in->_n._n_name, ext->e.e_name, SYMNMLEN); 117 118 in->n_value = H_GET_32 (abfd, ext->e_value); 119 in->n_scnum = H_GET_16 (abfd, ext->e_scnum); 120 123 121 if (sizeof (ext->e_type) == 2) 124 { 125 in->n_type = bfd_h_get_16 (abfd, (bfd_byte *) ext->e_type); 126 } 122 in->n_type = H_GET_16 (abfd, ext->e_type); 127 123 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); 124 in->n_type = H_GET_32 (abfd, ext->e_type); 125 126 in->n_sclass = H_GET_8 (abfd, ext->e_sclass); 127 in->n_numaux = H_GET_8 (abfd, ext->e_numaux); 133 128 134 129 #ifndef STRICT_PE_FORMAT … … 167 162 { 168 163 asection *sec; 164 169 165 for (sec = abfd->sections; sec; sec = sec->next) 170 166 { … … 176 172 } 177 173 } 174 178 175 if (in->n_scnum == 0) 179 176 { … … 181 178 asection *sec; 182 179 char *name; 180 183 181 for (sec = abfd->sections; sec; sec = sec->next) 184 182 if (unused_section_number <= sec->target_index) 185 183 unused_section_number = sec->target_index + 1; 186 184 187 name = bfd_alloc (abfd, strlen (in->n_name) + 10);185 name = bfd_alloc (abfd, (bfd_size_type) strlen (in->n_name) + 10); 188 186 if (name == NULL) 189 187 return; … … 230 228 struct internal_syment *in = (struct internal_syment *) inp; 231 229 SYMENT *ext = (SYMENT *) extp; 230 232 231 if (in->_n._n_name[0] == 0) 233 232 { 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);233 H_PUT_32 (abfd, 0, ext->e.e.e_zeroes); 234 H_PUT_32 (abfd, in->_n._n_n._n_offset, ext->e.e.e_offset); 236 235 } 237 236 else 238 { 239 memcpy (ext->e.e_name, in->_n._n_name, SYMNMLEN); 240 } 241 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); 237 memcpy (ext->e.e_name, in->_n._n_name, SYMNMLEN); 238 239 H_PUT_32 (abfd, in->n_value, ext->e_value); 240 H_PUT_16 (abfd, in->n_scnum, ext->e_scnum); 241 244 242 if (sizeof (ext->e_type) == 2) 245 { 246 bfd_h_put_16 (abfd, in->n_type, (bfd_byte *) ext->e_type); 247 } 243 H_PUT_16 (abfd, in->n_type, ext->e_type); 248 244 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); 245 H_PUT_32 (abfd, in->n_type, ext->e_type); 246 247 H_PUT_8 (abfd, in->n_sclass, ext->e_sclass); 248 H_PUT_8 (abfd, in->n_numaux, ext->e_numaux); 254 249 255 250 return SYMESZ; … … 275 270 { 276 271 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); 272 in->x_file.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset); 279 273 } 280 274 else 281 { 282 memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN); 283 } 275 memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN); 284 276 return; 285 277 … … 292 284 in->x_scn.x_nreloc = GET_SCN_NRELOC (abfd, ext); 293 285 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); 286 in->x_scn.x_checksum = H_GET_32 (abfd, ext->x_scn.x_checksum); 287 in->x_scn.x_associated = H_GET_16 (abfd, ext->x_scn.x_associated); 288 in->x_scn.x_comdat = H_GET_8 (abfd, ext->x_scn.x_comdat); 300 289 return; 301 290 } … … 303 292 } 304 293 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);294 in->x_sym.x_tagndx.l = H_GET_32 (abfd, ext->x_sym.x_tagndx); 295 in->x_sym.x_tvndx = H_GET_16 (abfd, ext->x_sym.x_tvndx); 307 296 308 297 if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class)) … … 314 303 { 315 304 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]);305 H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[0]); 317 306 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]);307 H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[1]); 319 308 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]);309 H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[2]); 321 310 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]);311 H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[3]); 323 312 } 324 313 325 314 if (ISFCN (type)) 326 315 { 327 in->x_sym.x_misc.x_fsize = 328 bfd_h_get_32 (abfd, (bfd_byte *) ext->x_sym.x_misc.x_fsize); 316 in->x_sym.x_misc.x_fsize = H_GET_32 (abfd, ext->x_sym.x_misc.x_fsize); 329 317 } 330 318 else … … 354 342 if (in->x_file.x_fname[0] == 0) 355 343 { 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); 344 H_PUT_32 (abfd, 0, ext->x_file.x_n.x_zeroes); 345 H_PUT_32 (abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset); 360 346 } 361 347 else 362 { 363 memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN); 364 } 348 memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN); 349 365 350 return AUXESZ; 366 351 … … 373 358 PUT_SCN_NRELOC (abfd, in->x_scn.x_nreloc, ext); 374 359 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); 360 H_PUT_32 (abfd, in->x_scn.x_checksum, ext->x_scn.x_checksum); 361 H_PUT_16 (abfd, in->x_scn.x_associated, ext->x_scn.x_associated); 362 H_PUT_8 (abfd, in->x_scn.x_comdat, ext->x_scn.x_comdat); 381 363 return AUXESZ; 382 364 } … … 384 366 } 385 367 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);368 H_PUT_32 (abfd, in->x_sym.x_tagndx.l, ext->x_sym.x_tagndx); 369 H_PUT_16 (abfd, in->x_sym.x_tvndx, ext->x_sym.x_tvndx); 388 370 389 371 if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class)) … … 394 376 else 395 377 { 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]);378 H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0], 379 ext->x_sym.x_fcnary.x_ary.x_dimen[0]); 380 H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1], 381 ext->x_sym.x_fcnary.x_ary.x_dimen[1]); 382 H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2], 383 ext->x_sym.x_fcnary.x_ary.x_dimen[2]); 384 H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3], 385 ext->x_sym.x_fcnary.x_ary.x_dimen[3]); 404 386 } 405 387 406 388 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); 389 H_PUT_32 (abfd, in->x_sym.x_misc.x_fsize, ext->x_sym.x_misc.x_fsize); 409 390 else 410 391 { … … 425 406 struct internal_lineno *in = (struct internal_lineno *) in1; 426 407 427 in->l_addr.l_symndx = bfd_h_get_32 (abfd, (bfd_byte *)ext->l_addr.l_symndx);408 in->l_addr.l_symndx = H_GET_32 (abfd, ext->l_addr.l_symndx); 428 409 in->l_lnno = GET_LINENO_LNNO (abfd, ext); 429 410 } … … 437 418 struct internal_lineno *in = (struct internal_lineno *) inp; 438 419 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); 420 H_PUT_32 (abfd, in->l_addr.l_symndx, ext->l_addr.l_symndx); 441 421 442 422 PUT_LINENO_LNNO (abfd, in->l_lnno, ext); … … 455 435 struct internal_aouthdr *aouthdr_int = (struct internal_aouthdr *)aouthdr_int1; 456 436 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); 437 aouthdr_int->magic = H_GET_16 (abfd, aouthdr_ext->magic); 438 aouthdr_int->vstamp = H_GET_16 (abfd, aouthdr_ext->vstamp); 439 aouthdr_int->tsize = GET_AOUTHDR_TSIZE (abfd, aouthdr_ext->tsize); 440 aouthdr_int->dsize = GET_AOUTHDR_DSIZE (abfd, aouthdr_ext->dsize); 441 aouthdr_int->bsize = GET_AOUTHDR_BSIZE (abfd, aouthdr_ext->bsize); 442 aouthdr_int->entry = GET_AOUTHDR_ENTRY (abfd, aouthdr_ext->entry); 467 443 aouthdr_int->text_start = 468 GET_AOUTHDR_TEXT_START (abfd, (bfd_byte *)aouthdr_ext->text_start);444 GET_AOUTHDR_TEXT_START (abfd, aouthdr_ext->text_start); 469 445 #ifndef COFF_WITH_pep 470 446 /* PE32+ does not have data_start member! */ 471 447 aouthdr_int->data_start = 472 GET_AOUTHDR_DATA_START (abfd, (bfd_byte *)aouthdr_ext->data_start);448 GET_AOUTHDR_DATA_START (abfd, aouthdr_ext->data_start); 473 449 #endif 474 450 475 451 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);452 a->ImageBase = GET_OPTHDR_IMAGE_BASE (abfd, src->ImageBase); 453 a->SectionAlignment = H_GET_32 (abfd, src->SectionAlignment); 454 a->FileAlignment = H_GET_32 (abfd, src->FileAlignment); 479 455 a->MajorOperatingSystemVersion = 480 bfd_h_get_16 (abfd, (bfd_byte *)src->MajorOperatingSystemVersion);456 H_GET_16 (abfd, src->MajorOperatingSystemVersion); 481 457 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); 458 H_GET_16 (abfd, src->MinorOperatingSystemVersion); 459 a->MajorImageVersion = H_GET_16 (abfd, src->MajorImageVersion); 460 a->MinorImageVersion = H_GET_16 (abfd, src->MinorImageVersion); 461 a->MajorSubsystemVersion = H_GET_16 (abfd, src->MajorSubsystemVersion); 462 a->MinorSubsystemVersion = H_GET_16 (abfd, src->MinorSubsystemVersion); 463 a->Reserved1 = H_GET_32 (abfd, src->Reserved1); 464 a->SizeOfImage = H_GET_32 (abfd, src->SizeOfImage); 465 a->SizeOfHeaders = H_GET_32 (abfd, src->SizeOfHeaders); 466 a->CheckSum = H_GET_32 (abfd, src->CheckSum); 467 a->Subsystem = H_GET_16 (abfd, src->Subsystem); 468 a->DllCharacteristics = H_GET_16 (abfd, src->DllCharacteristics); 469 a->SizeOfStackReserve = 470 GET_OPTHDR_SIZE_OF_STACK_RESERVE (abfd, src->SizeOfStackReserve); 471 a->SizeOfStackCommit = 472 GET_OPTHDR_SIZE_OF_STACK_COMMIT (abfd, src->SizeOfStackCommit); 473 a->SizeOfHeapReserve = 474 GET_OPTHDR_SIZE_OF_HEAP_RESERVE (abfd, src->SizeOfHeapReserve); 475 a->SizeOfHeapCommit = 476 GET_OPTHDR_SIZE_OF_HEAP_COMMIT (abfd, src->SizeOfHeapCommit); 477 a->LoaderFlags = H_GET_32 (abfd, src->LoaderFlags); 478 a->NumberOfRvaAndSizes = H_GET_32 (abfd, src->NumberOfRvaAndSizes); 499 479 500 480 { 501 481 int idx; 482 502 483 for (idx = 0; idx < 16; idx++) 503 484 { 504 485 /* If data directory is empty, rva also should be 0. */ 505 486 int size = 506 bfd_h_get_32 (abfd, (bfd_byte *)src->DataDirectory[idx][1]);487 H_GET_32 (abfd, src->DataDirectory[idx][1]); 507 488 a->DataDirectory[idx].Size = size; 508 489 509 490 if (size) 510 { 511 a->DataDirectory[idx].VirtualAddress = 512 bfd_h_get_32 (abfd, (bfd_byte *) src->DataDirectory[idx][0]); 513 } 491 a->DataDirectory[idx].VirtualAddress = 492 H_GET_32 (abfd, src->DataDirectory[idx][0]); 514 493 else 515 494 a->DataDirectory[idx].VirtualAddress = 0; … … 524 503 #endif 525 504 } 505 526 506 if (aouthdr_int->tsize) 527 507 { … … 531 511 #endif 532 512 } 513 533 514 #ifndef COFF_WITH_pep 534 515 /* PE32+ does not have data_start member! */ … … 548 529 import_table_size = a->DataDirectory[1].Size; 549 530 #endif 550 551 531 } 552 532 … … 563 543 asection *sec = bfd_get_section_by_name (abfd, name); 564 544 565 /* add import directory information if it exists*/545 /* Add import directory information if it exists. */ 566 546 if ((sec != NULL) 567 547 && (coff_section_data (abfd, sec) != NULL) 568 548 && (pei_section_data (abfd, sec) != NULL)) 569 549 { 570 /* If data directory is empty, rva also should be 0 */550 /* If data directory is empty, rva also should be 0. */ 571 551 int size = pei_section_data (abfd, sec)->virt_size; 572 552 aout->DataDirectory[idx].Size = size; … … 592 572 PEAOUTHDR *aouthdr_out = (PEAOUTHDR *) out; 593 573 bfd_vma sa, fa, ib; 594 574 IMAGE_DATA_DIRECTORY idata2, idata5; 575 576 595 577 if (pe->force_minimum_alignment) 596 578 { … … 608 590 ib = extra->ImageBase; 609 591 592 idata2 = pe->pe_opthdr.DataDirectory[1]; 593 idata5 = pe->pe_opthdr.DataDirectory[12]; 594 610 595 if (aouthdr_in->tsize) 611 596 { … … 615 600 #endif 616 601 } 602 617 603 if (aouthdr_in->dsize) 618 604 { … … 622 608 #endif 623 609 } 610 624 611 if (aouthdr_in->entry) 625 612 { … … 634 621 635 622 /* We like to have the sizes aligned. */ 636 637 623 aouthdr_in->bsize = FA (aouthdr_in->bsize); 638 624 639 625 extra->NumberOfRvaAndSizes = IMAGE_NUMBEROF_DIRECTORY_ENTRIES; 640 626 641 /* first null out all data directory entries .. */642 memset (extra->DataDirectory, sizeof (extra->DataDirectory), 0);627 /* First null out all data directory entries. */ 628 memset (extra->DataDirectory, 0, sizeof (extra->DataDirectory)); 643 629 644 630 add_data_entry (abfd, extra, 0, ".edata", ib); 645 646 /* Don't call add_data_entry for .idata$2 or .idata$5. It's done in647 bfd_coff_final_link where all the required information is648 available. */649 650 /* However, until other .idata fixes are made (pending patch), the651 entry for .idata is needed for backwards compatability. FIXME. */652 add_data_entry (abfd, extra, 1, ".idata", ib);653 654 631 add_data_entry (abfd, extra, 2, ".rsrc", ib); 655 656 632 add_data_entry (abfd, extra, 3, ".pdata", ib); 657 633 634 /* In theory we do not need to call add_data_entry for .idata$2 or 635 .idata$5. It will be done in bfd_coff_final_link where all the 636 required information is available. If however, we are not going 637 to perform a final link, eg because we have been invoked by objcopy 638 or strip, then we need to make sure that these Data Directory 639 entries are initialised properly. 640 641 So - we copy the input values into the output values, and then, if 642 a final link is going to be performed, it can overwrite them. */ 643 extra->DataDirectory[1] = idata2; 644 extra->DataDirectory[12] = idata5; 645 646 if (extra->DataDirectory[1].VirtualAddress == 0) 647 /* Until other .idata fixes are made (pending patch), the entry for 648 .idata is needed for backwards compatability. FIXME. */ 649 add_data_entry (abfd, extra, 1, ".idata", ib); 650 658 651 /* For some reason, the virtual size (which is what's set by 659 652 add_data_entry) for .reloc is not the same as the size recorded … … 692 685 693 686 extra->SizeOfHeaders = abfd->sections->filepos; 694 bfd_h_put_16 (abfd, aouthdr_in->magic, (bfd_byte *)aouthdr_out->standard.magic);687 H_PUT_16 (abfd, aouthdr_in->magic, aouthdr_out->standard.magic); 695 688 696 689 #define LINKER_VERSION 256 /* That is, 2.56 */ … … 698 691 /* This piece of magic sets the "linker version" field to 699 692 LINKER_VERSION. */ 700 bfd_h_put_16 (abfd, 701 LINKER_VERSION / 100 + (LINKER_VERSION % 100) * 256, 702 (bfd_byte *) aouthdr_out->standard.vstamp); 703 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); 693 H_PUT_16 (abfd, (LINKER_VERSION / 100 + (LINKER_VERSION % 100) * 256), 694 aouthdr_out->standard.vstamp); 695 696 PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, aouthdr_out->standard.tsize); 697 PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, aouthdr_out->standard.dsize); 698 PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, aouthdr_out->standard.bsize); 699 PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, aouthdr_out->standard.entry); 708 700 PUT_AOUTHDR_TEXT_START (abfd, aouthdr_in->text_start, 709 (bfd_byte *)aouthdr_out->standard.text_start);701 aouthdr_out->standard.text_start); 710 702 711 703 #ifndef COFF_WITH_pep 712 /* PE32+ does not have data_start member! */704 /* PE32+ does not have data_start member! */ 713 705 PUT_AOUTHDR_DATA_START (abfd, aouthdr_in->data_start, 714 (bfd_byte *) aouthdr_out->standard.data_start); 715 #endif 716 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); 706 aouthdr_out->standard.data_start); 707 #endif 708 709 PUT_OPTHDR_IMAGE_BASE (abfd, extra->ImageBase, aouthdr_out->ImageBase); 710 H_PUT_32 (abfd, extra->SectionAlignment, aouthdr_out->SectionAlignment); 711 H_PUT_32 (abfd, extra->FileAlignment, aouthdr_out->FileAlignment); 712 H_PUT_16 (abfd, extra->MajorOperatingSystemVersion, 713 aouthdr_out->MajorOperatingSystemVersion); 714 H_PUT_16 (abfd, extra->MinorOperatingSystemVersion, 715 aouthdr_out->MinorOperatingSystemVersion); 716 H_PUT_16 (abfd, extra->MajorImageVersion, aouthdr_out->MajorImageVersion); 717 H_PUT_16 (abfd, extra->MinorImageVersion, aouthdr_out->MinorImageVersion); 718 H_PUT_16 (abfd, extra->MajorSubsystemVersion, 719 aouthdr_out->MajorSubsystemVersion); 720 H_PUT_16 (abfd, extra->MinorSubsystemVersion, 721 aouthdr_out->MinorSubsystemVersion); 722 H_PUT_32 (abfd, extra->Reserved1, aouthdr_out->Reserved1); 723 H_PUT_32 (abfd, extra->SizeOfImage, aouthdr_out->SizeOfImage); 724 H_PUT_32 (abfd, extra->SizeOfHeaders, aouthdr_out->SizeOfHeaders); 725 H_PUT_32 (abfd, extra->CheckSum, aouthdr_out->CheckSum); 726 H_PUT_16 (abfd, extra->Subsystem, aouthdr_out->Subsystem); 727 H_PUT_16 (abfd, extra->DllCharacteristics, aouthdr_out->DllCharacteristics); 747 728 PUT_OPTHDR_SIZE_OF_STACK_RESERVE (abfd, extra->SizeOfStackReserve, 748 (bfd_byte *)aouthdr_out->SizeOfStackReserve);729 aouthdr_out->SizeOfStackReserve); 749 730 PUT_OPTHDR_SIZE_OF_STACK_COMMIT (abfd, extra->SizeOfStackCommit, 750 (bfd_byte *)aouthdr_out->SizeOfStackCommit);731 aouthdr_out->SizeOfStackCommit); 751 732 PUT_OPTHDR_SIZE_OF_HEAP_RESERVE (abfd, extra->SizeOfHeapReserve, 752 (bfd_byte *)aouthdr_out->SizeOfHeapReserve);733 aouthdr_out->SizeOfHeapReserve); 753 734 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); 735 aouthdr_out->SizeOfHeapCommit); 736 H_PUT_32 (abfd, extra->LoaderFlags, aouthdr_out->LoaderFlags); 737 H_PUT_32 (abfd, extra->NumberOfRvaAndSizes, 738 aouthdr_out->NumberOfRvaAndSizes); 759 739 { 760 740 int idx; 741 761 742 for (idx = 0; idx < 16; idx++) 762 743 { 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]);744 H_PUT_32 (abfd, extra->DataDirectory[idx].VirtualAddress, 745 aouthdr_out->DataDirectory[idx][0]); 746 H_PUT_32 (abfd, extra->DataDirectory[idx].Size, 747 aouthdr_out->DataDirectory[idx][1]); 767 748 } 768 749 } … … 833 814 filehdr_in->pe.nt_signature = NT_SIGNATURE; 834 815 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);837 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);844 845 /* put in extra dos header stuff. This data remains essentially816 H_PUT_16 (abfd, filehdr_in->f_magic, filehdr_out->f_magic); 817 H_PUT_16 (abfd, filehdr_in->f_nscns, filehdr_out->f_nscns); 818 819 H_PUT_32 (abfd, time (0), filehdr_out->f_timdat); 820 PUT_FILEHDR_SYMPTR (abfd, filehdr_in->f_symptr, 821 filehdr_out->f_symptr); 822 H_PUT_32 (abfd, filehdr_in->f_nsyms, filehdr_out->f_nsyms); 823 H_PUT_16 (abfd, filehdr_in->f_opthdr, filehdr_out->f_opthdr); 824 H_PUT_16 (abfd, filehdr_in->f_flags, filehdr_out->f_flags); 825 826 /* Put in extra dos header stuff. This data remains essentially 846 827 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); 881 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 } 828 for NT. */ 829 H_PUT_16 (abfd, filehdr_in->pe.e_magic, filehdr_out->e_magic); 830 H_PUT_16 (abfd, filehdr_in->pe.e_cblp, filehdr_out->e_cblp); 831 H_PUT_16 (abfd, filehdr_in->pe.e_cp, filehdr_out->e_cp); 832 H_PUT_16 (abfd, filehdr_in->pe.e_crlc, filehdr_out->e_crlc); 833 H_PUT_16 (abfd, filehdr_in->pe.e_cparhdr, filehdr_out->e_cparhdr); 834 H_PUT_16 (abfd, filehdr_in->pe.e_minalloc, filehdr_out->e_minalloc); 835 H_PUT_16 (abfd, filehdr_in->pe.e_maxalloc, filehdr_out->e_maxalloc); 836 H_PUT_16 (abfd, filehdr_in->pe.e_ss, filehdr_out->e_ss); 837 H_PUT_16 (abfd, filehdr_in->pe.e_sp, filehdr_out->e_sp); 838 H_PUT_16 (abfd, filehdr_in->pe.e_csum, filehdr_out->e_csum); 839 H_PUT_16 (abfd, filehdr_in->pe.e_ip, filehdr_out->e_ip); 840 H_PUT_16 (abfd, filehdr_in->pe.e_cs, filehdr_out->e_cs); 841 H_PUT_16 (abfd, filehdr_in->pe.e_lfarlc, filehdr_out->e_lfarlc); 842 H_PUT_16 (abfd, filehdr_in->pe.e_ovno, filehdr_out->e_ovno); 843 844 for (idx = 0; idx < 4; idx++) 845 H_PUT_16 (abfd, filehdr_in->pe.e_res[idx], filehdr_out->e_res[idx]); 846 847 H_PUT_16 (abfd, filehdr_in->pe.e_oemid, filehdr_out->e_oemid); 848 H_PUT_16 (abfd, filehdr_in->pe.e_oeminfo, filehdr_out->e_oeminfo); 849 850 for (idx = 0; idx < 10; idx++) 851 H_PUT_16 (abfd, filehdr_in->pe.e_res2[idx], filehdr_out->e_res2[idx]); 852 853 H_PUT_32 (abfd, filehdr_in->pe.e_lfanew, filehdr_out->e_lfanew); 854 855 for (idx = 0; idx < 16; idx++) 856 H_PUT_32 (abfd, filehdr_in->pe.dos_message[idx], 857 filehdr_out->dos_message[idx]); 888 858 889 859 /* Also put in the NT signature. */ 890 bfd_h_put_32 (abfd, filehdr_in->pe.nt_signature, 891 (bfd_byte *) filehdr_out->nt_signature); 860 H_PUT_32 (abfd, filehdr_in->pe.nt_signature, filehdr_out->nt_signature); 892 861 893 862 return FILHSZ; … … 903 872 FILHDR *filehdr_out = (FILHDR *) out; 904 873 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); 874 H_PUT_16 (abfd, filehdr_in->f_magic, filehdr_out->f_magic); 875 H_PUT_16 (abfd, filehdr_in->f_nscns, filehdr_out->f_nscns); 876 H_PUT_32 (abfd, filehdr_in->f_timdat, filehdr_out->f_timdat); 877 PUT_FILEHDR_SYMPTR (abfd, filehdr_in->f_symptr, filehdr_out->f_symptr); 878 H_PUT_32 (abfd, filehdr_in->f_nsyms, filehdr_out->f_nsyms); 879 H_PUT_16 (abfd, filehdr_in->f_opthdr, filehdr_out->f_opthdr); 880 H_PUT_16 (abfd, filehdr_in->f_flags, filehdr_out->f_flags); 913 881 914 882 return FILHSZ; … … 933 901 - pe_data (abfd)->pe_opthdr.ImageBase) 934 902 & 0xffffffff), 935 (bfd_byte *)scnhdr_ext->s_vaddr);903 scnhdr_ext->s_vaddr); 936 904 937 905 /* NT wants the size data to be rounded up to the next 938 906 NT_FILE_ALIGNMENT, but zero if it has no content (as in .bss, 939 907 sometimes). */ 940 941 908 if ((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0) 942 909 { 943 ps = scnhdr_int->s_size; 944 ss = 0; 910 if (bfd_pe_executable_p (abfd)) 911 { 912 ps = scnhdr_int->s_size; 913 ss = 0; 914 } 915 else 916 { 917 ps = 0; 918 ss = scnhdr_int->s_size; 919 } 945 920 } 946 921 else 947 922 { 948 ps = scnhdr_int->s_paddr; 923 if (bfd_pe_executable_p (abfd)) 924 ps = scnhdr_int->s_paddr; 925 else 926 ps = 0; 927 949 928 ss = scnhdr_int->s_size; 950 929 } 951 930 952 931 PUT_SCNHDR_SIZE (abfd, ss, 953 (bfd_byte *)scnhdr_ext->s_size);932 scnhdr_ext->s_size); 954 933 955 934 /* s_paddr in PE is really the virtual size. */ 956 PUT_SCNHDR_PADDR (abfd, ps, (bfd_byte *)scnhdr_ext->s_paddr);935 PUT_SCNHDR_PADDR (abfd, ps, scnhdr_ext->s_paddr); 957 936 958 937 PUT_SCNHDR_SCNPTR (abfd, scnhdr_int->s_scnptr, 959 (bfd_byte *)scnhdr_ext->s_scnptr);938 scnhdr_ext->s_scnptr); 960 939 PUT_SCNHDR_RELPTR (abfd, scnhdr_int->s_relptr, 961 (bfd_byte *)scnhdr_ext->s_relptr);940 scnhdr_ext->s_relptr); 962 941 PUT_SCNHDR_LNNOPTR (abfd, scnhdr_int->s_lnnoptr, 963 (bfd_byte *)scnhdr_ext->s_lnnoptr);942 scnhdr_ext->s_lnnoptr); 964 943 965 944 /* Extra flags must be set when dealing with NT. All sections should also … … 979 958 { 980 959 int flags = scnhdr_int->s_flags; 981 bfd_h_put_32 (abfd, flags, (bfd_byte *) scnhdr_ext->s_flags); 960 961 H_PUT_32 (abfd, flags, scnhdr_ext->s_flags); 982 962 } 983 963 … … 995 975 Overflow is not an issue: a 4G-line program will overflow a 996 976 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); 977 H_PUT_16 (abfd, (scnhdr_int->s_nlnno & 0xffff), scnhdr_ext->s_nlnno); 978 H_PUT_16 (abfd, (scnhdr_int->s_nlnno >> 16), scnhdr_ext->s_nreloc); 1001 979 } 1002 980 else 1003 981 { 1004 982 if (scnhdr_int->s_nlnno <= 0xffff) 1005 bfd_h_put_16 (abfd, scnhdr_int->s_nlnno, 1006 (bfd_byte *) scnhdr_ext->s_nlnno); 983 H_PUT_16 (abfd, scnhdr_int->s_nlnno, scnhdr_ext->s_nlnno); 1007 984 else 1008 985 { … … 1011 988 scnhdr_int->s_nlnno); 1012 989 bfd_set_error (bfd_error_file_truncated); 1013 bfd_h_put_16 (abfd, 0xffff, (bfd_byte *)scnhdr_ext->s_nlnno);990 H_PUT_16 (abfd, 0xffff, scnhdr_ext->s_nlnno); 1014 991 ret = 0; 1015 992 } 993 1016 994 if (scnhdr_int->s_nreloc <= 0xffff) 1017 bfd_h_put_16 (abfd, scnhdr_int->s_nreloc, 1018 (bfd_byte *) scnhdr_ext->s_nreloc); 995 H_PUT_16 (abfd, scnhdr_int->s_nreloc, scnhdr_ext->s_nreloc); 1019 996 else 1020 997 { 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);998 /* PE can deal with large #s of relocs, but not here. */ 999 H_PUT_16 (abfd, 0xffff, scnhdr_ext->s_nreloc); 1023 1000 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); 1001 H_PUT_32 (abfd, scnhdr_int->s_flags, scnhdr_ext->s_flags); 1026 1002 #if 0 1027 1003 (*_bfd_error_handler) (_("%s: reloc overflow 1: 0x%lx > 0xffff"), … … 1029 1005 scnhdr_int->s_nreloc); 1030 1006 bfd_set_error (bfd_error_file_truncated); 1031 bfd_h_put_16 (abfd, 0xffff, (bfd_byte *)scnhdr_ext->s_nreloc);1007 H_PUT_16 (abfd, 0xffff, scnhdr_ext->s_nreloc); 1032 1008 ret = 0; 1033 1009 #endif … … 1037 1013 } 1038 1014 1039 static 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_("DescriptionDirectory"),1048 N_("SpecialDirectory"),1049 N_("Thread Storage Directory [.tls]"),1050 N_("Load Configuration Directory"),1051 N_("Bound ImportDirectory"),1052 N_("Import Address TableDirectory"),1053 N_("Delay ImportDirectory"),1054 N_("Reserved"),1055 N_("Reserved")1056 }; 1057 1058 /**********************************************************************/ 1015 static char * dir_names[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] = 1016 { 1017 N_("Export Directory [.edata (or where ever we found it)]"), 1018 N_("Import Directory [parts of .idata]"), 1019 N_("Resource Directory [.rsrc]"), 1020 N_("Exception Directory [.pdata]"), 1021 N_("Security Directory"), 1022 N_("Base Relocation Directory [.reloc]"), 1023 N_("Debug Directory"), 1024 N_("Description Directory"), 1025 N_("Special Directory"), 1026 N_("Thread Storage Directory [.tls]"), 1027 N_("Load Configuration Directory"), 1028 N_("Bound Import Directory"), 1029 N_("Import Address Table Directory"), 1030 N_("Delay Import Directory"), 1031 N_("Reserved"), 1032 N_("Reserved") 1033 }; 1034 1059 1035 #ifdef POWERPC_LE_PE 1060 1036 /* The code for the PPC really falls in the "architecture dependent" … … 1065 1041 #endif 1066 1042 1067 /**********************************************************************/ 1068 static boolean 1043 static bfd_boolean 1069 1044 pe_print_idata (abfd, vfile) 1070 1045 bfd *abfd; … … 1083 1058 bfd_size_type dataoff; 1084 1059 bfd_size_type i; 1060 bfd_size_type amt; 1085 1061 int onaline = 20; 1086 1062 … … 1097 1073 section = bfd_get_section_by_name (abfd, ".idata"); 1098 1074 if (section == NULL) 1099 return true;1075 return TRUE; 1100 1076 1101 1077 addr = section->vma; 1102 1078 datasize = bfd_section_size (abfd, section); 1103 1079 if (datasize == 0) 1104 return true;1080 return TRUE; 1105 1081 } 1106 1082 else … … 1118 1094 fprintf (file, 1119 1095 _("\nThere is an import table, but the section containing it could not be found\n")); 1120 return true;1096 return TRUE; 1121 1097 } 1122 1098 } … … 1144 1120 int offset; 1145 1121 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) 1149 return false; 1150 1151 bfd_get_section_contents (abfd, 1152 rel_section, 1153 (PTR) data, 0, 1154 bfd_section_size (abfd, rel_section)); 1122 amt = bfd_section_size (abfd, rel_section); 1123 data = (bfd_byte *) bfd_malloc (amt); 1124 if (data == NULL && amt != 0) 1125 return FALSE; 1126 1127 bfd_get_section_contents (abfd, rel_section, (PTR) data, (bfd_vma) 0, 1128 amt); 1155 1129 1156 1130 offset = abfd->start_address - rel_section->vma; … … 1178 1152 section->name); 1179 1153 fprintf (file, 1180 _(" vma: Hint Time Forward DLL First\n")); 1181 fprintf (file, 1182 _(" Table Stamp Chain Name Thunk\n")); 1183 1184 data = (bfd_byte *) bfd_malloc (dataoff + datasize); 1154 _("\ 1155 vma: Hint Time Forward DLL First\n\ 1156 Table Stamp Chain Name Thunk\n")); 1157 1158 amt = dataoff + datasize; 1159 data = (bfd_byte *) bfd_malloc (amt); 1185 1160 if (data == NULL) 1186 return false;1161 return FALSE; 1187 1162 1188 1163 /* 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)) 1191 return false; 1164 if (! bfd_get_section_contents (abfd, section, (PTR) data, (bfd_vma) 0, amt)) 1165 return FALSE; 1192 1166 1193 1167 adj = section->vma - extra->ImageBase; 1194 1168 1169 /* Print all image import descriptors. */ 1195 1170 for (i = 0; i < datasize; i += onaline) 1196 1171 { … … 1204 1179 char *dll; 1205 1180 1206 /* print (i + extra->DataDirectory[1].VirtualAddress)*/1181 /* Print (i + extra->DataDirectory[1].VirtualAddress). */ 1207 1182 fprintf (file, " %08lx\t", (unsigned long) (i + adj + dataoff)); 1208 1183 #if 0 1209 1184 if (i + 20 > datasize) 1210 { 1211 /* Check stuff. */ 1212 ; 1213 } 1214 1185 /* Check stuff. */ 1186 ; 1187 #endif 1215 1188 hint_addr = bfd_get_32 (abfd, data + i + dataoff); 1216 1189 time_stamp = bfd_get_32 (abfd, data + i + 4 + dataoff); … … 1234 1207 if (hint_addr != 0) 1235 1208 { 1236 fprintf (file, _("\tvma: Hint/Ord Member-Name\n")); 1209 bfd_byte *ft_data; 1210 asection *ft_section; 1211 bfd_vma ft_addr; 1212 bfd_size_type ft_datasize; 1213 int ft_idx; 1214 int ft_allocated = 0; 1215 1216 fprintf (file, _("\tvma: Hint/Ord Member-Name Bound-To\n")); 1237 1217 1238 1218 idx = hint_addr - adj; 1239 1219 1220 ft_addr = first_thunk + extra->ImageBase; 1221 ft_data = data; 1222 ft_idx = first_thunk - adj; 1223 ft_allocated = 0; 1224 1225 if (first_thunk != hint_addr) 1226 { 1227 /* Find the section which contains the first thunk. */ 1228 for (ft_section = abfd->sections; 1229 ft_section != NULL; 1230 ft_section = ft_section->next) 1231 { 1232 ft_datasize = bfd_section_size (abfd, ft_section); 1233 if (ft_addr >= ft_section->vma 1234 && ft_addr < ft_section->vma + ft_datasize) 1235 break; 1236 } 1237 1238 if (ft_section == NULL) 1239 { 1240 fprintf (file, 1241 _("\nThere is a first thunk, but the section containing it could not be found\n")); 1242 continue; 1243 } 1244 1245 /* Now check to see if this section is the same as our current 1246 section. If it is not then we will have to load its data in. */ 1247 if (ft_section == section) 1248 { 1249 ft_data = data; 1250 ft_idx = first_thunk - adj; 1251 } 1252 else 1253 { 1254 ft_idx = first_thunk - (ft_section->vma - extra->ImageBase); 1255 ft_data = (bfd_byte *) bfd_malloc (datasize); 1256 if (ft_data == NULL) 1257 continue; 1258 1259 /* Read datasize bfd_bytes starting at offset ft_idx. */ 1260 if (! bfd_get_section_contents (abfd, ft_section, 1261 (PTR) ft_data, 1262 (bfd_vma) ft_idx, 1263 datasize)) 1264 { 1265 free (ft_data); 1266 continue; 1267 } 1268 1269 ft_idx = 0; 1270 ft_allocated = 1; 1271 } 1272 } 1273 1274 /* Print HintName vector entries. */ 1240 1275 for (j = 0; j < datasize; j += 4) 1241 1276 { 1242 1277 unsigned long member = bfd_get_32 (abfd, data + idx + j); 1243 1278 1279 /* Print single IMAGE_IMPORT_BY_NAME vector. */ 1244 1280 if (member == 0) 1245 1281 break; 1282 1246 1283 if (member & 0x80000000) 1247 fprintf (file, "\t%04lx\t %4lu ", member,1248 member & 0x7fffffff);1284 fprintf (file, "\t%04lx\t %4lu <none>", 1285 member, member & 0x7fffffff); 1249 1286 else 1250 1287 { … … 1259 1296 1260 1297 /* If the time stamp is not zero, the import address 1261 1298 table holds actual addresses. */ 1262 1299 if (time_stamp != 0 1263 1300 && first_thunk != 0 1264 1301 && first_thunk != hint_addr) 1265 1302 fprintf (file, "\t%04lx", 1266 (long) bfd_get_32 (abfd, data + first_thunk - adj+ j));1303 (long) bfd_get_32 (abfd, ft_data + ft_idx + j)); 1267 1304 1268 1305 fprintf (file, "\n"); 1269 1306 } 1307 1308 if (ft_allocated) 1309 free (ft_data); 1270 1310 } 1271 1311 1272 if (hint_addr != first_thunk && time_stamp == 0)1273 {1274 int differ = 0;1275 int idx2;1276 1277 idx2 = first_thunk - adj;1278 1279 for (j = 0; j < datasize; j += 4)1280 {1281 int ordinal;1282 char *member_name;1283 bfd_vma hint_member = 0;1284 bfd_vma iat_member;1285 1286 if (hint_addr != 0)1287 hint_member = bfd_get_32 (abfd, data + idx + j);1288 iat_member = bfd_get_32 (abfd, data + idx2 + j);1289 1290 if (hint_addr == 0 && iat_member == 0)1291 break;1292 1293 if (hint_addr == 0 || hint_member != iat_member)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 }1302 if (iat_member == 0)1303 {1304 fprintf (file,1305 _("\t>>> Ran out of IAT members!\n"));1306 }1307 else1308 {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 }1321 if (differ == 0)1322 {1323 fprintf (file,1324 _("\tThe Import Address Table is identical\n"));1325 }1326 }1327 1328 1312 fprintf (file, "\n"); 1329 1330 1313 } 1331 1314 1332 1315 free (data); 1333 1316 1334 return true;1317 return TRUE; 1335 1318 } 1336 1319 1337 static b oolean1320 static bfd_boolean 1338 1321 pe_print_edata (abfd, vfile) 1339 1322 bfd *abfd; … … 1343 1326 bfd_byte *data; 1344 1327 asection *section; 1345 1346 1328 bfd_size_type datasize = 0; 1347 1329 bfd_size_type dataoff; 1348 1330 bfd_size_type i; 1349 1350 1331 bfd_signed_vma adj; 1351 struct EDT_type { 1352 long export_flags; /* reserved - should be zero */ 1332 struct EDT_type 1333 { 1334 long export_flags; /* reserved - should be zero */ 1353 1335 long time_stamp; 1354 1336 short major_ver; 1355 1337 short minor_ver; 1356 bfd_vma name; 1357 long base; 1358 unsigned long num_functions; 1359 unsigned long num_names; 1360 bfd_vma eat_addr; 1361 bfd_vma npt_addr; 1362 bfd_vma ot_addr; 1338 bfd_vma name; /* rva - relative to image base */ 1339 long base; /* ordinal base */ 1340 unsigned long num_functions;/* Number in the export address table */ 1341 unsigned long num_names; /* Number in the name pointer table */ 1342 bfd_vma eat_addr; /* rva to the export address table */ 1343 bfd_vma npt_addr; /* rva to the Export Name Pointer Table */ 1344 bfd_vma ot_addr; /* rva to the Ordinal Table */ 1363 1345 } edt; 1364 1346 … … 1375 1357 section = bfd_get_section_by_name (abfd, ".edata"); 1376 1358 if (section == NULL) 1377 return true;1359 return TRUE; 1378 1360 1379 1361 addr = section->vma; 1380 1362 datasize = bfd_section_size (abfd, section); 1381 1363 if (datasize == 0) 1382 return true;1364 return TRUE; 1383 1365 } 1384 1366 else 1385 1367 { 1386 1368 addr += extra->ImageBase; 1369 1387 1370 for (section = abfd->sections; section != NULL; section = section->next) 1388 1371 { 1389 1372 datasize = bfd_section_size (abfd, section); 1373 1390 1374 if (addr >= section->vma && addr < section->vma + datasize) 1391 1375 break; … … 1396 1380 fprintf (file, 1397 1381 _("\nThere is an export table, but the section containing it could not be found\n")); 1398 return true;1382 return TRUE; 1399 1383 } 1400 1384 } … … 1408 1392 data = (bfd_byte *) bfd_malloc (datasize); 1409 1393 if (data == NULL) 1410 return false;1411 1412 if (! bfd_get_section_contents (abfd, section, (PTR) data, dataoff,1413 datasize))1414 return false;1394 return FALSE; 1395 1396 if (! bfd_get_section_contents (abfd, section, (PTR) data, 1397 (file_ptr) dataoff, datasize)) 1398 return FALSE; 1415 1399 1416 1400 /* Go get Export Directory Table. */ … … 1429 1413 adj = section->vma - extra->ImageBase + dataoff; 1430 1414 1431 /* Dump the EDT first first*/1415 /* Dump the EDT first. */ 1432 1416 fprintf (file, 1433 1417 _("\nThe Export Tables (interpreted %s section contents)\n\n"), … … 1483 1467 a list of pointers that either locate a function in this dll, or 1484 1468 forward the call to another dll. Something like: 1485 typedef union { 1469 typedef union 1470 { 1486 1471 long export_rva; 1487 1472 long forwarder_rva; … … 1548 1533 free (data); 1549 1534 1550 return true;1535 return TRUE; 1551 1536 } 1552 1537 … … 1556 1541 covers and the address of the corresponding unwind info data. */ 1557 1542 1558 static b oolean1543 static bfd_boolean 1559 1544 pe_print_pdata (abfd, vfile) 1560 1545 bfd *abfd; … … 1577 1562 || coff_section_data (abfd, section) == NULL 1578 1563 || pei_section_data (abfd, section) == NULL) 1579 return true;1564 return TRUE; 1580 1565 1581 1566 stop = pei_section_data (abfd, section)->virt_size; … … 1591 1576 _(" vma:\t\t\tBegin Address End Address Unwind Info\n")); 1592 1577 #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 1599 if (bfd_section_size (abfd, section) == 0) 1600 return true; 1601 1602 data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd, section)); 1578 fprintf (file, _("\ 1579 vma:\t\tBegin End EH EH PrologEnd Exception\n\ 1580 \t\tAddress Address Handler Data Address Mask\n")); 1581 #endif 1582 1603 1583 datasize = bfd_section_size (abfd, section); 1584 if (datasize == 0) 1585 return TRUE; 1586 1587 data = (bfd_byte *) bfd_malloc (datasize); 1604 1588 if (data == NULL && datasize != 0) 1605 return false; 1606 1607 bfd_get_section_contents (abfd, 1608 section, 1609 (PTR) data, 0, 1610 bfd_section_size (abfd, section)); 1589 return FALSE; 1590 1591 bfd_get_section_contents (abfd, section, (PTR) data, (bfd_vma) 0, 1592 datasize); 1611 1593 1612 1594 start = 0; … … 1632 1614 if (begin_addr == 0 && end_addr == 0 && eh_handler == 0 1633 1615 && eh_data == 0 && prolog_end_addr == 0) 1634 { 1635 /* We are probably into the padding of the section now. */ 1636 break; 1637 } 1616 /* We are probably into the padding of the section now. */ 1617 break; 1638 1618 1639 1619 em_data = ((eh_handler & 0x1) << 2) | (prolog_end_addr & 0x3); … … 1684 1664 free (data); 1685 1665 1686 return true;1666 return TRUE; 1687 1667 } 1688 1668 1689 1669 #define IMAGE_REL_BASED_HIGHADJ 4 1690 static 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 }; 1705 1706 static boolean 1670 static const char * const tbl[] = 1671 { 1672 "ABSOLUTE", 1673 "HIGH", 1674 "LOW", 1675 "HIGHLOW", 1676 "HIGHADJ", 1677 "MIPS_JMPADDR", 1678 "SECTION", 1679 "REL32", 1680 "RESERVED1", 1681 "MIPS_JMPADDR16", 1682 "DIR64", 1683 "HIGH3ADJ" 1684 "UNKNOWN", /* MUST be last */ 1685 }; 1686 1687 static bfd_boolean 1707 1688 pe_print_reloc (abfd, vfile) 1708 1689 bfd *abfd; … … 1712 1693 bfd_byte *data = 0; 1713 1694 asection *section = bfd_get_section_by_name (abfd, ".reloc"); 1714 bfd_size_type datasize = 0;1695 bfd_size_type datasize; 1715 1696 bfd_size_type i; 1716 1697 bfd_size_type start, stop; 1717 1698 1718 1699 if (section == NULL) 1719 return true;1700 return TRUE; 1720 1701 1721 1702 if (bfd_section_size (abfd, section) == 0) 1722 return true;1703 return TRUE; 1723 1704 1724 1705 fprintf (file, 1725 1706 _("\n\nPE File Base Relocations (interpreted .reloc section contents)\n")); 1726 1707 1727 data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd, section));1728 1708 datasize = bfd_section_size (abfd, section); 1709 data = (bfd_byte *) bfd_malloc (datasize); 1729 1710 if (data == NULL && datasize != 0) 1730 return false; 1731 1732 bfd_get_section_contents (abfd, 1733 section, 1734 (PTR) data, 0, 1735 bfd_section_size (abfd, section)); 1711 return FALSE; 1712 1713 bfd_get_section_contents (abfd, section, (PTR) data, (bfd_vma) 0, 1714 datasize); 1736 1715 1737 1716 start = 0; … … 1746 1725 1747 1726 /* 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 1727 of two 32 bit quantities, followed by a number of 16 bit entries. */ 1750 1728 virtual_address = bfd_get_32 (abfd, data+i); 1751 1729 size = bfd_get_32 (abfd, data+i+4); … … 1753 1731 1754 1732 if (size == 0) 1755 { 1756 break; 1757 } 1733 break; 1758 1734 1759 1735 fprintf (file, … … 1786 1762 fprintf (file, "\n"); 1787 1763 } 1764 1788 1765 i += size; 1789 1766 } … … 1791 1768 free (data); 1792 1769 1793 return true;1770 return TRUE; 1794 1771 } 1795 1772 1796 1773 /* Print out the program headers. */ 1797 1774 1798 b oolean1775 bfd_boolean 1799 1776 _bfd_XX_print_private_bfd_data_common (abfd, vfile) 1800 1777 bfd *abfd; … … 1826 1803 1827 1804 /* ctime implies '\n'. */ 1828 fprintf (file, "\nTime/Date\t\t%s", ctime (&pe->coff.timestamp)); 1805 { 1806 time_t t = pe->coff.timestamp; 1807 fprintf (file, "\nTime/Date\t\t%s", ctime (&t)); 1808 } 1829 1809 fprintf (file, "\nImageBase\t\t"); 1830 1810 fprintf_vma (file, i->ImageBase); … … 1843 1823 fprintf (file, "SizeOfHeaders\t\t%08lx\n", i->SizeOfHeaders); 1844 1824 fprintf (file, "CheckSum\t\t%08lx\n", i->CheckSum); 1825 1845 1826 switch (i->Subsystem) 1846 1827 { … … 1873 1854 break; 1874 1855 } 1856 1875 1857 fprintf (file, "Subsystem\t\t%08x", i->Subsystem); 1876 1858 if (subsystem_name) … … 1902 1884 pe_print_reloc (abfd, vfile); 1903 1885 1904 return true;1886 return TRUE; 1905 1887 } 1906 1888 … … 1908 1890 to the output bfd. */ 1909 1891 1910 b oolean1892 bfd_boolean 1911 1893 _bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd) 1912 1894 bfd *ibfd, *obfd; … … 1915 1897 if (ibfd->xvec->flavour != bfd_target_coff_flavour 1916 1898 || obfd->xvec->flavour != bfd_target_coff_flavour) 1917 return true;1899 return TRUE; 1918 1900 1919 1901 pe_data (obfd)->pe_opthdr = pe_data (ibfd)->pe_opthdr; 1920 1902 pe_data (obfd)->dll = pe_data (ibfd)->dll; 1921 1903 1922 /* for strip: if we removed .reloc, we'll make a real mess of things1904 /* For strip: if we removed .reloc, we'll make a real mess of things 1923 1905 if we don't remove this entry as well. */ 1924 1906 if (! pe_data (obfd)->has_reloc_section) … … 1927 1909 pe_data (obfd)->pe_opthdr.DataDirectory[5].Size = 0; 1928 1910 } 1929 return true;1911 return TRUE; 1930 1912 } 1931 1913 1932 1914 /* Copy private section data. */ 1933 boolean 1915 1916 bfd_boolean 1934 1917 _bfd_XX_bfd_copy_private_section_data (ibfd, isec, obfd, osec) 1935 1918 bfd *ibfd; … … 1940 1923 if (bfd_get_flavour (ibfd) != bfd_target_coff_flavour 1941 1924 || bfd_get_flavour (obfd) != bfd_target_coff_flavour) 1942 return true;1925 return TRUE; 1943 1926 1944 1927 if (coff_section_data (ibfd, isec) != NULL … … 1947 1930 if (coff_section_data (obfd, osec) == NULL) 1948 1931 { 1949 osec->used_by_bfd =1950 (PTR) bfd_zalloc (obfd, sizeof (struct coff_section_tdata));1932 bfd_size_type amt = sizeof (struct coff_section_tdata); 1933 osec->used_by_bfd = (PTR) bfd_zalloc (obfd, amt); 1951 1934 if (osec->used_by_bfd == NULL) 1952 return false;1935 return FALSE; 1953 1936 } 1937 1954 1938 if (pei_section_data (obfd, osec) == NULL) 1955 1939 { 1956 coff_section_data (obfd, osec)->tdata =1957 (PTR) bfd_zalloc (obfd, sizeof (struct pei_section_tdata));1940 bfd_size_type amt = sizeof (struct pei_section_tdata); 1941 coff_section_data (obfd, osec)->tdata = (PTR) bfd_zalloc (obfd, amt); 1958 1942 if (coff_section_data (obfd, osec)->tdata == NULL) 1959 return false;1943 return FALSE; 1960 1944 } 1945 1961 1946 pei_section_data (obfd, osec)->virt_size = 1962 1947 pei_section_data (ibfd, isec)->virt_size; … … 1965 1950 } 1966 1951 1967 return true;1952 return TRUE; 1968 1953 } 1969 1954 … … 1988 1973 access. */ 1989 1974 1990 b oolean1975 bfd_boolean 1991 1976 _bfd_XXi_final_link_postscript (abfd, pfinfo) 1992 1977 bfd *abfd; … … 2005 1990 of .idata$2 + .idata$3. */ 2006 1991 h1 = coff_link_hash_lookup (coff_hash_table (info), 2007 ".idata$2", false, false, true);1992 ".idata$2", FALSE, FALSE, TRUE); 2008 1993 if (h1 != NULL) 2009 1994 { … … 2013 1998 + h1->root.u.def.section->output_offset); 2014 1999 h1 = coff_link_hash_lookup (coff_hash_table (info), 2015 ".idata$4", false, false, true);2000 ".idata$4", FALSE, FALSE, TRUE); 2016 2001 pe_data (abfd)->pe_opthdr.DataDirectory[1].Size = 2017 2002 ((h1->root.u.def.value … … 2023 2008 .idata$5. */ 2024 2009 h1 = coff_link_hash_lookup (coff_hash_table (info), 2025 ".idata$5", false, false, true);2010 ".idata$5", FALSE, FALSE, TRUE); 2026 2011 pe_data (abfd)->pe_opthdr.DataDirectory[12].VirtualAddress = 2027 2012 (h1->root.u.def.value … … 2029 2014 + h1->root.u.def.section->output_offset); 2030 2015 h1 = coff_link_hash_lookup (coff_hash_table (info), 2031 ".idata$6", false, false, true);2016 ".idata$6", FALSE, FALSE, TRUE); 2032 2017 pe_data (abfd)->pe_opthdr.DataDirectory[12].Size = 2033 2018 ((h1->root.u.def.value 2034 2019 + h1->root.u.def.section->output_section->vma 2035 2020 + h1->root.u.def.section->output_offset) 2036 - pe_data (abfd)->pe_opthdr.DataDirectory[12].VirtualAddress); 2037 } 2038 2021 - pe_data (abfd)->pe_opthdr.DataDirectory[12].VirtualAddress); 2022 } 2023 2039 2024 /* If we couldn't find idata$2, we either have an excessively 2040 2025 trivial program or are in DEEP trouble; we have to assume trivial 2041 2026 program.... */ 2042 return true;2027 return TRUE; 2043 2028 } -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.