Changeset 609 for branches/GNU/src/binutils/bfd/hp300hpux.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/hp300hpux.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* BFD backend for hp-ux 9000/300 2 Copyright 1990, 1991, 1993, 1994, 1995, 1997, 2000, 2001 2 Copyright 1990, 1991, 1993, 1994, 1995, 1997, 2000, 2001, 2002 3 3 Free Software Foundation, Inc. 4 4 Written by Glenn Engel. … … 21 21 22 22 /* 23 24 23 hpux native ------------> | | 25 24 | hp300hpux bfd | ----------> hpux w/gnu ext … … 102 101 103 102 #define TARGETNAME "a.out-hp300hpux" 104 #define MY(OP) CAT(hp300hpux_,OP) 103 104 /* Do not "beautify" the CONCAT* macro args. Traditional C will not 105 remove whitespace added here, and thus will fail to concatenate 106 the tokens. */ 107 #define MY(OP) CONCAT2 (hp300hpux_,OP) 105 108 106 109 #define external_exec hp300hpux_exec_bytes … … 125 128 /***********************************************/ 126 129 /* these don't use MY because that causes problems within JUMP_TABLE 127 (C ATwinds up being expanded recursively, which ANSI C compilers130 (CONCAT2 winds up being expanded recursively, which ANSI C compilers 128 131 will not do). */ 129 132 #define MY_get_symtab hp300hpux_get_symtab … … 183 186 #define HP_RLENGTH_ALIGN 0x03 184 187 185 #define NAME(x,y) C AT3(hp300hpux,_32_,y)188 #define NAME(x,y) CONCAT3 (hp300hpux,_32_,y) 186 189 #define ARCH_SIZE 32 187 190 … … 191 194 192 195 #include "aoutx.h" 196 197 static const bfd_target * MY (callback) 198 PARAMS ((bfd *)); 199 static bfd_boolean MY (write_object_contents) 200 PARAMS ((bfd *)); 201 static void convert_sym_type 202 PARAMS ((struct external_nlist *, aout_symbol_type *, bfd *)); 203 204 bfd_boolean MY (slurp_symbol_table) 205 PARAMS ((bfd *)); 206 void MY (swap_std_reloc_in) 207 PARAMS ((bfd *, struct hp300hpux_reloc *, arelent *, asymbol **, 208 bfd_size_type)); 209 bfd_boolean MY (slurp_reloc_table) 210 PARAMS ((bfd *, sec_ptr, asymbol **)); 211 long MY (get_symtab) 212 PARAMS ((bfd *, asymbol **)); 213 long MY (get_symtab_upper_bound) 214 PARAMS ((bfd *)); 215 long MY (canonicalize_reloc) 216 PARAMS ((bfd *, sec_ptr, arelent **, asymbol **)); 193 217 194 218 /* Since the hpux symbol table has nlist elements interspersed with … … 258 282 } 259 283 260 extern boolean aout_32_write_syms PARAMS ((bfd * abfd)); 261 262 static boolean 284 extern bfd_boolean aout_32_write_syms 285 PARAMS ((bfd * abfd)); 286 287 static bfd_boolean 263 288 MY (write_object_contents) (abfd) 264 289 bfd *abfd; … … 292 317 293 318 /* this is really the sym table size but we store it in drelocs */ 294 bfd_h_put_32 (abfd, bfd_get_symcount (abfd) * 12, exec_bytes.e_drelocs);295 296 if (bfd_seek (abfd, 0L, false) != 0297 || (bfd_ write ((PTR) & exec_bytes, 1,EXEC_BYTES_SIZE, abfd)319 H_PUT_32 (abfd, (bfd_get_symcount (abfd) * 12), exec_bytes.e_drelocs); 320 321 if (bfd_seek (abfd, (file_ptr) 0, FALSE) != 0 322 || (bfd_bwrite ((PTR) &exec_bytes, (bfd_size_type) EXEC_BYTES_SIZE, abfd) 298 323 != EXEC_BYTES_SIZE)) 299 return false;324 return FALSE; 300 325 301 326 /* Write out the symbols, and then the relocs. We must write out … … 305 330 { 306 331 /* Skip the relocs to where we want to put the symbols. */ 307 if (bfd_seek (abfd, (file_ptr) N_DRELOFF (*execp) + execp->a_drsize,332 if (bfd_seek (abfd, (file_ptr) (N_DRELOFF (*execp) + execp->a_drsize), 308 333 SEEK_SET) != 0) 309 return false;334 return FALSE; 310 335 } 311 336 312 337 if (!MY (write_syms) (abfd)) 313 return false;338 return FALSE; 314 339 315 340 if (bfd_get_symcount (abfd) != 0) 316 341 { 317 if (bfd_seek (abfd, ( long) (N_TRELOFF (*execp)), false) != 0)318 return false;342 if (bfd_seek (abfd, (file_ptr) N_TRELOFF (*execp), SEEK_CUR) != 0) 343 return FALSE; 319 344 if (!NAME (aout,squirt_out_relocs) (abfd, obj_textsec (abfd))) 320 return false;321 if (bfd_seek (abfd, ( long) (N_DRELOFF (*execp)), false) != 0)322 return false;345 return FALSE; 346 if (bfd_seek (abfd, (file_ptr) N_DRELOFF (*execp), SEEK_CUR) != 0) 347 return FALSE; 323 348 if (!NAME (aout,squirt_out_relocs) (abfd, obj_datasec (abfd))) 324 return false;325 } 326 327 return true;349 return FALSE; 350 } 351 352 return TRUE; 328 353 } 329 354 … … 440 465 memset (execp, 0, sizeof (struct internal_exec)); 441 466 /* Now fill in fields in the execp, from the bytes in the raw data. */ 442 execp->a_info = bfd_h_get_32 (abfd, bytes->e_info);467 execp->a_info = H_GET_32 (abfd, bytes->e_info); 443 468 execp->a_text = GET_WORD (abfd, bytes->e_text); 444 469 execp->a_data = GET_WORD (abfd, bytes->e_data); … … 459 484 long syms; 460 485 struct aout_data_struct *rawptr; 461 if (bfd_h_get_32 (abfd, bytes->e_passize) != 0) 486 bfd_size_type amt; 487 488 if (H_GET_32 (abfd, bytes->e_passize) != 0) 462 489 break; 463 if ( bfd_h_get_32 (abfd, bytes->e_syms) != 0)490 if (H_GET_32 (abfd, bytes->e_syms) != 0) 464 491 break; 465 if ( bfd_h_get_32 (abfd, bytes->e_supsize) != 0)492 if (H_GET_32 (abfd, bytes->e_supsize) != 0) 466 493 break; 467 494 468 syms = bfd_h_get_32 (abfd, bytes->e_drelocs);495 syms = H_GET_32 (abfd, bytes->e_drelocs); 469 496 if (syms == 0) 470 497 break; … … 474 501 475 502 /* allocate storage for where we will store this result */ 476 rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, sizeof (*rawptr)); 503 amt = sizeof (*rawptr); 504 rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, amt); 477 505 478 506 if (rawptr == NULL) … … 507 535 */ 508 536 509 b oolean537 bfd_boolean 510 538 MY (slurp_symbol_table) (abfd) 511 539 bfd *abfd; … … 518 546 aout_symbol_type *cached; 519 547 unsigned num_syms = 0; 548 bfd_size_type amt; 520 549 521 550 /* If there's no work to be done, don't do any */ 522 551 if (obj_aout_symbols (abfd) != (aout_symbol_type *) NULL) 523 return true;552 return TRUE; 524 553 symbol_bytes = exec_hdr (abfd)->a_syms; 525 554 526 strings = (char *) bfd_alloc (abfd,527 symbol_bytes + SYM_EXTRA_BYTES);555 amt = symbol_bytes + SYM_EXTRA_BYTES; 556 strings = (char *) bfd_alloc (abfd, amt); 528 557 if (!strings) 529 return false;558 return FALSE; 530 559 syms = (struct external_nlist *) (strings + SYM_EXTRA_BYTES); 531 560 if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0 532 || bfd_ read ((PTR) syms, symbol_bytes, 1, abfd) != symbol_bytes)561 || bfd_bread ((PTR) syms, symbol_bytes, abfd) != symbol_bytes) 533 562 { 534 563 bfd_release (abfd, syms); 535 return false;564 return FALSE; 536 565 } 537 566 … … 549 578 bfd_get_symcount (abfd) = num_syms; 550 579 551 cached = ((aout_symbol_type *)552 bfd_zalloc (abfd, 553 bfd_get_symcount (abfd) * sizeof (aout_symbol_type)));554 if (cached == NULL && bfd_get_symcount (abfd)!= 0)555 return false;580 amt = num_syms; 581 amt *= sizeof (aout_symbol_type); 582 cached = (aout_symbol_type *) bfd_zalloc (abfd, amt); 583 if (cached == NULL && num_syms != 0) 584 return FALSE; 556 585 557 586 /* as we march thru the hp symbol table, convert it into a list of … … 580 609 convert_sym_type (sym_pointer, cache_ptr, abfd); 581 610 if (!translate_from_native_sym_flags (abfd, cache_ptr)) 582 return false;611 return FALSE; 583 612 584 613 /********************************************************/ … … 609 638 obj_aout_symbols (abfd) = cached; 610 639 611 return true;640 return TRUE; 612 641 } 613 642 … … 626 655 struct aoutdata *su = &(abfd->tdata.aout_data->a); 627 656 628 cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);629 r_index = bfd_h_get_16 (abfd, bytes->r_index);657 cache_ptr->address = H_GET_32 (abfd, bytes->r_address); 658 r_index = H_GET_16 (abfd, bytes->r_index); 630 659 631 660 switch (bytes->r_type[0]) … … 691 720 } 692 721 693 b oolean722 bfd_boolean 694 723 MY (slurp_reloc_table) (abfd, asect, symbols) 695 724 bfd *abfd; … … 697 726 asymbol **symbols; 698 727 { 699 unsigned intcount;728 bfd_size_type count; 700 729 bfd_size_type reloc_size; 701 730 PTR relocs; … … 707 736 708 737 if (asect->relocation) 709 return true;738 return TRUE; 710 739 711 740 if (asect->flags & SEC_CONSTRUCTOR) 712 return true;741 return TRUE; 713 742 714 743 if (asect == obj_datasec (abfd)) … … 725 754 726 755 bfd_set_error (bfd_error_invalid_operation); 727 return false;756 return FALSE; 728 757 729 758 doit: 730 759 if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0) 731 return false;760 return FALSE; 732 761 each_size = obj_reloc_entry_size (abfd); 733 762 734 763 count = reloc_size / each_size; 735 764 736 reloc_cache = (arelent *) bfd_zalloc (abfd, (size_t) (count * sizeof 737 (arelent))); 765 reloc_cache = (arelent *) bfd_zalloc (abfd, count * sizeof (arelent)); 738 766 if (!reloc_cache && count != 0) 739 return false;767 return FALSE; 740 768 741 769 relocs = (PTR) bfd_alloc (abfd, reloc_size); … … 743 771 { 744 772 bfd_release (abfd, reloc_cache); 745 return false;746 } 747 748 if (bfd_ read (relocs, 1, reloc_size, abfd) != reloc_size)773 return FALSE; 774 } 775 776 if (bfd_bread (relocs, reloc_size, abfd) != reloc_size) 749 777 { 750 778 bfd_release (abfd, relocs); 751 779 bfd_release (abfd, reloc_cache); 752 return false;780 return FALSE; 753 781 } 754 782 … … 760 788 { 761 789 MY (swap_std_reloc_in) (abfd, rptr, cache_ptr, symbols, 762 bfd_get_symcount (abfd));790 (bfd_size_type) bfd_get_symcount (abfd)); 763 791 } 764 792 … … 766 794 asect->relocation = reloc_cache; 767 795 asect->reloc_count = count; 768 return true;796 return TRUE; 769 797 } 770 798 … … 775 803 /************************************************************************/ 776 804 777 long aout_32_get_symtab PARAMS ((bfd * abfd, asymbol ** location)); 778 long aout_32_get_symtab_upper_bound PARAMS ((bfd * abfd)); 779 780 long aout_32_canonicalize_reloc PARAMS ((bfd * abfd, sec_ptr section, 781 arelent ** relptr, 782 asymbol ** symbols)); 805 long aout_32_get_symtab 806 PARAMS ((bfd * abfd, asymbol ** location)); 807 long aout_32_get_symtab_upper_bound 808 PARAMS ((bfd * abfd)); 809 long aout_32_canonicalize_reloc 810 PARAMS ((bfd * abfd, sec_ptr section, arelent ** relptr, 811 asymbol ** symbols)); 783 812 784 813 long -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.