Changeset 609 for branches/GNU/src/binutils/bfd/aout-tic30.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/aout-tic30.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* BFD back-end for TMS320C30 a.out binaries. 2 Copyright 1998, 1999, 2000 Free Software Foundation, Inc.2 Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. 3 3 Contributed by Steven Haworth (steve@pm.cse.rmit.edu.au) 4 4 … … 22 22 #define TARGET_IS_BIG_ENDIAN_P 23 23 #define N_HEADER_IN_TEXT(x) 1 24 #define BYTES_IN_WORD 425 24 #define TEXT_START_ADDR 1024 26 25 #define TARGET_PAGE_SIZE 128 … … 29 28 #define ARCH_SIZE 32 30 29 31 #define MY(OP) CAT(tic30_aout_,OP) 30 /* Do not "beautify" the CONCAT* macro args. Traditional C will not 31 remove whitespace added here, and thus will fail to concatenate 32 the tokens. */ 33 #define MY(OP) CONCAT2 (tic30_aout_,OP) 32 34 #define TARGETNAME "a.out-tic30" 33 #define NAME(x,y) C AT3(tic30_aout,_32_,y)35 #define NAME(x,y) CONCAT3 (tic30_aout,_32_,y) 34 36 35 37 #include "bfd.h" … … 54 56 PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *, bfd_vma, 55 57 bfd_vma, bfd_vma)); 56 static const bfd_target *tic30_aout_object_p PARAMS ((bfd *)); 57 static boolean tic30_aout_write_object_contents PARAMS ((bfd *)); 58 static boolean tic30_aout_set_sizes PARAMS ((bfd *)); 59 60 #define MY_reloc_howto(BFD,REL,IN,EX,PC) tic30_aout_reloc_howto(BFD,REL,&IN,&EX,&PC) 58 static const bfd_target *tic30_aout_object_p 59 PARAMS ((bfd *)); 60 static bfd_boolean tic30_aout_write_object_contents 61 PARAMS ((bfd *)); 62 static bfd_boolean tic30_aout_set_sizes 63 PARAMS ((bfd *)); 64 static const bfd_target * tic30_aout_callback 65 PARAMS ((bfd *)); 66 static bfd_boolean MY_bfd_copy_private_section_data 67 PARAMS ((bfd *, asection *, bfd *, asection *)); 68 static bfd_boolean MY_bfd_final_link 69 PARAMS ((bfd *, struct bfd_link_info *)); 70 reloc_howto_type * tic30_aout_reloc_type_lookup 71 PARAMS ((bfd *, bfd_reloc_code_real_type)); 72 enum machine_type tic30_aout_machine_type 73 PARAMS ((enum bfd_architecture, unsigned long, bfd_boolean *)); 74 bfd_boolean tic30_aout_set_arch_mach 75 PARAMS ((bfd *, enum bfd_architecture, unsigned long)); 76 77 #define MY_reloc_howto(BFD, REL, IN, EX, PC) \ 78 tic30_aout_reloc_howto(BFD, REL, &IN, &EX, &PC) 61 79 #define MY_final_link_relocate tic30_aout_final_link_relocate 62 80 #define MY_object_p tic30_aout_object_p … … 102 120 #endif 103 121 104 static CONSTstruct aout_backend_data tic30_aout_backend_data =122 static const struct aout_backend_data tic30_aout_backend_data = 105 123 { 106 124 MY_zmagic_contiguous, … … 131 149 it. */ 132 150 reloc_howto_type tic30_aout_howto_table[] = 133 { 134 EMPTY_HOWTO (-1), 135 HOWTO (1, 2, 1, 16, false, 0, 0, tic30_aout_fix_16, 136 "16", false, 0x0000FFFF, 0x0000FFFF, false), 137 HOWTO (2, 2, 2, 24, false, 0, complain_overflow_bitfield, NULL, 138 "24", false, 0x00FFFFFF, 0x00FFFFFF, false), 139 HOWTO (3, 18, 3, 24, false, 0, complain_overflow_bitfield, NULL, 140 "LDP", false, 0x00FF0000, 0x000000FF, false), 141 HOWTO (4, 2, 4, 32, false, 0, complain_overflow_bitfield, tic30_aout_fix_32, 142 "32", false, 0xFFFFFFFF, 0xFFFFFFFF, false), 143 HOWTO (5, 2, 1, 16, true, 0, complain_overflow_signed, 144 tic30_aout_fix_pcrel_16, "PCREL", true, 0x0000FFFF, 0x0000FFFF, true), 145 EMPTY_HOWTO (-1), 146 EMPTY_HOWTO (-1), 147 EMPTY_HOWTO (-1), 148 EMPTY_HOWTO (-1), 149 EMPTY_HOWTO (-1) 150 }; 151 152 extern reloc_howto_type *NAME (aout, reloc_type_lookup) (); 151 { 152 EMPTY_HOWTO (-1), 153 HOWTO (1, 2, 1, 16, FALSE, 0, 0, tic30_aout_fix_16, 154 "16", FALSE, 0x0000FFFF, 0x0000FFFF, FALSE), 155 HOWTO (2, 2, 2, 24, FALSE, 0, complain_overflow_bitfield, NULL, 156 "24", FALSE, 0x00FFFFFF, 0x00FFFFFF, FALSE), 157 HOWTO (3, 18, 3, 24, FALSE, 0, complain_overflow_bitfield, NULL, 158 "LDP", FALSE, 0x00FF0000, 0x000000FF, FALSE), 159 HOWTO (4, 2, 4, 32, FALSE, 0, complain_overflow_bitfield, tic30_aout_fix_32, 160 "32", FALSE, 0xFFFFFFFF, 0xFFFFFFFF, FALSE), 161 HOWTO (5, 2, 1, 16, TRUE, 0, complain_overflow_signed, 162 tic30_aout_fix_pcrel_16, "PCREL", TRUE, 0x0000FFFF, 0x0000FFFF, TRUE), 163 EMPTY_HOWTO (-1), 164 EMPTY_HOWTO (-1), 165 EMPTY_HOWTO (-1), 166 EMPTY_HOWTO (-1), 167 EMPTY_HOWTO (-1) 168 }; 169 170 extern reloc_howto_type *NAME (aout, reloc_type_lookup) 171 PARAMS ((bfd *, bfd_reloc_code_real_type)); 153 172 154 173 reloc_howto_type * … … 318 337 unsigned long arch_align; 319 338 320 /* Calculate the file positions of the parts of a newly read aout header */339 /* Calculate the file positions of the parts of a newly read aout header. */ 321 340 obj_textsec (abfd)->_raw_size = N_TXTSIZE (*execp); 322 341 323 /* The virtual memory addresses of the sections */342 /* The virtual memory addresses of the sections. */ 324 343 obj_textsec (abfd)->vma = N_TXTADDR (*execp); 325 344 obj_datasec (abfd)->vma = N_DATADDR (*execp); … … 330 349 obj_bsssec (abfd)->lma = obj_bsssec (abfd)->vma; 331 350 332 /* The file offsets of the sections */351 /* The file offsets of the sections. */ 333 352 obj_textsec (abfd)->filepos = N_TXTOFF (*execp); 334 353 obj_datasec (abfd)->filepos = N_DATOFF (*execp); 335 354 336 /* The file offsets of the relocation info */355 /* The file offsets of the relocation info. */ 337 356 obj_textsec (abfd)->rel_filepos = N_TRELOFF (*execp); 338 357 obj_datasec (abfd)->rel_filepos = N_DRELOFF (*execp); … … 346 365 SET_ARCH_MACH (abfd, *execp); 347 366 #else 348 bfd_default_set_arch_mach (abfd, DEFAULT_ARCH, 0 );367 bfd_default_set_arch_mach (abfd, DEFAULT_ARCH, 0L); 349 368 #endif 350 369 … … 406 425 { 407 426 bfd_vma x; 408 b oolean overflow;427 bfd_boolean overflow; 409 428 410 429 if (howto->size < 0) … … 430 449 break; 431 450 } 432 overflow = false; 451 452 overflow = FALSE; 453 433 454 if (howto->complain_on_overflow != complain_overflow_dont) 434 455 { … … 475 496 bfd_signed_vma reloc_signed_min = ~reloc_signed_max; 476 497 if (signed_check > reloc_signed_max || signed_check < reloc_signed_min) 477 overflow = true;498 overflow = TRUE; 478 499 } 479 500 break; … … 482 503 bfd_vma reloc_unsigned_max = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1; 483 504 if (check > reloc_unsigned_max) 484 overflow = true;505 overflow = TRUE; 485 506 } 486 507 break; … … 488 509 { 489 510 bfd_vma reloc_bits = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1; 490 if ((check & ~reloc_bits) != 0 && (((bfd_vma) signed_check & ~reloc_bits) != (-1 & ~reloc_bits))) 491 overflow = true; 511 if ((check & ~reloc_bits) != 0 512 && (((bfd_vma) signed_check & ~reloc_bits) 513 != ((bfd_vma) -1 & ~reloc_bits))) 514 overflow = TRUE; 492 515 } 493 516 break; … … 521 544 } 522 545 523 /* Finish up the reading of an a.out file header */546 /* Finish up the reading of an a.out file header. */ 524 547 525 548 static const bfd_target * … … 527 550 bfd *abfd; 528 551 { 529 struct external_exec exec_bytes; /* Raw exec header from file */530 struct internal_exec exec; /* Cleaned-up exec header */552 struct external_exec exec_bytes; /* Raw exec header from file. */ 553 struct internal_exec exec; /* Cleaned-up exec header. */ 531 554 const bfd_target *target; 532 533 if (bfd_read ((PTR) & exec_bytes, 1, EXEC_BYTES_SIZE, abfd) 534 != EXEC_BYTES_SIZE)555 bfd_size_type amt = EXEC_BYTES_SIZE; 556 557 if (bfd_bread ((PTR) &exec_bytes, amt, abfd) != amt) 535 558 { 536 559 if (bfd_get_error () != bfd_error_system_call) … … 542 565 exec.a_info = SWAP_MAGIC (exec_bytes.e_info); 543 566 #else 544 exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);567 exec.a_info = H_GET_32 (abfd, exec_bytes.e_info); 545 568 #endif /* SWAP_MAGIC */ 546 569 … … 563 586 #ifdef ENTRY_CAN_BE_ZERO 564 587 /* The NEWSOS3 entry-point is/was 0, which (amongst other lossage) 565 *means that it isn't obvious if EXEC_P should be set.566 *All of the following must be true for an executable:567 *There must be no relocations, the bfd can be neither an568 *archive nor an archive element, and the file must be executable. */588 means that it isn't obvious if EXEC_P should be set. 589 All of the following must be true for an executable: 590 There must be no relocations, the bfd can be neither an 591 archive nor an archive element, and the file must be executable. */ 569 592 570 593 if (exec.a_trsize + exec.a_drsize == 0 … … 589 612 after the section contents have been set. */ 590 613 591 static b oolean614 static bfd_boolean 592 615 MY_bfd_copy_private_section_data (ibfd, isec, obfd, osec) 593 616 bfd *ibfd; … … 598 621 if (bfd_get_flavour (obfd) == bfd_target_aout_flavour) 599 622 obj_aout_subformat (obfd) = obj_aout_subformat (ibfd); 600 return true;623 return TRUE; 601 624 } 602 625 … … 605 628 file header, symbols, and relocation. */ 606 629 607 static b oolean630 static bfd_boolean 608 631 tic30_aout_write_object_contents (abfd) 609 632 bfd *abfd; … … 615 638 616 639 { 617 bfd_size_type text_size; /* dummy vars*/640 bfd_size_type text_size; /* Dummy vars. */ 618 641 file_ptr text_end; 642 619 643 if (adata (abfd).magic == undecided_magic) 620 644 NAME (aout, adjust_sizes_and_vmas) (abfd, &text_size, &text_end); … … 629 653 if (adata (abfd).exec_bytes_size > 0) 630 654 { 655 bfd_size_type amt; 631 656 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) 632 return false; 633 if (bfd_write ((PTR) & exec_bytes, 1, adata (abfd).exec_bytes_size, abfd) != adata (abfd).exec_bytes_size) 634 return false; 657 return FALSE; 658 amt = adata (abfd).exec_bytes_size; 659 if (bfd_bwrite ((PTR) &exec_bytes, amt, abfd) != amt) 660 return FALSE; 635 661 } 636 /* Now write out reloc info, followed by syms and strings */ 637 662 663 /* Now write out reloc info, followed by syms and strings. */ 638 664 if (bfd_get_outsymbols (abfd) != (asymbol **) NULL 639 665 && bfd_get_symcount (abfd) != 0) 640 666 { 641 667 if (bfd_seek (abfd, (file_ptr) (N_SYMOFF (*execp)), SEEK_SET) != 0) 642 return false;668 return FALSE; 643 669 644 670 if (!NAME (aout, write_syms) (abfd)) 645 return false;671 return FALSE; 646 672 } 647 673 648 674 if (bfd_seek (abfd, (file_ptr) (N_TRELOFF (*execp)), SEEK_SET) != 0) 649 return false;675 return FALSE; 650 676 if (!NAME (aout, squirt_out_relocs) (abfd, obj_textsec (abfd))) 651 return false;677 return FALSE; 652 678 653 679 if (bfd_seek (abfd, (file_ptr) (N_DRELOFF (*execp)), SEEK_SET) != 0) 654 return false;680 return FALSE; 655 681 if (!NAME (aout, squirt_out_relocs) (abfd, obj_datasec (abfd))) 656 return false;682 return FALSE; 657 683 } 658 684 659 return true;660 } 661 662 static b oolean685 return TRUE; 686 } 687 688 static bfd_boolean 663 689 tic30_aout_set_sizes (abfd) 664 690 bfd *abfd; … … 680 706 adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE; 681 707 682 return true;708 return TRUE; 683 709 } 684 710 … … 711 737 offsets in the output file. */ 712 738 713 static b oolean739 static bfd_boolean 714 740 MY_bfd_final_link (abfd, info) 715 741 bfd *abfd; … … 746 772 obj_datasec (abfd)->vma = BFD_ALIGN (vma, 4); 747 773 } 774 748 775 if (obj_datasec (abfd)->vma < vma) 749 { 750 obj_datasec (abfd)->vma = BFD_ALIGN (vma, 4); 751 } 776 obj_datasec (abfd)->vma = BFD_ALIGN (vma, 4); 777 752 778 obj_datasec (abfd)->user_set_vma = 1; 753 779 vma = obj_datasec (abfd)->vma; … … 779 805 enum bfd_architecture arch; 780 806 unsigned long machine ATTRIBUTE_UNUSED; 781 b oolean *unknown;807 bfd_boolean *unknown; 782 808 { 783 809 enum machine_type arch_flags; 784 810 785 811 arch_flags = M_UNKNOWN; 786 *unknown = true;812 *unknown = TRUE; 787 813 788 814 switch (arch) 789 815 { 790 816 case bfd_arch_tic30: 791 *unknown = false;817 *unknown = FALSE; 792 818 break; 793 819 default: … … 795 821 } 796 822 if (arch_flags != M_UNKNOWN) 797 *unknown = false;823 *unknown = FALSE; 798 824 return arch_flags; 799 825 } 800 826 801 b oolean827 bfd_boolean 802 828 tic30_aout_set_arch_mach (abfd, arch, machine) 803 829 bfd *abfd; … … 806 832 { 807 833 if (!bfd_default_set_arch_mach (abfd, arch, machine)) 808 return false;834 return FALSE; 809 835 if (arch != bfd_arch_unknown) 810 836 { 811 b oolean unknown;837 bfd_boolean unknown; 812 838 tic30_aout_machine_type (arch, machine, &unknown); 813 839 if (unknown) 814 return false;840 return FALSE; 815 841 } 816 842 obj_reloc_entry_size (abfd) = RELOC_STD_SIZE; … … 941 967 #define MY_bfd_gc_sections bfd_generic_gc_sections 942 968 #endif 969 #ifndef MY_bfd_merge_sections 970 #define MY_bfd_merge_sections bfd_generic_merge_sections 971 #endif 972 #ifndef MY_bfd_discard_group 973 #define MY_bfd_discard_group bfd_generic_discard_group 974 #endif 943 975 #ifndef MY_bfd_reloc_type_lookup 944 976 #define MY_bfd_reloc_type_lookup tic30_aout_reloc_type_lookup … … 956 988 #define MY_bfd_link_hash_table_create NAME(aout,link_hash_table_create) 957 989 #endif 990 #ifndef MY_bfd_link_hash_table_free 991 #define MY_bfd_link_hash_table_free _bfd_generic_link_hash_table_free 992 #endif 958 993 #ifndef MY_bfd_link_add_symbols 959 994 #define MY_bfd_link_add_symbols NAME(aout,link_add_symbols) 995 #endif 996 #ifndef MY_bfd_link_just_syms 997 #define MY_bfd_link_just_syms _bfd_generic_link_just_syms 960 998 #endif 961 999 #ifndef MY_bfd_link_split_section -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.