Changeset 609 for branches/GNU/src/binutils/bfd/coff-ppc.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/coff-ppc.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* BFD back-end for PowerPC Microsoft Portable Executable files. 2 2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 3 2000, 2001 3 2000, 2001, 2002, 2003 4 4 Free Software Foundation, Inc. 5 5 … … 10 10 intel backends, and the PE work for the arm. 11 11 12 This file is part of BFD, the Binary File Descriptor library.13 14 This program is free software; you can redistribute it and/or modify15 it under the terms of the GNU General Public License as published by16 the Free Software Foundation; either version 2 of the License, or17 (at your option) any later version.18 19 This program is distributed in the hope that it will be useful,20 but WITHOUT ANY WARRANTY; without even the implied warranty of21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the22 GNU General Public License for more details.23 24 You should have received a copy of the GNU General Public License25 along with this program; if not, write to the Free Software26 Foundation, 59 Temple Place - Suite 330,27 Boston, MA 02111-1307, USA. */12 This file is part of BFD, the Binary File Descriptor library. 13 14 This program is free software; you can redistribute it and/or modify 15 it under the terms of the GNU General Public License as published by 16 the Free Software Foundation; either version 2 of the License, or 17 (at your option) any later version. 18 19 This program is distributed in the hope that it will be useful, 20 but WITHOUT ANY WARRANTY; without even the implied warranty of 21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 GNU General Public License for more details. 23 24 You should have received a copy of the GNU General Public License 25 along with this program; if not, write to the Free Software 26 Foundation, 59 Temple Place - Suite 330, 27 Boston, MA 02111-1307, USA. */ 28 28 29 29 /* Current State: … … 32 32 - ld will link files, but they do not run. 33 33 - dlltool will not produce correct output in some .reloc cases, and will 34 not produce the right glue code for dll function calls. 35 */ 34 not produce the right glue code for dll function calls. */ 36 35 37 36 #include "bfd.h" … … 55 54 /* This file is compiled more than once, but we only compile the 56 55 final_link routine once. */ 57 extern b oolean ppc_bfd_coff_final_link56 extern bfd_boolean ppc_bfd_coff_final_link 58 57 PARAMS ((bfd *, struct bfd_link_info *)); 59 58 extern void dump_toc PARAMS ((PTR)); 60 59 61 /* The toc is a set of bfd_vma fields. We use the fact that valid */62 /* addresses are even (i.e. the bit representing "1" is off) to allow */ 63 /* us to encode a little extra information in the field */ 64 /* - Unallocated addresses are intialized to 1. */ 65 /* - Allocated addresses are even numbers. */ 66 /* The first time we actually write a reference to the toc in the bfd, */ 67 /* we want to record that fact in a fixup file (if it is asked for), so */ 68 /* we keep track of whether or not an address has been written by marking */ 69 /* the low order bit with a "1" upon writing*/60 /* The toc is a set of bfd_vma fields. We use the fact that valid 61 addresses are even (i.e. the bit representing "1" is off) to allow 62 us to encode a little extra information in the field 63 - Unallocated addresses are initialized to 1. 64 - Allocated addresses are even numbers. 65 The first time we actually write a reference to the toc in the bfd, 66 we want to record that fact in a fixup file (if it is asked for), so 67 we keep track of whether or not an address has been written by marking 68 the low order bit with a "1" upon writing. */ 70 69 71 70 #define SET_UNALLOCATED(x) ((x) = 1) … … 76 75 #define MAKE_ADDR_AGAIN(x) ((x) &= ~1) 77 76 78 /* Turn on this check if you suspect something amiss in the hash tables */77 /* Turn on this check if you suspect something amiss in the hash tables. */ 79 78 #ifdef DEBUG_HASH 80 79 81 /* Need a 7 char string for an eye catcher */80 /* Need a 7 char string for an eye catcher. */ 82 81 #define EYE "krkjunk" 83 82 … … 102 101 103 102 /* In order not to add an int to every hash table item for every coff 104 linker, we define our own hash table, derived from the coff one */103 linker, we define our own hash table, derived from the coff one. */ 105 104 106 105 /* PE linker hash table entries. */ … … 108 107 struct ppc_coff_link_hash_entry 109 108 { 110 struct coff_link_hash_entry root; /* First entry, as required */109 struct coff_link_hash_entry root; /* First entry, as required. */ 111 110 112 111 /* As we wonder around the relocs, we'll keep the assigned toc_offset 113 here */114 bfd_vma toc_offset; /* Our addition, as required */112 here. */ 113 bfd_vma toc_offset; /* Our addition, as required. */ 115 114 int symbol_is_glue; 116 115 unsigned long int glue_insn; … … 123 122 struct ppc_coff_link_hash_table 124 123 { 125 struct coff_link_hash_table root; /* First entry, as required */124 struct coff_link_hash_table root; /* First entry, as required. */ 126 125 }; 127 126 … … 129 128 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, 130 129 const char *)); 131 static b oolean ppc_coff_link_hash_table_init130 static bfd_boolean ppc_coff_link_hash_table_init 132 131 PARAMS ((struct ppc_coff_link_hash_table *, bfd *, 133 132 struct bfd_hash_entry *(*) (struct bfd_hash_entry *, … … 136 135 static struct bfd_link_hash_table *ppc_coff_link_hash_table_create 137 136 PARAMS ((bfd *)); 138 static b oolean coff_ppc_relocate_section137 static bfd_boolean coff_ppc_relocate_section 139 138 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 140 139 struct internal_reloc *, struct internal_syment *, asection **)); … … 173 172 { 174 173 /* Initialize the local fields. */ 175 SET_UNALLOCATED (ret->toc_offset);174 SET_UNALLOCATED (ret->toc_offset); 176 175 ret->symbol_is_glue = 0; 177 176 ret->glue_insn = 0; 178 177 179 HASH_CHECK_INIT (ret);178 HASH_CHECK_INIT (ret); 180 179 } 181 180 … … 185 184 /* Initialize a PE linker hash table. */ 186 185 187 static b oolean186 static bfd_boolean 188 187 ppc_coff_link_hash_table_init (table, abfd, newfunc) 189 188 struct ppc_coff_link_hash_table *table; … … 203 202 { 204 203 struct ppc_coff_link_hash_table *ret; 205 206 ret = ((struct ppc_coff_link_hash_table *) 207 bfd_alloc (abfd, sizeof (struct ppc_coff_link_hash_table)));204 bfd_size_type amt = sizeof (struct ppc_coff_link_hash_table); 205 206 ret = (struct ppc_coff_link_hash_table *) bfd_malloc (amt); 208 207 if (ret == NULL) 209 208 return NULL; … … 211 210 ppc_coff_link_hash_newfunc)) 212 211 { 213 bfd_release (abfd,ret);212 free (ret); 214 213 return (struct bfd_link_hash_table *) NULL; 215 214 } … … 217 216 } 218 217 219 /* Now, tailor coffcode.h to use our hash stuff */218 /* Now, tailor coffcode.h to use our hash stuff. */ 220 219 221 220 #define coff_bfd_link_hash_table_create ppc_coff_link_hash_table_create 222 221 223 222 224 /* The nt loader points the toc register to &toc + 32768, in order to */225 /* use the complete range of a 16-bit displacement. We have to adjust */ 226 /* for this when we fix up loads displaced off the toc reg.*/223 /* The nt loader points the toc register to &toc + 32768, in order to 224 use the complete range of a 16-bit displacement. We have to adjust 225 for this when we fix up loads displaced off the toc reg. */ 227 226 #define TOC_LOAD_ADJUSTMENT (-32768) 228 227 #define TOC_SECTION_NAME ".private.toc" … … 236 235 #define MINUS_ONE (((bfd_vma)0) - 1) 237 236 238 /* these should definitely go in a header file somewhere... */237 /* These should definitely go in a header file somewhere... */ 239 238 240 239 /* NOP */ … … 286 285 #define IMAGE_REL_PPC_SECREL16 0x000F 287 286 288 /* stuff to handle immediate data when the number of bits in the */289 /* data is greater than the number of bits in the immediate field */ 290 /* We need to do (usually) 32 bit arithmetic on 16 bit chunks*/287 /* Stuff to handle immediate data when the number of bits in the 288 data is greater than the number of bits in the immediate field 289 We need to do (usually) 32 bit arithmetic on 16 bit chunks. */ 291 290 #define IMAGE_REL_PPC_REFHI 0x0010 292 291 #define IMAGE_REL_PPC_REFLO 0x0011 293 292 #define IMAGE_REL_PPC_PAIR 0x0012 294 293 295 /* This is essentially the same as tocrel16, with TOCDEFN assumed */294 /* This is essentially the same as tocrel16, with TOCDEFN assumed. */ 296 295 #define IMAGE_REL_PPC_TOCREL16_DEFN 0x0013 297 296 298 /* Flag bits in IMAGE_RELOCATION.TYPE*/299 300 /* subtract reloc value rather than adding it*/297 /* Flag bits in IMAGE_RELOCATION.TYPE. */ 298 299 /* Subtract reloc value rather than adding it. */ 301 300 #define IMAGE_REL_PPC_NEG 0x0100 302 301 303 /* fix branch prediction bit to predict branch taken*/302 /* Fix branch prediction bit to predict branch taken. */ 304 303 #define IMAGE_REL_PPC_BRTAKEN 0x0200 305 304 306 /* fix branch prediction bit to predict branch not taken*/305 /* Fix branch prediction bit to predict branch not taken. */ 307 306 #define IMAGE_REL_PPC_BRNTAKEN 0x0400 308 307 309 /* toc slot defined in file (or, data in toc)*/308 /* TOC slot defined in file (or, data in toc). */ 310 309 #define IMAGE_REL_PPC_TOCDEFN 0x0800 311 310 312 /* masks to isolate above values in IMAGE_RELOCATION.Type*/311 /* Masks to isolate above values in IMAGE_RELOCATION.Type. */ 313 312 #define IMAGE_REL_PPC_TYPEMASK 0x00FF 314 313 #define IMAGE_REL_PPC_FLAGMASK 0x0F00 … … 320 319 321 320 322 /* static helper functions to make relocation work*/321 /* Static helper functions to make relocation work. */ 323 322 /* (Work In Progress) */ 324 323 … … 389 388 char **error)); 390 389 391 static b oolean in_reloc_p PARAMS((bfd *abfd, reloc_howto_type *howto));390 static bfd_boolean in_reloc_p PARAMS((bfd *abfd, reloc_howto_type *howto)); 392 391 393 392 394 393 /* FIXME: It'll take a while to get through all of these. I only need a few to 395 394 get us started, so those I'll make sure work. Those marked FIXME are either 396 completely unverified or have a specific unknown marked in the comment */ 397 398 /*---------------------------------------------------------------------------*/ 399 /* */ 400 /* Relocation entries for Windows/NT on PowerPC. */ 401 /* */ 402 /* From the document "" we find the following listed as used relocs: */ 403 /* */ 404 /* ABSOLUTE : The noop */ 405 /* ADDR[64|32|16] : fields that hold addresses in data fields or the */ 406 /* 16 bit displacement field on a load/store. */ 407 /* ADDR[24|14] : fields that hold addresses in branch and cond */ 408 /* branches. These represent [26|16] bit addresses. */ 409 /* The low order 2 bits are preserved. */ 410 /* REL[24|14] : branches relative to the Instruction Address */ 411 /* register. These represent [26|16] bit addresses, */ 412 /* as before. The instruction field will be zero, and */ 413 /* the address of the SYM will be inserted at link time. */ 414 /* TOCREL16 : 16 bit displacement field referring to a slot in */ 415 /* toc. */ 416 /* TOCREL14 : 16 bit displacement field, similar to REL14 or ADDR14. */ 417 /* ADDR32NB : 32 bit address relative to the virtual origin. */ 418 /* (On the alpha, this is always a linker generated thunk)*/ 419 /* (i.e. 32bit addr relative to the image base) */ 420 /* SECREL : The value is relative to the start of the section */ 421 /* containing the symbol. */ 422 /* SECTION : access to the header containing the item. Supports the */ 423 /* codeview debugger. */ 424 /* */ 425 /* In particular, note that the document does not indicate that the */ 426 /* relocations listed in the header file are used. */ 427 /* */ 428 /* */ 429 /* */ 430 /*---------------------------------------------------------------------------*/ 395 completely unverified or have a specific unknown marked in the comment. */ 396 397 /* Relocation entries for Windows/NT on PowerPC. 398 399 From the document "" we find the following listed as used relocs: 400 401 ABSOLUTE : The noop 402 ADDR[64|32|16] : fields that hold addresses in data fields or the 403 16 bit displacement field on a load/store. 404 ADDR[24|14] : fields that hold addresses in branch and cond 405 branches. These represent [26|16] bit addresses. 406 The low order 2 bits are preserved. 407 REL[24|14] : branches relative to the Instruction Address 408 register. These represent [26|16] bit addresses, 409 as before. The instruction field will be zero, and 410 the address of the SYM will be inserted at link time. 411 TOCREL16 : 16 bit displacement field referring to a slot in 412 toc. 413 TOCREL14 : 16 bit displacement field, similar to REL14 or ADDR14. 414 ADDR32NB : 32 bit address relative to the virtual origin. 415 (On the alpha, this is always a linker generated thunk) 416 (i.e. 32bit addr relative to the image base) 417 SECREL : The value is relative to the start of the section 418 containing the symbol. 419 SECTION : access to the header containing the item. Supports the 420 codeview debugger. 421 422 In particular, note that the document does not indicate that the 423 relocations listed in the header file are used. */ 424 431 425 432 426 static reloc_howto_type ppc_coff_howto_table[] = … … 438 432 0, /* size (0 = byte, 1 = short, 2 = long) */ 439 433 0, /* bitsize */ 440 false, /* pc_relative */434 FALSE, /* pc_relative */ 441 435 0, /* bitpos */ 442 436 complain_overflow_dont, /* dont complain_on_overflow */ 443 437 0, /* special_function */ 444 438 "ABSOLUTE", /* name */ 445 false, /* partial_inplace */439 FALSE, /* partial_inplace */ 446 440 0x00, /* src_mask */ 447 441 0x00, /* dst_mask */ 448 false), /* pcrel_offset */442 FALSE), /* pcrel_offset */ 449 443 450 444 /* IMAGE_REL_PPC_ADDR64 0x0001 64-bit address */ … … 454 448 3, /* size (0 = byte, 1 = short, 2 = long) */ 455 449 64, /* bitsize */ 456 false, /* pc_relative */450 FALSE, /* pc_relative */ 457 451 0, /* bitpos */ 458 452 complain_overflow_bitfield, /* complain_on_overflow */ 459 453 0, /* special_function */ 460 454 "ADDR64", /* name */ 461 true, /* partial_inplace */455 TRUE, /* partial_inplace */ 462 456 MINUS_ONE, /* src_mask */ 463 457 MINUS_ONE, /* dst_mask */ 464 false), /* pcrel_offset */458 FALSE), /* pcrel_offset */ 465 459 466 460 /* IMAGE_REL_PPC_ADDR32 0x0002 32-bit address */ … … 470 464 2, /* size (0 = byte, 1 = short, 2 = long) */ 471 465 32, /* bitsize */ 472 false, /* pc_relative */466 FALSE, /* pc_relative */ 473 467 0, /* bitpos */ 474 468 complain_overflow_bitfield, /* complain_on_overflow */ 475 469 0, /* special_function */ 476 470 "ADDR32", /* name */ 477 true, /* partial_inplace */471 TRUE, /* partial_inplace */ 478 472 0xffffffff, /* src_mask */ 479 473 0xffffffff, /* dst_mask */ 480 false), /* pcrel_offset */474 FALSE), /* pcrel_offset */ 481 475 482 476 /* IMAGE_REL_PPC_ADDR24 0x0003 26-bit address, shifted left 2 (branch absolute) */ … … 489 483 2, /* size (0 = byte, 1 = short, 2 = long) */ 490 484 26, /* bitsize */ 491 false, /* pc_relative */485 FALSE, /* pc_relative */ 492 486 0, /* bitpos */ 493 487 complain_overflow_bitfield, /* complain_on_overflow */ 494 488 0, /* special_function */ 495 489 "ADDR24", /* name */ 496 true, /* partial_inplace */490 TRUE, /* partial_inplace */ 497 491 0x07fffffc, /* src_mask */ 498 492 0x07fffffc, /* dst_mask */ 499 false), /* pcrel_offset */493 FALSE), /* pcrel_offset */ 500 494 501 495 /* IMAGE_REL_PPC_ADDR16 0x0004 16-bit address */ … … 505 499 1, /* size (0 = byte, 1 = short, 2 = long) */ 506 500 16, /* bitsize */ 507 false, /* pc_relative */501 FALSE, /* pc_relative */ 508 502 0, /* bitpos */ 509 503 complain_overflow_signed, /* complain_on_overflow */ 510 504 0, /* special_function */ 511 505 "ADDR16", /* name */ 512 true, /* partial_inplace */506 TRUE, /* partial_inplace */ 513 507 0xffff, /* src_mask */ 514 508 0xffff, /* dst_mask */ 515 false), /* pcrel_offset */509 FALSE), /* pcrel_offset */ 516 510 517 511 /* IMAGE_REL_PPC_ADDR14 0x0005 */ … … 523 517 1, /* size (0 = byte, 1 = short, 2 = long) */ 524 518 16, /* bitsize */ 525 false, /* pc_relative */519 FALSE, /* pc_relative */ 526 520 0, /* bitpos */ 527 521 complain_overflow_signed, /* complain_on_overflow */ 528 522 0, /* special_function */ 529 523 "ADDR16", /* name */ 530 true, /* partial_inplace */524 TRUE, /* partial_inplace */ 531 525 0xffff, /* src_mask */ 532 526 0xffff, /* dst_mask */ 533 false), /* pcrel_offset */527 FALSE), /* pcrel_offset */ 534 528 535 529 /* IMAGE_REL_PPC_REL24 0x0006 */ … … 540 534 2, /* size (0 = byte, 1 = short, 2 = long) */ 541 535 26, /* bitsize */ 542 true, /* pc_relative */536 TRUE, /* pc_relative */ 543 537 0, /* bitpos */ 544 538 complain_overflow_signed, /* complain_on_overflow */ 545 539 0, /* special_function */ 546 540 "REL24", /* name */ 547 true, /* partial_inplace */541 TRUE, /* partial_inplace */ 548 542 0x3fffffc, /* src_mask */ 549 543 0x3fffffc, /* dst_mask */ 550 false), /* pcrel_offset */544 FALSE), /* pcrel_offset */ 551 545 552 546 /* IMAGE_REL_PPC_REL14 0x0007 */ … … 559 553 1, /* size (0 = byte, 1 = short, 2 = long) */ 560 554 16, /* bitsize */ 561 false, /* pc_relative */555 FALSE, /* pc_relative */ 562 556 0, /* bitpos */ 563 557 complain_overflow_signed, /* complain_on_overflow */ 564 558 0, /* special_function */ 565 559 "ADDR16", /* name */ 566 true, /* partial_inplace */560 TRUE, /* partial_inplace */ 567 561 0xffff, /* src_mask */ 568 562 0xffff, /* dst_mask */ 569 true), /* pcrel_offset */563 TRUE), /* pcrel_offset */ 570 564 571 565 /* IMAGE_REL_PPC_TOCREL16 0x0008 */ … … 576 570 1, /* size (0 = byte, 1 = short, 2 = long) */ 577 571 16, /* bitsize */ 578 false, /* pc_relative */572 FALSE, /* pc_relative */ 579 573 0, /* bitpos */ 580 574 complain_overflow_dont, /* complain_on_overflow */ 581 575 ppc_toc16_reloc, /* special_function */ 582 576 "TOCREL16", /* name */ 583 false, /* partial_inplace */577 FALSE, /* partial_inplace */ 584 578 0xffff, /* src_mask */ 585 579 0xffff, /* dst_mask */ 586 false), /* pcrel_offset */580 FALSE), /* pcrel_offset */ 587 581 588 582 /* IMAGE_REL_PPC_TOCREL14 0x0009 */ … … 593 587 1, /* size (0 = byte, 1 = short, 2 = long) */ 594 588 16, /* bitsize */ 595 false, /* pc_relative */589 FALSE, /* pc_relative */ 596 590 0, /* bitpos */ 597 591 complain_overflow_signed, /* complain_on_overflow */ 598 592 0, /* special_function */ 599 593 "TOCREL14", /* name */ 600 false, /* partial_inplace */594 FALSE, /* partial_inplace */ 601 595 0xffff, /* src_mask */ 602 596 0xffff, /* dst_mask */ 603 false), /* pcrel_offset */597 FALSE), /* pcrel_offset */ 604 598 605 599 /* IMAGE_REL_PPC_ADDR32NB 0x000A */ … … 610 604 2, /* size (0 = byte, 1 = short, 2 = long) */ 611 605 32, /* bitsize */ 612 false, /* pc_relative */606 FALSE, /* pc_relative */ 613 607 0, /* bitpos */ 614 608 complain_overflow_signed, /* complain_on_overflow */ 615 609 0, /* special_function */ 616 610 "ADDR32NB", /* name */ 617 true, /* partial_inplace */611 TRUE, /* partial_inplace */ 618 612 0xffffffff, /* src_mask */ 619 613 0xffffffff, /* dst_mask */ 620 false), /* pcrel_offset */614 FALSE), /* pcrel_offset */ 621 615 622 616 /* IMAGE_REL_PPC_SECREL 0x000B */ … … 627 621 2, /* size (0 = byte, 1 = short, 2 = long) */ 628 622 32, /* bitsize */ 629 false, /* pc_relative */623 FALSE, /* pc_relative */ 630 624 0, /* bitpos */ 631 625 complain_overflow_signed, /* complain_on_overflow */ 632 626 ppc_secrel_reloc, /* special_function */ 633 627 "SECREL", /* name */ 634 true, /* partial_inplace */628 TRUE, /* partial_inplace */ 635 629 0xffffffff, /* src_mask */ 636 630 0xffffffff, /* dst_mask */ 637 true), /* pcrel_offset */631 TRUE), /* pcrel_offset */ 638 632 639 633 /* IMAGE_REL_PPC_SECTION 0x000C */ … … 644 638 2, /* size (0 = byte, 1 = short, 2 = long) */ 645 639 32, /* bitsize */ 646 false, /* pc_relative */640 FALSE, /* pc_relative */ 647 641 0, /* bitpos */ 648 642 complain_overflow_signed, /* complain_on_overflow */ 649 643 ppc_section_reloc, /* special_function */ 650 644 "SECTION", /* name */ 651 true, /* partial_inplace */645 TRUE, /* partial_inplace */ 652 646 0xffffffff, /* src_mask */ 653 647 0xffffffff, /* dst_mask */ 654 true), /* pcrel_offset */648 TRUE), /* pcrel_offset */ 655 649 656 650 /* IMAGE_REL_PPC_IFGLUE 0x000D */ … … 661 655 2, /* size (0 = byte, 1 = short, 2 = long) */ 662 656 32, /* bitsize */ 663 false, /* pc_relative */657 FALSE, /* pc_relative */ 664 658 0, /* bitpos */ 665 659 complain_overflow_signed, /* complain_on_overflow */ 666 660 0, /* special_function */ 667 661 "IFGLUE", /* name */ 668 true, /* partial_inplace */662 TRUE, /* partial_inplace */ 669 663 0xffffffff, /* src_mask */ 670 664 0xffffffff, /* dst_mask */ 671 false), /* pcrel_offset */665 FALSE), /* pcrel_offset */ 672 666 673 667 /* IMAGE_REL_PPC_IMGLUE 0x000E */ … … 678 672 2, /* size (0 = byte, 1 = short, 2 = long) */ 679 673 32, /* bitsize */ 680 false, /* pc_relative */674 FALSE, /* pc_relative */ 681 675 0, /* bitpos */ 682 676 complain_overflow_dont, /* complain_on_overflow */ 683 677 ppc_imglue_reloc, /* special_function */ 684 678 "IMGLUE", /* name */ 685 false, /* partial_inplace */679 FALSE, /* partial_inplace */ 686 680 0xffffffff, /* src_mask */ 687 681 0xffffffff, /* dst_mask */ 688 false), /* pcrel_offset */682 FALSE), /* pcrel_offset */ 689 683 690 684 /* IMAGE_REL_PPC_SECREL16 0x000F */ … … 695 689 1, /* size (0 = byte, 1 = short, 2 = long) */ 696 690 16, /* bitsize */ 697 false, /* pc_relative */691 FALSE, /* pc_relative */ 698 692 0, /* bitpos */ 699 693 complain_overflow_signed, /* complain_on_overflow */ 700 694 0, /* special_function */ 701 695 "SECREL16", /* name */ 702 true, /* partial_inplace */696 TRUE, /* partial_inplace */ 703 697 0xffff, /* src_mask */ 704 698 0xffff, /* dst_mask */ 705 true), /* pcrel_offset */699 TRUE), /* pcrel_offset */ 706 700 707 701 /* IMAGE_REL_PPC_REFHI 0x0010 */ … … 711 705 1, /* size (0 = byte, 1 = short, 2 = long) */ 712 706 16, /* bitsize */ 713 false, /* pc_relative */707 FALSE, /* pc_relative */ 714 708 0, /* bitpos */ 715 709 complain_overflow_signed, /* complain_on_overflow */ 716 710 ppc_refhi_reloc, /* special_function */ 717 711 "REFHI", /* name */ 718 true, /* partial_inplace */712 TRUE, /* partial_inplace */ 719 713 0xffffffff, /* src_mask */ 720 714 0xffffffff, /* dst_mask */ 721 false), /* pcrel_offset */715 FALSE), /* pcrel_offset */ 722 716 723 717 /* IMAGE_REL_PPC_REFLO 0x0011 */ … … 727 721 1, /* size (0 = byte, 1 = short, 2 = long) */ 728 722 16, /* bitsize */ 729 false, /* pc_relative */723 FALSE, /* pc_relative */ 730 724 0, /* bitpos */ 731 725 complain_overflow_signed, /* complain_on_overflow */ 732 726 ppc_refhi_reloc, /* special_function */ 733 727 "REFLO", /* name */ 734 true, /* partial_inplace */728 TRUE, /* partial_inplace */ 735 729 0xffffffff, /* src_mask */ 736 730 0xffffffff, /* dst_mask */ 737 false), /* pcrel_offset */731 FALSE), /* pcrel_offset */ 738 732 739 733 /* IMAGE_REL_PPC_PAIR 0x0012 */ … … 743 737 1, /* size (0 = byte, 1 = short, 2 = long) */ 744 738 16, /* bitsize */ 745 false, /* pc_relative */739 FALSE, /* pc_relative */ 746 740 0, /* bitpos */ 747 741 complain_overflow_signed, /* complain_on_overflow */ 748 742 ppc_pair_reloc, /* special_function */ 749 743 "PAIR", /* name */ 750 true, /* partial_inplace */744 TRUE, /* partial_inplace */ 751 745 0xffffffff, /* src_mask */ 752 746 0xffffffff, /* dst_mask */ 753 false), /* pcrel_offset */747 FALSE), /* pcrel_offset */ 754 748 755 749 /* IMAGE_REL_PPC_TOCREL16_DEFN 0x0013 */ … … 760 754 1, /* size (0 = byte, 1 = short, 2 = long) */ 761 755 16, /* bitsize */ 762 false, /* pc_relative */756 FALSE, /* pc_relative */ 763 757 0, /* bitpos */ 764 758 complain_overflow_dont, /* complain_on_overflow */ 765 759 0, /* special_function */ 766 760 "TOCREL16, TOCDEFN", /* name */ 767 false, /* partial_inplace */761 FALSE, /* partial_inplace */ 768 762 0xffff, /* src_mask */ 769 763 0xffff, /* dst_mask */ 770 false), /* pcrel_offset */764 FALSE), /* pcrel_offset */ 771 765 772 766 }; 773 767 774 768 775 /* Some really cheezy macros that can be turned on to test stderr :-) */769 /* Some really cheezy macros that can be turned on to test stderr :-) */ 776 770 777 771 #ifdef DEBUG_RELOC … … 798 792 #define n_name _n._n_name 799 793 #define n_zeroes _n._n_n._n_zeroes 800 #define n_offset _n._n_n._n_offset 801 802 */ 803 804 #define DUMP_RELOC2(n,r) \ 805 { \ 806 fprintf (stderr,"%s sym %d, r_vaddr %d %s\n", \ 807 n, r->r_symndx, r->r_vaddr,\ 794 #define n_offset _n._n_n._n_offset */ 795 796 #define DUMP_RELOC2(n,r) \ 797 { \ 798 fprintf (stderr,"%s sym %d, r_vaddr %d %s\n", \ 799 n, r->r_symndx, r->r_vaddr, \ 808 800 (((r->r_type) & IMAGE_REL_PPC_TOCDEFN) == 0) \ 809 ?" ":" TOCDEFN" ); \801 ?" ":" TOCDEFN" ); \ 810 802 } 811 803 … … 817 809 818 810 819 /* toc construction and management routines*/811 /* TOC construction and management routines. */ 820 812 821 813 /* This file is compiled twice, and these variables are defined in one 822 814 of the compilations. FIXME: This is confusing and weird. Also, 823 815 BFD should not use global variables. */ 824 extern bfd *bfd_of_toc_owner;816 extern bfd * bfd_of_toc_owner; 825 817 extern long int global_toc_size; 826 827 818 extern long int import_table_size; 828 819 extern long int first_thunk_address; … … 840 831 priv, 841 832 pub, 842 data833 tocdata 843 834 }; 844 835 … … 856 847 857 848 static void record_toc 858 PARAMS ((asection *, int, enum ref_category, const char *));849 PARAMS ((asection *, bfd_signed_vma, enum ref_category, const char *)); 859 850 860 851 static void 861 852 record_toc (toc_section, our_toc_offset, cat, name) 862 853 asection *toc_section; 863 intour_toc_offset;854 bfd_signed_vma our_toc_offset; 864 855 enum ref_category cat; 865 856 const char *name; 866 857 { 867 /* add this entry to our toc addr-offset-name list */ 868 struct list_ele *t; 869 t = (struct list_ele *) bfd_malloc (sizeof (struct list_ele)); 858 /* Add this entry to our toc addr-offset-name list. */ 859 bfd_size_type amt = sizeof (struct list_ele); 860 struct list_ele *t = (struct list_ele *) bfd_malloc (amt); 861 870 862 if (t == NULL) 871 863 abort (); … … 890 882 #ifdef COFF_IMAGE_WITH_PE 891 883 892 static b oolean ppc_record_toc_entry884 static bfd_boolean ppc_record_toc_entry 893 885 PARAMS ((bfd *, struct bfd_link_info *, asection *, int, enum toc_type)); 894 886 static void ppc_mark_symbol_as_glue 895 887 PARAMS ((bfd *, int, struct internal_reloc *)); 896 888 897 /* record a toc offset against a symbol*/898 static b oolean889 /* Record a toc offset against a symbol. */ 890 static bfd_boolean 899 891 ppc_record_toc_entry(abfd, info, sec, sym, toc_kind) 900 892 bfd *abfd; … … 920 912 { 921 913 local_syms = obj_coff_local_toc_table(abfd); 914 922 915 if (local_syms == 0) 923 916 { 924 917 unsigned int i; 918 bfd_size_type amt; 919 925 920 /* allocate a table */ 926 local_syms = 927 (int *) bfd_zalloc (abfd, 928 obj_raw_syment_count(abfd) * sizeof (int)); 921 amt = (bfd_size_type) obj_raw_syment_count (abfd) * sizeof (int); 922 local_syms = (int *) bfd_zalloc (abfd, amt); 929 923 if (local_syms == 0) 930 return false; 931 obj_coff_local_toc_table(abfd) = local_syms; 932 for (i = 0; i < obj_raw_syment_count(abfd); ++i) 924 return FALSE; 925 obj_coff_local_toc_table (abfd) = local_syms; 926 927 for (i = 0; i < obj_raw_syment_count (abfd); ++i) 933 928 { 934 SET_UNALLOCATED (local_syms[i]);929 SET_UNALLOCATED (local_syms[i]); 935 930 } 936 931 } … … 941 936 global_toc_size += 4; 942 937 943 /* The size must fit in a 16bit displacment */938 /* The size must fit in a 16bit displacment. */ 944 939 if (global_toc_size > 65535) 945 940 { 946 941 (*_bfd_error_handler) (_("TOC overflow")); 947 942 bfd_set_error (bfd_error_file_too_big); 948 return false;943 return FALSE; 949 944 } 950 945 } … … 954 949 name = h->root.root.root.string; 955 950 956 /* check to see if there's a toc slot allocated. If not, do it957 here. It will be used in relocate_section */951 /* Check to see if there's a toc slot allocated. If not, do it 952 here. It will be used in relocate_section. */ 958 953 if (IS_UNALLOCATED(h->toc_offset)) 959 954 { … … 961 956 global_toc_size += 4; 962 957 963 /* The size must fit in a 16bit displacment */958 /* The size must fit in a 16bit displacment. */ 964 959 if (global_toc_size >= 65535) 965 960 { 966 961 (*_bfd_error_handler) (_("TOC overflow")); 967 962 bfd_set_error (bfd_error_file_too_big); 968 return false;963 return FALSE; 969 964 } 970 965 } 971 966 } 972 967 973 return true;974 } 975 976 /* record a toc offset against a symbol*/968 return TRUE; 969 } 970 971 /* Record a toc offset against a symbol. */ 977 972 static void 978 973 ppc_mark_symbol_as_glue(abfd, sym, rel) … … 996 991 997 992 998 /* Return trueif this relocation should993 /* Return TRUE if this relocation should 999 994 appear in the output .reloc section. */ 1000 995 1001 static b oolean in_reloc_p(abfd, howto)996 static bfd_boolean in_reloc_p(abfd, howto) 1002 997 bfd * abfd ATTRIBUTE_UNUSED; 1003 998 reloc_howto_type *howto; … … 1020 1015 #if 0 1021 1016 1022 /* this function is in charge of performing all the ppc PE relocations */1023 /* Don't yet know if we want to do this this particular way ... (krk)*/1024 /* FIXME: (it is not yet enabled) */1017 /* This function is in charge of performing all the ppc PE relocations 1018 Don't yet know if we want to do this this particular way ... (krk). */ 1019 /* FIXME: (it is not yet enabled). */ 1025 1020 1026 1021 static bfd_reloc_status_type … … 1035 1030 char **error_message; 1036 1031 { 1037 /* the consth relocation comes in two parts, we have to remember1038 the state between calls, in these variables */1039 static b oolean part1_consth_active = false;1032 /* The consth relocation comes in two parts, we have to remember 1033 the state between calls, in these variables. */ 1034 static bfd_boolean part1_consth_active = FALSE; 1040 1035 static unsigned long part1_consth_value; 1041 1036 … … 1048 1043 if (output_bfd) 1049 1044 { 1050 /* Partial linking - do nothing */1045 /* Partial linking - do nothing. */ 1051 1046 reloc_entry->address += input_section->output_offset; 1052 1047 return bfd_reloc_ok; … … 1056 1051 && bfd_is_und_section (symbol_in->section)) 1057 1052 { 1058 /* Keep the state machine happy in case we're called again */1053 /* Keep the state machine happy in case we're called again. */ 1059 1054 if (r_type == IMAGE_REL_PPC_REFHI) 1060 1055 { 1061 part1_consth_active = true;1056 part1_consth_active = TRUE; 1062 1057 part1_consth_value = 0; 1063 1058 } … … 1067 1062 if ((part1_consth_active) && (r_type != IMAGE_REL_PPC_PAIR)) 1068 1063 { 1069 part1_consth_active = false;1064 part1_consth_active = FALSE; 1070 1065 *error_message = (char *) _("Missing PAIR"); 1071 1066 return(bfd_reloc_dangerous); … … 1081 1076 /* The reloc processing routine for the optimized COFF linker. */ 1082 1077 1083 static b oolean1078 static bfd_boolean 1084 1079 coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section, 1085 1080 contents, relocs, syms, sections) … … 1095 1090 struct internal_reloc *rel; 1096 1091 struct internal_reloc *relend; 1097 b oolean hihalf;1092 bfd_boolean hihalf; 1098 1093 bfd_vma hihalf_val; 1099 1094 asection *toc_section = 0; … … 1105 1100 addresses and symbol indices. */ 1106 1101 if (info->relocateable) 1107 return true;1108 1109 hihalf = false;1102 return TRUE; 1103 1104 hihalf = FALSE; 1110 1105 hihalf_val = 0; 1111 1106 … … 1158 1153 val = 0; 1159 1154 1160 /* FIXME: PAIR unsupported in the following code */1155 /* FIXME: PAIR unsupported in the following code. */ 1161 1156 if (h == NULL) 1162 1157 { … … 1189 1184 if (! ((*info->callbacks->undefined_symbol) 1190 1185 (info, h->root.root.root.string, input_bfd, input_section, 1191 rel->r_vaddr - input_section->vma, true)))1192 return false;1186 rel->r_vaddr - input_section->vma, TRUE))) 1187 return FALSE; 1193 1188 } 1194 1189 } … … 1196 1191 rstat = bfd_reloc_ok; 1197 1192 1198 /* Each case must do its own relocation, setting rstat appropriately */1193 /* Each case must do its own relocation, setting rstat appropriately. */ 1199 1194 switch (r_type) 1200 1195 { … … 1202 1197 (*_bfd_error_handler) 1203 1198 (_("%s: unsupported relocation type 0x%02x"), 1204 bfd_ get_filename (input_bfd), r_type);1199 bfd_archive_filename (input_bfd), r_type); 1205 1200 bfd_set_error (bfd_error_bad_value); 1206 return false;1201 return FALSE; 1207 1202 case IMAGE_REL_PPC_TOCREL16: 1208 1203 { 1209 bfd_ vma our_toc_offset;1204 bfd_signed_vma our_toc_offset; 1210 1205 int fixit; 1211 1206 … … 1224 1219 } 1225 1220 1226 /* 1227 * Amazing bit tricks present. As we may have seen earlier, we 1228 * use the 1 bit to tell us whether or not a toc offset has been 1229 * allocated. Now that they've all been allocated, we will use 1230 * the 1 bit to tell us if we've written this particular toc 1231 * entry out. 1232 */ 1233 fixit = false; 1221 /* Amazing bit tricks present. As we may have seen earlier, we 1222 use the 1 bit to tell us whether or not a toc offset has been 1223 allocated. Now that they've all been allocated, we will use 1224 the 1 bit to tell us if we've written this particular toc 1225 entry out. */ 1226 fixit = FALSE; 1234 1227 if (h == 0) 1235 { /* it is a file local symbol */ 1228 { 1229 /* It is a file local symbol. */ 1236 1230 int *local_toc_table; 1237 1231 const char *name; … … 1245 1239 if (IS_WRITTEN(our_toc_offset)) 1246 1240 { 1247 /* if it has been written out, it is marked with the1241 /* If it has been written out, it is marked with the 1248 1242 1 bit. Fix up our offset, but do not write it out 1249 again. 1250 */ 1243 again. */ 1251 1244 MAKE_ADDR_AGAIN(our_toc_offset); 1252 1245 } 1253 1246 else 1254 1247 { 1255 /* write out the toc entry */ 1256 record_toc(toc_section, 1257 our_toc_offset, 1258 priv, 1259 strdup(name)); 1260 1261 bfd_put_32 (output_bfd, 1262 val, 1248 /* Write out the toc entry. */ 1249 record_toc (toc_section, our_toc_offset, priv, 1250 strdup (name)); 1251 1252 bfd_put_32 (output_bfd, val, 1263 1253 toc_section->contents + our_toc_offset); 1264 1254 1265 1255 MARK_AS_WRITTEN(local_toc_table[symndx]); 1266 fixit = true;1256 fixit = TRUE; 1267 1257 } 1268 1258 } … … 1287 1277 the toc, some trippy library code trying for speed on 1288 1278 dll linkage, takes advantage of that and considers 1289 the IAT to be part of the toc, thus saving a load. 1290 */ 1291 1292 our_toc_offset = val - 1293 (toc_section->output_section->vma + 1294 toc_section->output_offset); 1295 1296 /* The size must still fit in a 16bit displacment */ 1297 if (our_toc_offset >= 65535) 1279 the IAT to be part of the toc, thus saving a load. */ 1280 1281 our_toc_offset = val - (toc_section->output_section->vma 1282 + toc_section->output_offset); 1283 1284 /* The size must still fit in a 16bit displacment. */ 1285 if ((bfd_vma) our_toc_offset >= 65535) 1298 1286 { 1299 1287 (*_bfd_error_handler) 1300 (_("%s: Relocation for %s of %x exceeds Toc size limit"), 1301 bfd_get_filename (input_bfd), name, our_toc_offset); 1288 (_("%s: Relocation for %s of %lx exceeds Toc size limit"), 1289 bfd_archive_filename (input_bfd), name, 1290 (unsigned long) our_toc_offset); 1302 1291 bfd_set_error (bfd_error_bad_value); 1303 return false;1292 return FALSE; 1304 1293 } 1305 1294 1306 record_toc(toc_section, our_toc_offset, pub, strdup(name)); 1295 record_toc (toc_section, our_toc_offset, pub, 1296 strdup (name)); 1307 1297 } 1308 else if (IS_WRITTEN (our_toc_offset))1298 else if (IS_WRITTEN (our_toc_offset)) 1309 1299 { 1310 /* if it has been written out, it is marked with the1300 /* If it has been written out, it is marked with the 1311 1301 1 bit. Fix up our offset, but do not write it out 1312 again. 1313 */ 1302 again. */ 1314 1303 MAKE_ADDR_AGAIN(our_toc_offset); 1315 1304 } 1316 1305 else 1317 1306 { 1318 record_toc(toc_section, our_toc_offset, pub, strdup(name));1319 1320 /* write out the toc entry */ 1321 bfd_put_32 (output_bfd,1322 1307 record_toc(toc_section, our_toc_offset, pub, 1308 strdup (name)); 1309 1310 /* Write out the toc entry. */ 1311 bfd_put_32 (output_bfd, val, 1323 1312 toc_section->contents + our_toc_offset); 1324 1313 1325 1314 MARK_AS_WRITTEN(h->toc_offset); 1326 /* The tricky part is that this is the address that */1327 /* needs a .reloc entry for it*/1328 fixit = true;1315 /* The tricky part is that this is the address that 1316 needs a .reloc entry for it. */ 1317 fixit = TRUE; 1329 1318 } 1330 1319 } … … 1333 1322 { 1334 1323 /* So if this is non pcrelative, and is referenced 1335 to a section or a common symbol, then it needs a reloc */1336 1337 /* relocation to a symbol in a section which1324 to a section or a common symbol, then it needs a reloc. */ 1325 1326 /* Relocation to a symbol in a section which 1338 1327 isn't absolute - we output the address here 1339 to a file */ 1340 1341 bfd_vma addr = toc_section->output_section->vma 1342 + toc_section->output_offset + our_toc_offset; 1343 1344 if (coff_data(output_bfd)->pe) 1328 to a file. */ 1329 bfd_vma addr = (toc_section->output_section->vma 1330 + toc_section->output_offset + our_toc_offset); 1331 1332 if (coff_data (output_bfd)->pe) 1345 1333 addr -= pe_data(output_bfd)->pe_opthdr.ImageBase; 1346 1334 … … 1348 1336 } 1349 1337 1350 /* FIXME: this test is conservative */1351 if ( (r_flags & IMAGE_REL_PPC_TOCDEFN) != IMAGE_REL_PPC_TOCDEFN &&1352 our_toc_offset > toc_section->_raw_size)1338 /* FIXME: this test is conservative. */ 1339 if ((r_flags & IMAGE_REL_PPC_TOCDEFN) != IMAGE_REL_PPC_TOCDEFN 1340 && (bfd_vma) our_toc_offset > toc_section->_raw_size) 1353 1341 { 1354 1342 (*_bfd_error_handler) 1355 (_("%s: Relocation exceeds allocated TOC (% x)"),1356 bfd_ get_filename (input_bfd),1357 toc_section->_raw_size);1343 (_("%s: Relocation exceeds allocated TOC (%lx)"), 1344 bfd_archive_filename (input_bfd), 1345 (unsigned long) toc_section->_raw_size); 1358 1346 bfd_set_error (bfd_error_bad_value); 1359 return false;1347 return FALSE; 1360 1348 } 1361 1349 1362 /* Now we know the relocation for this toc reference */1350 /* Now we know the relocation for this toc reference. */ 1363 1351 relocation = our_toc_offset + TOC_LOAD_ADJUSTMENT; 1364 rstat = _bfd_relocate_contents (howto, 1365 input_bfd, 1366 relocation, 1367 loc); 1352 rstat = _bfd_relocate_contents (howto, input_bfd, relocation, loc); 1368 1353 } 1369 1354 break; 1370 1355 case IMAGE_REL_PPC_IFGLUE: 1371 1356 { 1372 /* To solve this, we need to know whether or not the symbol */ 1373 /* appearing on the call instruction is a glue function or not. */ 1374 /* A glue function must announce itself via a IMGLUE reloc, and */ 1375 /* the reloc contains the required toc restore instruction */ 1376 1357 /* To solve this, we need to know whether or not the symbol 1358 appearing on the call instruction is a glue function or not. 1359 A glue function must announce itself via a IMGLUE reloc, and 1360 the reloc contains the required toc restore instruction. */ 1377 1361 bfd_vma x; 1378 1362 const char *my_name; 1379 DUMP_RELOC2(howto->name, rel); 1363 1364 DUMP_RELOC2 (howto->name, rel); 1380 1365 1381 1366 if (h != 0) … … 1385 1370 { 1386 1371 x = bfd_get_32 (input_bfd, loc); 1387 bfd_put_32 (input_bfd, h->glue_insn, loc);1372 bfd_put_32 (input_bfd, (bfd_vma) h->glue_insn, loc); 1388 1373 } 1389 1374 } … … 1391 1376 break; 1392 1377 case IMAGE_REL_PPC_SECREL: 1393 /* Unimplemented: codeview debugging information */1378 /* Unimplemented: codeview debugging information. */ 1394 1379 /* For fast access to the header of the section 1395 1380 containing the item. */ 1396 1381 break; 1397 1382 case IMAGE_REL_PPC_SECTION: 1398 /* Unimplemented: codeview debugging information */1383 /* Unimplemented: codeview debugging information. */ 1399 1384 /* Is used to indicate that the value should be relative 1400 1385 to the beginning of the section that contains the 1401 symbol */1386 symbol. */ 1402 1387 break; 1403 1388 case IMAGE_REL_PPC_ABSOLUTE: 1404 1389 { 1405 1390 const char *my_name; 1391 1406 1392 if (h == 0) 1407 1393 my_name = (syms+symndx)->_n._n_name; 1408 1394 else 1409 { 1410 my_name = h->root.root.root.string; 1411 } 1395 my_name = h->root.root.root.string; 1412 1396 1413 1397 fprintf (stderr, 1414 1398 _("Warning: unsupported reloc %s <file %s, section %s>\n"), 1415 1399 howto->name, 1416 bfd_ get_filename(input_bfd),1400 bfd_archive_filename(input_bfd), 1417 1401 input_section->name); 1418 1402 … … 1425 1409 { 1426 1410 /* There is nothing to do now. This reloc was noted in the first 1427 pass over the relocs, and the glue instruction extracted */1411 pass over the relocs, and the glue instruction extracted. */ 1428 1412 const char *my_name; 1413 1429 1414 if (h->symbol_is_glue == 1) 1430 1415 break; … … 1433 1418 (*_bfd_error_handler) 1434 1419 (_("%s: Out of order IMGLUE reloc for %s"), 1435 bfd_ get_filename (input_bfd), my_name);1420 bfd_archive_filename (input_bfd), my_name); 1436 1421 bfd_set_error (bfd_error_bad_value); 1437 return false;1422 return FALSE; 1438 1423 } 1439 1424 1440 1425 case IMAGE_REL_PPC_ADDR32NB: 1441 1426 { 1442 struct coff_link_hash_entry *myh = 0;1443 1427 const char *name = 0; 1444 DUMP_RELOC2(howto->name, rel); 1428 1429 DUMP_RELOC2 (howto->name, rel); 1445 1430 1446 1431 if (strncmp(".idata$2",input_section->name,8) == 0 && first_thunk_address == 0) 1447 1432 { 1448 /* set magic values*/1433 /* Set magic values. */ 1449 1434 int idata5offset; 1450 struct coff_link_hash_entry *myh = 0; 1435 struct coff_link_hash_entry *myh; 1436 1451 1437 myh = coff_link_hash_lookup (coff_hash_table (info), 1452 1438 "__idata5_magic__", 1453 false, false, true);1439 FALSE, FALSE, TRUE); 1454 1440 first_thunk_address = myh->root.u.def.value + 1455 1441 sec->output_section->vma + … … 1460 1446 myh = coff_link_hash_lookup (coff_hash_table (info), 1461 1447 "__idata6_magic__", 1462 false, false, true);1448 FALSE, FALSE, TRUE); 1463 1449 1464 1450 thunk_size = myh->root.u.def.value - idata5offset; 1465 1451 myh = coff_link_hash_lookup (coff_hash_table (info), 1466 1452 "__idata4_magic__", 1467 false, false, true);1453 FALSE, FALSE, TRUE); 1468 1454 import_table_size = myh->root.u.def.value; 1469 1455 } 1470 1456 1471 1457 if (h == 0) 1472 { /* it is a file local symbol */ 1458 { 1459 /* It is a file local symbol. */ 1473 1460 sym = syms + symndx; 1474 1461 name = sym->_n._n_name; … … 1479 1466 1480 1467 name = h->root.root.root.string; 1481 if (strcmp (".idata$2", name) == 0)1468 if (strcmp (".idata$2", name) == 0) 1482 1469 target = "__idata2_magic__"; 1483 else if (strcmp (".idata$4", name) == 0)1470 else if (strcmp (".idata$4", name) == 0) 1484 1471 target = "__idata4_magic__"; 1485 else if (strcmp (".idata$5", name) == 0)1472 else if (strcmp (".idata$5", name) == 0) 1486 1473 target = "__idata5_magic__"; 1487 1474 1488 1475 if (target != 0) 1489 1476 { 1490 myh = 0;1477 struct coff_link_hash_entry *myh; 1491 1478 1492 1479 myh = coff_link_hash_lookup (coff_hash_table (info), 1493 1480 target, 1494 false, false, true);1481 FALSE, FALSE, TRUE); 1495 1482 if (myh == 0) 1496 1483 { … … 1506 1493 myh = coff_link_hash_lookup (coff_hash_table (info), 1507 1494 "__idata5_magic__", 1508 false, false, true);1495 FALSE, FALSE, TRUE); 1509 1496 first_thunk_address = myh->root.u.def.value + 1510 1497 sec->output_section->vma + … … 1515 1502 myh = coff_link_hash_lookup (coff_hash_table (info), 1516 1503 "__idata6_magic__", 1517 false, false, true);1504 FALSE, FALSE, TRUE); 1518 1505 1519 1506 thunk_size = myh->root.u.def.value - idata5offset; 1520 1507 myh = coff_link_hash_lookup (coff_hash_table (info), 1521 1508 "__idata4_magic__", 1522 false, false, true);1509 FALSE, FALSE, TRUE); 1523 1510 import_table_size = myh->root.u.def.value; 1524 1511 } … … 1527 1514 1528 1515 rstat = _bfd_relocate_contents (howto, 1529 1530 1531 pe_data(output_bfd)->pe_opthdr.ImageBase,1532 1516 input_bfd, 1517 val - 1518 pe_data (output_bfd)->pe_opthdr.ImageBase, 1519 loc); 1533 1520 } 1534 1521 break; … … 1555 1542 } 1556 1543 1557 if ( info->base_file)1544 if (info->base_file) 1558 1545 { 1559 1546 /* So if this is non pcrelative, and is referenced 1560 to a section or a common symbol, then it needs a reloc */1561 if (sym && pe_data(output_bfd)->in_reloc_p (output_bfd, howto))1547 to a section or a common symbol, then it needs a reloc. */ 1548 if (sym && pe_data(output_bfd)->in_reloc_p (output_bfd, howto)) 1562 1549 { 1563 /* relocation to a symbol in a section which1550 /* Relocation to a symbol in a section which 1564 1551 isn't absolute - we output the address here 1565 to a file */1552 to a file. */ 1566 1553 bfd_vma addr = rel->r_vaddr 1567 1554 - input_section->vma … … 1569 1556 + input_section->output_section->vma; 1570 1557 1571 if (coff_data(output_bfd)->pe) 1572 { 1573 addr -= pe_data(output_bfd)->pe_opthdr.ImageBase; 1574 } 1558 if (coff_data (output_bfd)->pe) 1559 addr -= pe_data (output_bfd)->pe_opthdr.ImageBase; 1560 1575 1561 fwrite (&addr, 1,4, (FILE *) info->base_file); 1576 1562 } … … 1608 1594 (bfd_vma) 0, input_bfd, 1609 1595 input_section, rel->r_vaddr - input_section->vma))) 1610 { 1611 return false; 1612 } 1596 return FALSE; 1613 1597 } 1614 1598 } 1615 1616 } 1617 1618 return true; 1599 } 1600 1601 return TRUE; 1619 1602 } 1620 1603 … … 1662 1645 else if (t->cat == pub) 1663 1646 cat = _("public "); 1664 else if (t->cat == data)1647 else if (t->cat == tocdata) 1665 1648 cat = _("data-in-toc "); 1666 1649 … … 1673 1656 fprintf (file, 1674 1657 _("**** global_toc_size %ld(%lx), thunk_size %ld(%lx)\n"), 1675 global_toc_size, global_toc_size, thunk_size, thunk_size); 1658 global_toc_size, global_toc_size, 1659 thunk_size, thunk_size); 1676 1660 cat = _("Out of bounds!"); 1677 1661 } … … 1689 1673 } 1690 1674 1691 b oolean1675 bfd_boolean 1692 1676 ppc_allocate_toc_section (info) 1693 1677 struct bfd_link_info *info ATTRIBUTE_UNUSED; … … 1695 1679 asection *s; 1696 1680 bfd_byte *foo; 1681 bfd_size_type amt; 1697 1682 static char test_char = '1'; 1698 1683 1699 if ( global_toc_size == 0 ) /* FIXME: does this get me in trouble? */1700 return true;1684 if ( global_toc_size == 0 ) /* FIXME: does this get me in trouble? */ 1685 return TRUE; 1701 1686 1702 1687 if (bfd_of_toc_owner == 0) 1703 { 1704 /* No toc owner? Something is very wrong. */ 1705 abort (); 1706 } 1688 /* No toc owner? Something is very wrong. */ 1689 abort (); 1707 1690 1708 1691 s = bfd_get_section_by_name ( bfd_of_toc_owner , TOC_SECTION_NAME); 1709 1692 if (s == NULL) 1710 { 1711 /* No toc section? Something is very wrong. */ 1712 abort (); 1713 } 1714 1715 foo = (bfd_byte *) bfd_alloc(bfd_of_toc_owner, global_toc_size); 1716 memset(foo, test_char, global_toc_size); 1693 /* No toc section? Something is very wrong. */ 1694 abort (); 1695 1696 amt = global_toc_size; 1697 foo = (bfd_byte *) bfd_alloc (bfd_of_toc_owner, amt); 1698 memset(foo, test_char, (size_t) global_toc_size); 1717 1699 1718 1700 s->_raw_size = s->_cooked_size = global_toc_size; 1719 1701 s->contents = foo; 1720 1702 1721 return true;1722 } 1723 1724 b oolean1703 return TRUE; 1704 } 1705 1706 bfd_boolean 1725 1707 ppc_process_before_allocation (abfd, info) 1726 1708 bfd *abfd; … … 1730 1712 struct internal_reloc *i, *rel; 1731 1713 1732 /* here we have a bfd that is to be included on the link. We have a hook1714 /* Here we have a bfd that is to be included on the link. We have a hook 1733 1715 to do reloc rummaging, before section sizes are nailed down. */ 1734 1735 _bfd_coff_get_external_symbols(abfd); 1736 1737 /* rummage around all the relocs and map the toc */ 1716 _bfd_coff_get_external_symbols (abfd); 1717 1718 /* Rummage around all the relocs and map the toc. */ 1738 1719 sec = abfd->sections; 1739 1720 1740 1721 if (sec == 0) 1741 { 1742 return true; 1743 } 1722 return TRUE; 1744 1723 1745 1724 for (; sec != 0; sec = sec->next) 1746 {1747 if (sec->reloc_count == 0)1748 1749 1750 /* load the relocs */1751 /* FIXME: there may be a storage leak here */1752 i=_bfd_coff_read_internal_relocs(abfd,sec,1,0,0,0);1753 1754 if (i == 0)1755 1756 1757 for (rel=i;rel<i+sec->reloc_count;++rel)1758 1759 unsigned short r_type = EXTRACT_TYPE(rel->r_type);1760 unsigned short r_flags = EXTRACT_FLAGS(rel->r_type);1761 boolean ok = true;1762 1763 DUMP_RELOC2(ppc_coff_howto_table[r_type].name, rel);1764 1765 switch(r_type)1766 {1767 case IMAGE_REL_PPC_TOCREL16:1768 /* if TOCDEFN is on, ignore as someone else has allocated the1769 toc entry*/1770 if ( (r_flags & IMAGE_REL_PPC_TOCDEFN) != IMAGE_REL_PPC_TOCDEFN)1771 1772 rel->r_symndx, default_toc);1773 if (!ok)1774 return false;1775 break;1776 case IMAGE_REL_PPC_IMGLUE:1777 ppc_mark_symbol_as_glue(abfd, rel->r_symndx, rel);1778 break;1779 default:1780 break;1781 }1782 1783 }1784 1785 return true;1725 { 1726 if (sec->reloc_count == 0) 1727 continue; 1728 1729 /* load the relocs */ 1730 /* FIXME: there may be a storage leak here */ 1731 i=_bfd_coff_read_internal_relocs(abfd,sec,1,0,0,0); 1732 1733 if (i == 0) 1734 abort (); 1735 1736 for (rel = i; rel < i + sec->reloc_count; ++rel) 1737 { 1738 unsigned short r_type = EXTRACT_TYPE (rel->r_type); 1739 unsigned short r_flags = EXTRACT_FLAGS (rel->r_type); 1740 bfd_boolean ok = TRUE; 1741 1742 DUMP_RELOC2 (ppc_coff_howto_table[r_type].name, rel); 1743 1744 switch(r_type) 1745 { 1746 case IMAGE_REL_PPC_TOCREL16: 1747 /* If TOCDEFN is on, ignore as someone else has allocated the 1748 toc entry. */ 1749 if ((r_flags & IMAGE_REL_PPC_TOCDEFN) != IMAGE_REL_PPC_TOCDEFN) 1750 ok = ppc_record_toc_entry(abfd, info, sec, 1751 rel->r_symndx, default_toc); 1752 if (!ok) 1753 return FALSE; 1754 break; 1755 case IMAGE_REL_PPC_IMGLUE: 1756 ppc_mark_symbol_as_glue (abfd, rel->r_symndx, rel); 1757 break; 1758 default: 1759 break; 1760 } 1761 } 1762 } 1763 1764 return TRUE; 1786 1765 } 1787 1766 … … 1789 1768 1790 1769 static bfd_reloc_status_type 1791 ppc_refhi_reloc (abfd, 1792 reloc_entry, 1793 symbol, 1794 data, 1795 input_section, 1796 output_bfd, 1797 error_message) 1770 ppc_refhi_reloc (abfd, reloc_entry, symbol, data, 1771 input_section, output_bfd, error_message) 1798 1772 bfd *abfd ATTRIBUTE_UNUSED; 1799 1773 arelent *reloc_entry ATTRIBUTE_UNUSED; … … 1816 1790 1817 1791 static bfd_reloc_status_type 1818 ppc_reflo_reloc (abfd, 1819 reloc_entry, 1820 symbol, 1821 data, 1822 input_section, 1823 output_bfd, 1824 error_message) 1792 ppc_reflo_reloc (abfd, reloc_entry, symbol, data, 1793 input_section, output_bfd, error_message) 1825 1794 bfd *abfd; 1826 1795 arelent *reloc_entry; … … 1843 1812 1844 1813 static bfd_reloc_status_type 1845 ppc_pair_reloc (abfd, 1846 reloc_entry, 1847 symbol, 1848 data, 1849 input_section, 1850 output_bfd, 1851 error_message) 1814 ppc_pair_reloc (abfd, reloc_entry, symbol, data, 1815 input_section, output_bfd, error_message) 1852 1816 bfd *abfd ATTRIBUTE_UNUSED; 1853 1817 arelent *reloc_entry ATTRIBUTE_UNUSED; … … 1869 1833 1870 1834 static bfd_reloc_status_type 1871 ppc_toc16_reloc (abfd, 1872 reloc_entry, 1873 symbol, 1874 data, 1875 input_section, 1876 output_bfd, 1877 error_message) 1835 ppc_toc16_reloc (abfd, reloc_entry, symbol, data, 1836 input_section, output_bfd, error_message) 1878 1837 bfd *abfd ATTRIBUTE_UNUSED; 1879 1838 arelent *reloc_entry ATTRIBUTE_UNUSED; … … 1884 1843 char **error_message ATTRIBUTE_UNUSED; 1885 1844 { 1886 UN_IMPL ("TOCREL16");1887 DUMP_RELOC ("TOCREL16",reloc_entry);1845 UN_IMPL ("TOCREL16"); 1846 DUMP_RELOC ("TOCREL16",reloc_entry); 1888 1847 1889 1848 if (output_bfd == (bfd *) NULL) 1890 { 1891 return bfd_reloc_continue; 1892 } 1849 return bfd_reloc_continue; 1893 1850 1894 1851 return bfd_reloc_ok; … … 1897 1854 #if 0 1898 1855 1899 /* ADDR32NB : 32 bit address relative to the virtual origin. */ 1900 /* (On the alpha, this is always a linker generated thunk)*/ 1901 /* (i.e. 32bit addr relative to the image base) */ 1902 /* */ 1903 /* */ 1856 /* ADDR32NB : 32 bit address relative to the virtual origin. 1857 (On the alpha, this is always a linker generated thunk) 1858 (i.e. 32bit addr relative to the image base). */ 1904 1859 1905 1860 static bfd_reloc_status_type 1906 ppc_addr32nb_reloc (abfd, 1907 reloc_entry, 1908 symbol, 1909 data, 1910 input_section, 1911 output_bfd, 1912 error_message) 1861 ppc_addr32nb_reloc (abfd, reloc_entry, symbol, data, 1862 input_section, output_bfd, error_message) 1913 1863 bfd *abfd; 1914 1864 arelent *reloc_entry; … … 1928 1878 1929 1879 static bfd_reloc_status_type 1930 ppc_secrel_reloc (abfd, 1931 reloc_entry, 1932 symbol, 1933 data, 1934 input_section, 1935 output_bfd, 1936 error_message) 1880 ppc_secrel_reloc (abfd, reloc_entry, symbol, data, 1881 input_section, output_bfd, error_message) 1937 1882 bfd *abfd ATTRIBUTE_UNUSED; 1938 1883 arelent *reloc_entry ATTRIBUTE_UNUSED; … … 1953 1898 1954 1899 static bfd_reloc_status_type 1955 ppc_section_reloc (abfd, 1956 reloc_entry, 1957 symbol, 1958 data, 1959 input_section, 1960 output_bfd, 1961 error_message) 1900 ppc_section_reloc (abfd, reloc_entry, symbol, data, 1901 input_section, output_bfd, error_message) 1962 1902 bfd *abfd ATTRIBUTE_UNUSED; 1963 1903 arelent *reloc_entry ATTRIBUTE_UNUSED; … … 1978 1918 1979 1919 static bfd_reloc_status_type 1980 ppc_imglue_reloc (abfd, 1981 reloc_entry, 1982 symbol, 1983 data, 1984 input_section, 1985 output_bfd, 1986 error_message) 1920 ppc_imglue_reloc (abfd, reloc_entry, symbol, data, 1921 input_section, output_bfd, error_message) 1987 1922 bfd *abfd ATTRIBUTE_UNUSED; 1988 1923 arelent *reloc_entry ATTRIBUTE_UNUSED; … … 2008 1943 /* FIXME: There is a possiblity that when we read in a reloc from a file, 2009 1944 that there are some bits encoded in the upper portion of the 2010 type field. Not yet implemented. 2011 */ 2012 static void ppc_coff_rtype2howto PARAMS ((arelent *relent, 2013 struct internal_reloc *internal)); 1945 type field. Not yet implemented. */ 1946 static void ppc_coff_rtype2howto PARAMS ((arelent *, struct internal_reloc *)); 2014 1947 2015 1948 static void … … 2018 1951 struct internal_reloc *internal; 2019 1952 { 2020 2021 1953 /* We can encode one of three things in the type field, aside from the 2022 1954 type: … … 2027 1959 3. IMAGE_REL_PPC_TOCDEFN - toc slot definition in the file 2028 1960 For now, we just strip this stuff to find the type, and ignore it other 2029 than that. 2030 */ 1961 than that. */ 2031 1962 reloc_howto_type *howto; 2032 1963 unsigned short r_type = EXTRACT_TYPE (internal->r_type); … … 2034 1965 unsigned short junk = EXTRACT_JUNK (internal->r_type); 2035 1966 2036 /* the masking process only slices off the bottom byte for r_type. */1967 /* The masking process only slices off the bottom byte for r_type. */ 2037 1968 if ( r_type > MAX_RELOC_INDEX ) 2038 1969 abort (); 2039 1970 2040 /* check for absolute crap*/2041 if ( junk != 0)1971 /* Check for absolute crap. */ 1972 if (junk != 0) 2042 1973 abort (); 2043 1974 … … 2052 1983 case IMAGE_REL_PPC_SECTION: 2053 1984 case IMAGE_REL_PPC_SECREL: 2054 DUMP_RELOC2 (ppc_coff_howto_table[r_type].name, internal);1985 DUMP_RELOC2 (ppc_coff_howto_table[r_type].name, internal); 2055 1986 howto = ppc_coff_howto_table + r_type; 2056 1987 break; 2057 1988 case IMAGE_REL_PPC_IMGLUE: 2058 DUMP_RELOC2 (ppc_coff_howto_table[r_type].name, internal);1989 DUMP_RELOC2 (ppc_coff_howto_table[r_type].name, internal); 2059 1990 howto = ppc_coff_howto_table + r_type; 2060 1991 break; 2061 1992 case IMAGE_REL_PPC_TOCREL16: 2062 DUMP_RELOC2 (ppc_coff_howto_table[r_type].name, internal);1993 DUMP_RELOC2 (ppc_coff_howto_table[r_type].name, internal); 2063 1994 if (r_flags & IMAGE_REL_PPC_TOCDEFN) 2064 1995 howto = ppc_coff_howto_table + IMAGE_REL_PPC_TOCREL16_DEFN; … … 2076 2007 2077 2008 relent->howto = howto; 2078 2079 2009 } 2080 2010 … … 2098 2028 3. IMAGE_REL_PPC_TOCDEFN - toc slot definition in the file 2099 2029 For now, we just strip this stuff to find the type, and ignore it other 2100 than that. 2101 */ 2102 2103 unsigned short r_type = EXTRACT_TYPE (rel->r_type); 2104 unsigned short r_flags = EXTRACT_FLAGS(rel->r_type); 2105 unsigned short junk = EXTRACT_JUNK (rel->r_type); 2106 2107 /* the masking process only slices off the bottom byte for r_type. */ 2108 if ( r_type > MAX_RELOC_INDEX ) 2030 than that. */ 2031 2032 unsigned short r_type = EXTRACT_TYPE (rel->r_type); 2033 unsigned short r_flags = EXTRACT_FLAGS (rel->r_type); 2034 unsigned short junk = EXTRACT_JUNK (rel->r_type); 2035 2036 /* The masking process only slices off the bottom byte for r_type. */ 2037 if (r_type > MAX_RELOC_INDEX) 2109 2038 abort (); 2110 2039 2111 /* check for absolute crap*/2112 if ( junk != 0)2040 /* Check for absolute crap. */ 2041 if (junk != 0) 2113 2042 abort (); 2114 2043 … … 2153 2082 } 2154 2083 2155 /* a cheesy little macro to make the code a little more readable*/2084 /* A cheesy little macro to make the code a little more readable. */ 2156 2085 #define HOW2MAP(bfd_rtype,ppc_rtype) \ 2157 2086 case bfd_rtype: return &ppc_coff_howto_table[ppc_rtype] … … 2179 2108 return NULL; 2180 2109 } 2181 /*NOTREACHED*/2182 2110 } 2183 2111 … … 2188 2116 2189 2117 #define RTYPE2HOWTO(cache_ptr, dst) ppc_coff_rtype2howto (cache_ptr, dst) 2190 2191 #ifndef COFF_IMAGE_WITH_PE2192 static void ppc_coff_swap_sym_in_hook PARAMS ((bfd *, PTR, PTR));2193 #endif2194 2118 2195 2119 /* We use the special COFF backend linker, with our own special touch. */ … … 2202 2126 #ifndef COFF_IMAGE_WITH_PE 2203 2127 /* FIXME: This no longer works. */ 2128 #if 0 2204 2129 #define coff_swap_sym_in_hook ppc_coff_swap_sym_in_hook 2130 #endif 2205 2131 #endif 2206 2132 … … 2232 2158 2233 2159 #ifndef COFF_IMAGE_WITH_PE 2160 /* FIXME: This no longer works. */ 2161 #if 0 2234 2162 /* FIXME: 2235 2163 What we're trying to do here is allocate a toc section (early), and attach … … 2243 2171 that you are the last bfd closed. 2244 2172 3. Doing it on a "swap in" hook depends on when the "swap in" is called, 2245 and how often, etc. It's not clear to me that there isn't a hole here. 2246 */ 2173 and how often, etc. It's not clear to me that there isn't a hole here. */ 2174 static void ppc_coff_swap_sym_in_hook PARAMS ((bfd *, PTR, PTR)); 2247 2175 2248 2176 static void … … 2252 2180 PTR in1; 2253 2181 { 2254 struct internal_syment *in = (struct internal_syment *)in1;2255 2256 if (bfd_of_toc_owner != 0) /* we already have a toc, so go home*/2182 struct internal_syment * in = (struct internal_syment *)in1; 2183 2184 if (bfd_of_toc_owner != 0) /* We already have a toc, so go home. */ 2257 2185 return; 2258 2186 2259 if (strcmp (in->_n._n_name, ".toc") == 0)2187 if (strcmp (in->_n._n_name, ".toc") == 0) 2260 2188 { 2261 2189 flagword flags; 2262 2190 register asection *s; 2263 2191 2264 s = bfd_get_section_by_name ( abfd, TOC_SECTION_NAME);2192 s = bfd_get_section_by_name (abfd, TOC_SECTION_NAME); 2265 2193 if (s != NULL) 2266 { 2267 return; 2268 } 2194 return; 2269 2195 2270 2196 flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY ; … … 2275 2201 || !bfd_set_section_flags (abfd, s, flags) 2276 2202 || !bfd_set_section_alignment (abfd, s, 2)) 2277 { 2278 /* FIXME: set appropriate bfd error */ 2279 abort (); 2280 } 2281 2282 /* save the bfd for later allocation */ 2203 /* FIXME: set appropriate bfd error. */ 2204 abort (); 2205 2206 /* Save the bfd for later allocation. */ 2283 2207 bfd_of_toc_owner = abfd; 2284 2208 } … … 2287 2211 } 2288 2212 #endif 2213 #endif 2289 2214 2290 2215 #ifndef COFF_IMAGE_WITH_PE 2291 2216 2292 static b oolean ppc_do_last PARAMS ((bfd *));2217 static bfd_boolean ppc_do_last PARAMS ((bfd *)); 2293 2218 static bfd *ppc_get_last PARAMS ((void)); 2294 2219 2295 static b oolean2220 static bfd_boolean 2296 2221 ppc_do_last (abfd) 2297 2222 bfd *abfd; 2298 2223 { 2299 2224 if (abfd == bfd_of_toc_owner) 2300 return true;2225 return TRUE; 2301 2226 else 2302 return false;2227 return FALSE; 2303 2228 } 2304 2229 … … 2309 2234 } 2310 2235 2311 /* this piece of machinery exists only to guarantee that the bfd that holds2236 /* This piece of machinery exists only to guarantee that the bfd that holds 2312 2237 the toc section is written last. 2313 2238 … … 2318 2243 cofflink.c:_bfd_coff_final_link(). It is specifically different only 2319 2244 where the POWERPC_LE_PE macro modifies the code. It is left in as a 2320 precise form of comment. krk@cygnus.com 2321 */ 2245 precise form of comment. krk@cygnus.com */ 2322 2246 2323 2247 /* Do the final link step. */ 2324 2248 2325 b oolean2249 bfd_boolean 2326 2250 ppc_bfd_coff_final_link (abfd, info) 2327 2251 bfd *abfd; … … 2330 2254 bfd_size_type symesz; 2331 2255 struct coff_final_link_info finfo; 2332 b oolean debug_merge_allocated;2256 bfd_boolean debug_merge_allocated; 2333 2257 asection *o; 2334 2258 struct bfd_link_order *p; 2335 size_tmax_sym_count;2336 size_tmax_lineno_count;2337 size_tmax_reloc_count;2338 size_tmax_output_reloc_count;2339 size_tmax_contents_size;2259 bfd_size_type max_sym_count; 2260 bfd_size_type max_lineno_count; 2261 bfd_size_type max_reloc_count; 2262 bfd_size_type max_output_reloc_count; 2263 bfd_size_type max_contents_size; 2340 2264 file_ptr rel_filepos; 2341 2265 unsigned int relsz; … … 2345 2269 bfd_byte *external_relocs = NULL; 2346 2270 char strbuf[STRING_SIZE_SIZE]; 2271 bfd_size_type amt; 2347 2272 2348 2273 symesz = bfd_coff_symesz (abfd); … … 2362 2287 finfo.external_relocs = NULL; 2363 2288 finfo.internal_relocs = NULL; 2364 debug_merge_allocated = false;2289 debug_merge_allocated = FALSE; 2365 2290 2366 2291 coff_data (abfd)->link_info = info; … … 2372 2297 if (! coff_debug_merge_hash_table_init (&finfo.debug_merge)) 2373 2298 goto error_return; 2374 debug_merge_allocated = true;2299 debug_merge_allocated = TRUE; 2375 2300 2376 2301 /* Compute the file positions for all the sections. */ … … 2378 2303 { 2379 2304 if (! bfd_coff_compute_section_file_positions (abfd)) 2380 return false;2305 return FALSE; 2381 2306 } 2382 2307 … … 2393 2318 o->reloc_count = 0; 2394 2319 o->lineno_count = 0; 2320 2395 2321 for (p = o->link_order_head; p != NULL; p = p->next) 2396 2322 { 2397 2398 2323 if (p->type == bfd_indirect_link_order) 2399 2324 { … … 2406 2331 to do this so that we can identify any sections which 2407 2332 the linker has decided to not include. */ 2408 sec->linker_mark = true;2333 sec->linker_mark = TRUE; 2409 2334 2410 2335 if (info->strip == strip_none … … 2445 2370 /* We use section_count + 1, rather than section_count, because 2446 2371 the target_index fields are 1 based. */ 2447 finfo.section_info =2448 ((struct coff_link_section_info *) 2449 bfd_malloc ((abfd->section_count + 1) 2450 * sizeof (struct coff_link_section_info))); 2372 amt = abfd->section_count + 1; 2373 amt *= sizeof (struct coff_link_section_info); 2374 finfo.section_info = (struct coff_link_section_info *) bfd_malloc (amt); 2375 2451 2376 if (finfo.section_info == NULL) 2452 2377 goto error_return; 2378 2453 2379 for (i = 0; i <= abfd->section_count; i++) 2454 2380 { … … 2463 2389 linesz = bfd_coff_linesz (abfd); 2464 2390 max_output_reloc_count = 0; 2391 2465 2392 for (o = abfd->sections; o != NULL; o = o->next) 2466 2393 { … … 2489 2416 common case. */ 2490 2417 BFD_ASSERT (info->relocateable); 2418 amt = o->reloc_count; 2419 amt *= sizeof (struct internal_reloc); 2491 2420 finfo.section_info[o->target_index].relocs = 2492 ((struct internal_reloc *) 2493 bfd_malloc (o->reloc_count * sizeof (struct internal_reloc))); 2421 (struct internal_reloc *) bfd_malloc (amt); 2422 amt = o->reloc_count; 2423 amt *= sizeof (struct coff_link_hash_entry *); 2494 2424 finfo.section_info[o->target_index].rel_hashes = 2495 ((struct coff_link_hash_entry **) 2496 bfd_malloc (o->reloc_count 2497 * sizeof (struct coff_link_hash_entry *))); 2425 (struct coff_link_hash_entry **) bfd_malloc (amt); 2498 2426 if (finfo.section_info[o->target_index].relocs == NULL 2499 2427 || finfo.section_info[o->target_index].rel_hashes == NULL) … … 2518 2446 for (sub = info->input_bfds; sub != NULL; sub = sub->link_next) 2519 2447 { 2520 size_tsz;2521 2522 sub->output_has_begun = false;2448 bfd_size_type sz; 2449 2450 sub->output_has_begun = FALSE; 2523 2451 sz = obj_raw_syment_count (sub); 2524 2452 if (sz > max_sym_count) … … 2527 2455 2528 2456 /* Allocate some buffers used while linking. */ 2529 finfo.internal_syms = ((struct internal_syment *)2530 bfd_malloc (max_sym_count 2531 * sizeof (struct internal_syment)));2532 finfo.sec_ptrs = (asection **) bfd_malloc ( max_sym_count2533 * sizeof (asection *));2534 finfo.sym_indices = (long *) bfd_malloc ( max_sym_count * sizeof (long));2535 finfo.outsyms = ((bfd_byte *)2536 bfd_malloc ((size_t) ((max_sym_count + 1) * symesz)));2537 finfo.linenos = (bfd_byte *) bfd_malloc (max_lineno_count2538 * bfd_coff_linesz (abfd));2457 amt = max_sym_count * sizeof (struct internal_syment); 2458 finfo.internal_syms = (struct internal_syment *) bfd_malloc (amt); 2459 amt = max_sym_count * sizeof (asection *); 2460 finfo.sec_ptrs = (asection **) bfd_malloc (amt); 2461 amt = max_sym_count * sizeof (long); 2462 finfo.sym_indices = (long *) bfd_malloc (amt); 2463 amt = (max_sym_count + 1) * symesz; 2464 finfo.outsyms = (bfd_byte *) bfd_malloc (amt); 2465 amt = max_lineno_count * bfd_coff_linesz (abfd); 2466 finfo.linenos = (bfd_byte *) bfd_malloc (amt); 2539 2467 finfo.contents = (bfd_byte *) bfd_malloc (max_contents_size); 2540 2468 finfo.external_relocs = (bfd_byte *) bfd_malloc (max_reloc_count * relsz); 2541 2469 if (! info->relocateable) 2542 finfo.internal_relocs = ((struct internal_reloc *) 2543 bfd_malloc (max_reloc_count 2544 * sizeof (struct internal_reloc))); 2470 { 2471 amt = max_reloc_count * sizeof (struct internal_reloc); 2472 finfo.internal_relocs = (struct internal_reloc *) bfd_malloc (amt); 2473 } 2545 2474 if ((finfo.internal_syms == NULL && max_sym_count > 0) 2546 2475 || (finfo.sec_ptrs == NULL && max_sym_count > 0) … … 2585 2514 if (! _bfd_coff_link_input_bfd (&finfo, sub)) 2586 2515 goto error_return; 2587 sub->output_has_begun = true;2516 sub->output_has_begun = TRUE; 2588 2517 } 2589 2518 } … … 2610 2539 goto error_return; 2611 2540 } 2612 last_one->output_has_begun = true;2541 last_one->output_has_begun = TRUE; 2613 2542 } 2614 2543 #endif 2615 2544 2616 2545 /* Free up the buffers used by _bfd_coff_link_input_bfd. */ 2617 2618 2546 coff_debug_merge_hash_table_free (&finfo.debug_merge); 2619 debug_merge_allocated = false;2547 debug_merge_allocated = FALSE; 2620 2548 2621 2549 if (finfo.internal_syms != NULL) … … 2661 2589 && (unsigned int) finfo.last_file.n_value != obj_raw_syment_count (abfd)) 2662 2590 { 2591 file_ptr pos; 2592 2663 2593 finfo.last_file.n_value = obj_raw_syment_count (abfd); 2664 2594 bfd_coff_swap_sym_out (abfd, (PTR) &finfo.last_file, 2665 2595 (PTR) finfo.outsyms); 2666 if (bfd_seek (abfd, 2667 (obj_sym_filepos (abfd) 2668 + finfo.last_file_index * symesz), 2669 SEEK_SET) != 0 2670 || bfd_write (finfo.outsyms, symesz, 1, abfd) != symesz) 2671 return false; 2596 pos = obj_sym_filepos (abfd) + finfo.last_file_index * symesz; 2597 if (bfd_seek (abfd, pos, SEEK_SET) != 0 2598 || bfd_bwrite (finfo.outsyms, symesz, abfd) != symesz) 2599 return FALSE; 2672 2600 } 2673 2601 2674 2602 /* Write out the global symbols. */ 2675 finfo.failed = false;2603 finfo.failed = FALSE; 2676 2604 coff_link_hash_traverse (coff_hash_table (info), _bfd_coff_write_global_sym, 2677 2605 (PTR) &finfo); … … 2691 2619 the symbol indices to use for relocs against them, and we can 2692 2620 finally write out the relocs. */ 2693 external_relocs = ((bfd_byte *)2694 bfd_malloc (max_output_reloc_count * relsz));2621 amt = max_output_reloc_count * relsz; 2622 external_relocs = (bfd_byte *) bfd_malloc (amt); 2695 2623 if (external_relocs == NULL) 2696 2624 goto error_return; … … 2720 2648 } 2721 2649 2650 amt = relsz * o->reloc_count; 2722 2651 if (bfd_seek (abfd, o->rel_filepos, SEEK_SET) != 0 2723 || bfd_write ((PTR) external_relocs, relsz, o->reloc_count, 2724 abfd) != relsz * o->reloc_count) 2652 || bfd_bwrite ((PTR) external_relocs, amt, abfd) != amt) 2725 2653 goto error_return; 2726 2654 } … … 2750 2678 { 2751 2679 if (! _bfd_write_stab_strings (abfd, &coff_hash_table (info)->stab_info)) 2752 return false;2680 return FALSE; 2753 2681 } 2754 2682 … … 2756 2684 if (obj_raw_syment_count (abfd) != 0) 2757 2685 { 2758 if (bfd_seek (abfd,2759 (obj_sym_filepos (abfd) 2760 + obj_raw_syment_count (abfd) * symesz), 2761 2762 return false;2686 file_ptr pos; 2687 2688 pos = obj_sym_filepos (abfd) + obj_raw_syment_count (abfd) * symesz; 2689 if (bfd_seek (abfd, pos, SEEK_SET) != 0) 2690 return FALSE; 2763 2691 2764 2692 #if STRING_SIZE_SIZE == 4 2765 bfd_h_put_32 (abfd,2766 2767 (bfd_byte *)strbuf);2693 H_PUT_32 (abfd, 2694 _bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE, 2695 strbuf); 2768 2696 #else 2769 #error Change bfd_h_put_322697 #error Change H_PUT_32 above 2770 2698 #endif 2771 2699 2772 if (bfd_write (strbuf, 1, STRING_SIZE_SIZE, abfd) != STRING_SIZE_SIZE) 2773 return false; 2700 if (bfd_bwrite (strbuf, (bfd_size_type) STRING_SIZE_SIZE, abfd) 2701 != STRING_SIZE_SIZE) 2702 return FALSE; 2774 2703 2775 2704 if (! _bfd_stringtab_emit (abfd, finfo.strtab)) 2776 return false;2705 return FALSE; 2777 2706 } 2778 2707 … … 2783 2712 bfd_get_symcount (abfd) = 0; 2784 2713 2785 return true;2714 return TRUE; 2786 2715 2787 2716 error_return: … … 2821 2750 if (external_relocs != NULL) 2822 2751 free (external_relocs); 2823 return false;2752 return FALSE; 2824 2753 } 2825 2754 #endif -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.