Changeset 609 for branches/GNU/src/binutils/bfd/aoutf1.h
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/aoutf1.h
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* A.out "format 1" file handling code for BFD. 2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000 2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 3 2001, 2002 3 4 Free Software Foundation, Inc. 4 5 Written by Cygnus Support. … … 75 76 #endif 76 77 77 static boolean sunos_merge_private_bfd_data PARAMS ((bfd *, bfd *)); 78 static void sunos_set_arch_mach PARAMS ((bfd *, int)); 79 static void choose_reloc_size PARAMS ((bfd *)); 80 static boolean sunos_write_object_contents PARAMS ((bfd *)); 81 static const bfd_target *sunos4_core_file_p PARAMS ((bfd *)); 82 static char *sunos4_core_file_failing_command PARAMS ((bfd *)); 83 static int sunos4_core_file_failing_signal PARAMS ((bfd *)); 84 static boolean sunos4_core_file_matches_executable_p PARAMS ((bfd *, bfd *)); 85 static boolean sunos4_set_sizes PARAMS ((bfd *)); 78 static bfd_boolean sunos_merge_private_bfd_data 79 PARAMS ((bfd *, bfd *)); 80 static void sunos_set_arch_mach 81 PARAMS ((bfd *, enum machine_type)); 82 static void choose_reloc_size 83 PARAMS ((bfd *)); 84 static bfd_boolean sunos_write_object_contents 85 PARAMS ((bfd *)); 86 static const bfd_target *sunos4_core_file_p 87 PARAMS ((bfd *)); 88 static char *sunos4_core_file_failing_command 89 PARAMS ((bfd *)); 90 static int sunos4_core_file_failing_signal 91 PARAMS ((bfd *)); 92 static bfd_boolean sunos4_core_file_matches_executable_p 93 PARAMS ((bfd *, bfd *)); 94 static bfd_boolean sunos4_set_sizes 95 PARAMS ((bfd *)); 86 96 87 97 /* Merge backend data into the output file. … … 91 101 #define MY_bfd_merge_private_bfd_data sunos_merge_private_bfd_data 92 102 93 static b oolean103 static bfd_boolean 94 104 sunos_merge_private_bfd_data (ibfd, obfd) 95 105 bfd *ibfd, *obfd; … … 97 107 if (bfd_get_flavour (ibfd) != bfd_target_aout_flavour 98 108 || bfd_get_flavour (obfd) != bfd_target_aout_flavour) 99 return true;109 return TRUE; 100 110 101 111 if (bfd_get_arch (obfd) == bfd_arch_sparc) … … 105 115 } 106 116 107 return true;117 return TRUE; 108 118 } 109 119 … … 114 124 sunos_set_arch_mach (abfd, machtype) 115 125 bfd *abfd; 116 intmachtype;126 enum machine_type machtype; 117 127 { 118 128 /* Determine the architecture and machine type of the object file. */ 119 129 enum bfd_architecture arch; 120 long machine;130 unsigned long machine; 121 131 switch (machtype) 122 132 { … … 207 217 aout_32_sunos4_write_object_contents, depending upon ARCH_SIZE. */ 208 218 209 static b oolean219 static bfd_boolean 210 220 sunos_write_object_contents (abfd) 211 221 bfd *abfd; … … 260 270 N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags); 261 271 262 N_SET_DYNAMIC (*execp, bfd_get_file_flags (abfd) & DYNAMIC);272 N_SET_DYNAMIC (*execp, (long)(bfd_get_file_flags (abfd) & DYNAMIC)); 263 273 264 274 WRITE_HEADERS (abfd, execp); 265 275 266 return true;276 return TRUE; 267 277 } 268 278 … … 424 434 struct external_sun3_core *extcore = (struct external_sun3_core *) ext; 425 435 426 intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_magic);427 intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_len);436 intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic); 437 intcore->c_len = H_GET_32 (abfd, &extcore->c_len); 428 438 intcore->c_regs_pos = (long) (((struct external_sun3_core *) 0)->c_regs); 429 439 intcore->c_regs_size = sizeof (extcore->c_regs); … … 434 444 #endif 435 445 (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr); 436 intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_signo);437 intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_tsize);438 intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_dsize);446 intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo); 447 intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize); 448 intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize); 439 449 intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr); 440 intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_ssize);450 intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize); 441 451 memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname)); 442 452 intcore->fp_stuff_pos = (long) (((struct external_sun3_core *) 0)->fp_stuff); … … 445 455 (file_ptr) (((struct external_sun3_core *) 0)->fp_stuff); 446 456 /* Ucode is the last thing in the struct -- just before the end */ 447 intcore->c_ucode = 448 bfd_h_get_32 (abfd, 449 intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore); 457 intcore->c_ucode = H_GET_32 (abfd, 458 (intcore->c_len 459 - sizeof (extcore->c_ucode) 460 + (unsigned char *) extcore)); 450 461 intcore->c_stacktop = 0x0E000000; /* By experimentation */ 451 462 } … … 460 471 struct external_sparc_core *extcore = (struct external_sparc_core *) ext; 461 472 462 intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_magic);463 intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_len);473 intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic); 474 intcore->c_len = H_GET_32 (abfd, &extcore->c_len); 464 475 intcore->c_regs_pos = (long) (((struct external_sparc_core *) 0)->c_regs); 465 476 intcore->c_regs_size = sizeof (extcore->c_regs); … … 470 481 #endif 471 482 (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr); 472 intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_signo);473 intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_tsize);474 intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_dsize);483 intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo); 484 intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize); 485 intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize); 475 486 intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr); 476 intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_ssize);487 intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize); 477 488 memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname)); 478 489 intcore->fp_stuff_pos = (long) (((struct external_sparc_core *) 0)->fp_stuff); … … 481 492 (file_ptr) (((struct external_sparc_core *) 0)->fp_stuff); 482 493 /* Ucode is the last thing in the struct -- just before the end */ 483 intcore->c_ucode = 484 bfd_h_get_32 (abfd, 485 intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore); 494 intcore->c_ucode = H_GET_32 (abfd, 495 (intcore->c_len 496 - sizeof (extcore->c_ucode) 497 + (unsigned char *) extcore)); 486 498 487 499 /* Supposedly the user stack grows downward from the bottom of kernel memory. … … 501 513 #define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000) 502 514 { 503 bfd_vma sp = bfd_h_get_32 504 (abfd, (unsigned char *) &((struct regs *) &extcore->c_regs[0])->r_o6); 515 bfd_vma sp = H_GET_32 (abfd, &((struct regs *) &extcore->c_regs[0])->r_o6); 505 516 if (sp < SPARC_USRSTACK_SPARC10) 506 517 intcore->c_stacktop = SPARC_USRSTACK_SPARC10; … … 520 531 (struct external_solaris_bcp_core *) ext; 521 532 522 intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_magic);523 intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_len);533 intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic); 534 intcore->c_len = H_GET_32 (abfd, &extcore->c_len); 524 535 intcore->c_regs_pos = (long) (((struct external_solaris_bcp_core *) 0)->c_regs); 525 536 intcore->c_regs_size = sizeof (extcore->c_regs); … … 536 547 start address. */ 537 548 memset ((PTR) &intcore->c_aouthdr, 0, sizeof (struct internal_exec)); 538 intcore->c_data_addr = 539 bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_exdata_datorg); 540 intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo); 541 intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize); 542 intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize); 543 intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize); 549 intcore->c_data_addr = H_GET_32 (abfd, &extcore->c_exdata_datorg); 550 intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo); 551 intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize); 552 intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize); 553 intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize); 544 554 memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname)); 545 555 intcore->fp_stuff_pos = … … 549 559 (file_ptr) (((struct external_solaris_bcp_core *) 0)->fp_stuff); 550 560 /* Ucode is the last thing in the struct -- just before the end */ 551 intcore->c_ucode = 552 bfd_h_get_32 (abfd, 553 intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore); 561 intcore->c_ucode = H_GET_32 (abfd, 562 (intcore->c_len 563 - sizeof (extcore->c_ucode) 564 + (unsigned char *) extcore)); 554 565 555 566 /* Supposedly the user stack grows downward from the bottom of kernel memory. … … 569 580 #define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000) 570 581 { 571 bfd_vma sp = bfd_h_get_32 572 (abfd, (unsigned char *) &((struct regs *) &extcore->c_regs[0])->r_o6); 582 bfd_vma sp = H_GET_32 (abfd, &((struct regs *) &extcore->c_regs[0])->r_o6); 573 583 if (sp < SPARC_USRSTACK_SPARC10) 574 584 intcore->c_stacktop = SPARC_USRSTACK_SPARC10; … … 600 610 { 601 611 unsigned char longbuf[4]; /* Raw bytes of various header fields */ 602 bfd_size_type core_size ;612 bfd_size_type core_size, amt; 603 613 unsigned long core_mag; 604 614 struct internal_sunos_core *core; … … 609 619 struct internal_sunos_core internal_sunos_core; 610 620 char external_core[1]; 611 } 612 *mergem; 613 614 if (bfd_read ((PTR) longbuf, 1, sizeof (longbuf), abfd) != 615 sizeof (longbuf)) 621 } *mergem; 622 623 if (bfd_bread ((PTR) longbuf, (bfd_size_type) sizeof (longbuf), abfd) 624 != sizeof (longbuf)) 616 625 return 0; 617 core_mag = bfd_h_get_32 (abfd, longbuf);626 core_mag = H_GET_32 (abfd, longbuf); 618 627 619 628 if (core_mag != CORE_MAGIC) … … 621 630 622 631 /* SunOS core headers can vary in length; second word is size; */ 623 if (bfd_ read ((PTR) longbuf, 1, sizeof (longbuf), abfd) !=624 sizeof (longbuf))632 if (bfd_bread ((PTR) longbuf, (bfd_size_type) sizeof (longbuf), abfd) 633 != sizeof (longbuf)) 625 634 return 0; 626 core_size = bfd_h_get_32 (abfd, longbuf);635 core_size = H_GET_32 (abfd, longbuf); 627 636 /* Sanity check */ 628 637 if (core_size > 20000) 629 638 return 0; 630 639 631 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) <0)640 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) 632 641 return 0; 633 642 634 mergem = (struct mergem *) bfd_zalloc (abfd, core_size + sizeof (struct mergem)); 643 amt = core_size + sizeof (struct mergem); 644 mergem = (struct mergem *) bfd_zalloc (abfd, amt); 635 645 if (mergem == NULL) 636 646 return 0; … … 638 648 extcore = mergem->external_core; 639 649 640 if ((bfd_ read ((PTR) extcore, 1, core_size, abfd)) != core_size)650 if ((bfd_bread ((PTR) extcore, core_size, abfd)) != core_size) 641 651 { 652 loser: 642 653 bfd_release (abfd, (char *) mergem); 654 abfd->tdata.any = NULL; 655 bfd_section_list_clear (abfd); 643 656 return 0; 644 657 } … … 661 674 default: 662 675 bfd_set_error (bfd_error_system_call); /* FIXME */ 663 bfd_release (abfd, (char *) mergem); 664 return 0; 676 goto loser; 665 677 } 666 678 … … 668 680 abfd->tdata.sun_core_data->hdr = core; 669 681 670 /* create the sections. This is raunchy, but bfd_close wants to reclaim 671 them */ 672 core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection)); 682 /* Create the sections. */ 683 core_stacksec (abfd) = bfd_make_section_anyway (abfd, ".stack"); 673 684 if (core_stacksec (abfd) == NULL) 674 { 675 loser: 676 bfd_release (abfd, (char *) mergem); 677 return 0; 678 } 679 core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection)); 685 /* bfd_release frees everything allocated after it's arg. */ 686 goto loser; 687 688 core_datasec (abfd) = bfd_make_section_anyway (abfd, ".data"); 680 689 if (core_datasec (abfd) == NULL) 681 { 682 loser1: 683 bfd_release (abfd, core_stacksec (abfd)); 684 goto loser; 685 } 686 core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection)); 690 goto loser; 691 692 core_regsec (abfd) = bfd_make_section_anyway (abfd, ".reg"); 687 693 if (core_regsec (abfd) == NULL) 688 { 689 loser2: 690 bfd_release (abfd, core_datasec (abfd)); 691 goto loser1; 692 } 693 core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection)); 694 goto loser; 695 696 core_reg2sec (abfd) = bfd_make_section_anyway (abfd, ".reg2"); 694 697 if (core_reg2sec (abfd) == NULL) 695 { 696 bfd_release (abfd, core_regsec (abfd)); 697 goto loser2; 698 } 699 700 core_stacksec (abfd)->name = ".stack"; 701 core_datasec (abfd)->name = ".data"; 702 core_regsec (abfd)->name = ".reg"; 703 core_reg2sec (abfd)->name = ".reg2"; 698 goto loser; 704 699 705 700 core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS; … … 730 725 core_reg2sec (abfd)->alignment_power = 2; 731 726 732 abfd->sections = core_stacksec (abfd);733 core_stacksec (abfd)->next = core_datasec (abfd);734 core_datasec (abfd)->next = core_regsec (abfd);735 core_regsec (abfd)->next = core_reg2sec (abfd);736 737 abfd->section_count = 4;738 739 727 return abfd->xvec; 740 728 } … … 754 742 } 755 743 756 static b oolean744 static bfd_boolean 757 745 sunos4_core_file_matches_executable_p (core_bfd, exec_bfd) 758 746 bfd *core_bfd; … … 762 750 { 763 751 bfd_set_error (bfd_error_system_call); 764 return false;752 return FALSE; 765 753 } 766 754 767 755 /* Solaris core files do not include an aouthdr. */ 768 756 if ((core_hdr (core_bfd)->hdr)->c_len == SOLARIS_BCP_CORE_LEN) 769 return true;757 return TRUE; 770 758 771 759 return (memcmp ((char *) &((core_hdr (core_bfd)->hdr)->c_aouthdr), 772 760 (char *) exec_hdr (exec_bfd), 773 sizeof (struct internal_exec)) == 0) ? true : false;761 sizeof (struct internal_exec)) == 0); 774 762 } 775 763 776 764 #define MY_set_sizes sunos4_set_sizes 777 static b oolean765 static bfd_boolean 778 766 sunos4_set_sizes (abfd) 779 767 bfd *abfd; … … 782 770 { 783 771 default: 784 return false;772 return FALSE; 785 773 case bfd_arch_sparc: 786 774 adata (abfd).page_size = 0x2000; 787 775 adata (abfd).segment_size = 0x2000; 788 776 adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE; 789 return true;777 return TRUE; 790 778 case bfd_arch_m68k: 791 779 adata (abfd).page_size = 0x2000; 792 780 adata (abfd).segment_size = 0x20000; 793 781 adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE; 794 return true;782 return TRUE; 795 783 } 796 784 } … … 824 812 #endif 825 813 826 static CONSTstruct aout_backend_data sunos4_aout_backend =814 static const struct aout_backend_data sunos4_aout_backend = 827 815 { 828 816 0, /* zmagic files are not contiguous */ -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.