Changeset 609 for branches/GNU/src/binutils/bfd/riscix.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/riscix.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* BFD back-end for RISC iX (Acorn, arm) binaries. 2 Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001 2 Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002 3 3 Free Software Foundation, Inc. 4 4 Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org) … … 56 56 57 57 /* Only a pure OMAGIC file has the minimal header */ 58 #define N_TXTOFF(x) \ 59 ((x).a_info == OMAGIC ? 32 \ 60 : (N_MAGIC(x) == ZMAGIC) ? TARGET_PAGE_SIZE \ 61 : 999) 62 63 #define N_TXTADDR(x) \ 64 (N_MAGIC(x) != ZMAGIC ? 0 /* object file or NMAGIC */ \ 58 #define N_TXTOFF(x) \ 59 ((x).a_info == OMAGIC \ 60 ? 32 \ 61 : (N_MAGIC(x) == ZMAGIC \ 62 ? TARGET_PAGE_SIZE \ 63 : 999)) 64 65 #define N_TXTADDR(x) \ 66 (N_MAGIC(x) != ZMAGIC \ 67 ? (bfd_vma) 0 /* object file or NMAGIC */ \ 65 68 /* Programs with shared libs are loaded at the first page after all the \ 66 69 text segments of the shared library programs. Without looking this \ 67 70 up we can't know exactly what the address will be. A reasonable guess \ 68 is that a_entry will be in the first page of the executable. */ \ 69 : N_SHARED_LIB(x) ? ((x).a_entry & ~(TARGET_PAGE_SIZE - 1)) \ 70 : TEXT_START_ADDR) 71 is that a_entry will be in the first page of the executable. */ \ 72 : (N_SHARED_LIB(x) \ 73 ? ((x).a_entry & ~(bfd_vma) (TARGET_PAGE_SIZE - 1)) \ 74 : (bfd_vma) TEXT_START_ADDR)) 71 75 72 76 #define N_SYMOFF(x) \ … … 80 84 #define DEFAULT_ARCH bfd_arch_arm 81 85 82 #define MY(OP) CAT(riscix_,OP) 86 /* Do not "beautify" the CONCAT* macro args. Traditional C will not 87 remove whitespace added here, and thus will fail to concatenate 88 the tokens. */ 89 #define MY(OP) CONCAT2 (riscix_,OP) 83 90 #define TARGETNAME "a.out-riscix" 84 91 #define N_BADMAG(x) ((((x).a_info & ~007200) != ZMAGIC) && \ … … 91 98 #include "libbfd.h" 92 99 93 #define WRITE_HEADERS(abfd, execp) \94 { \95 bfd_size_type text_size; /* dummy vars */ \96 file_ptr text_end; \97 if (adata(abfd).magic == undecided_magic) \98 NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end); \99 \100 execp->a_syms = bfd_get_symcount (abfd) * EXTERNAL_NLIST_SIZE; \101 execp->a_entry = bfd_get_start_address (abfd); \102 \103 execp->a_trsize = ((obj_textsec (abfd)->reloc_count) * \104 obj_reloc_entry_size (abfd)); \105 execp->a_drsize = ((obj_datasec (abfd)->reloc_count) * \106 obj_reloc_entry_size (abfd)); \107 NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes); \108 \109 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 ) return false;\110 if (bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)\111 != EXEC_BYTES_SIZE)\112 return false;\113 /* Now write out reloc info, followed by syms and strings */ \114 \115 if (bfd_get_outsymbols (abfd) != (asymbol **) NULL \116 && bfd_get_symcount (abfd) != 0) \117 { \100 #define WRITE_HEADERS(abfd, execp) \ 101 { \ 102 bfd_size_type text_size; /* dummy vars */ \ 103 file_ptr text_end; \ 104 if (adata(abfd).magic == undecided_magic) \ 105 NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end); \ 106 \ 107 execp->a_syms = bfd_get_symcount (abfd) * EXTERNAL_NLIST_SIZE; \ 108 execp->a_entry = bfd_get_start_address (abfd); \ 109 \ 110 execp->a_trsize = ((obj_textsec (abfd)->reloc_count) * \ 111 obj_reloc_entry_size (abfd)); \ 112 execp->a_drsize = ((obj_datasec (abfd)->reloc_count) * \ 113 obj_reloc_entry_size (abfd)); \ 114 NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes); \ 115 \ 116 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 \ 117 || bfd_bwrite ((PTR) &exec_bytes, (bfd_size_type) EXEC_BYTES_SIZE, \ 118 abfd) != EXEC_BYTES_SIZE) \ 119 return FALSE; \ 120 /* Now write out reloc info, followed by syms and strings */ \ 121 \ 122 if (bfd_get_outsymbols (abfd) != (asymbol **) NULL \ 123 && bfd_get_symcount (abfd) != 0) \ 124 { \ 118 125 if (bfd_seek (abfd, (file_ptr) (N_SYMOFF(*execp)), SEEK_SET) != 0) \ 119 return false;\120 \121 if (! NAME(aout,write_syms) (abfd)) return false;\122 \126 return FALSE; \ 127 \ 128 if (! NAME(aout,write_syms) (abfd)) return FALSE; \ 129 \ 123 130 if (bfd_seek (abfd, (file_ptr) (N_TRELOFF(*execp)), SEEK_SET) != 0) \ 124 return false;\125 \126 if (! riscix_squirt_out_relocs (abfd, obj_textsec (abfd))) \127 return false;\131 return FALSE; \ 132 \ 133 if (! riscix_squirt_out_relocs (abfd, obj_textsec (abfd))) \ 134 return FALSE; \ 128 135 if (bfd_seek (abfd, (file_ptr) (N_DRELOFF(*execp)), SEEK_SET) != 0) \ 129 return false;\130 \131 if (!NAME(aout,squirt_out_relocs) (abfd, obj_datasec (abfd))) \132 return false;\133 } \136 return FALSE; \ 137 \ 138 if (!NAME(aout,squirt_out_relocs) (abfd, obj_datasec (abfd))) \ 139 return FALSE; \ 140 } \ 134 141 } 135 142 … … 144 151 riscix_fix_pcrel_26 PARAMS ((bfd *, arelent *, asymbol *, PTR, 145 152 asection *, bfd *, char **)); 153 static const bfd_target * 154 MY (object_p) PARAMS ((bfd *)); 155 156 reloc_howto_type * 157 riscix_reloc_type_lookup PARAMS ((bfd *, bfd_reloc_code_real_type)); 158 159 void 160 riscix_swap_std_reloc_out PARAMS ((bfd *, arelent *, struct reloc_std_external *)); 161 162 bfd_boolean 163 riscix_squirt_out_relocs PARAMS ((bfd *, asection *)); 164 165 long 166 MY (canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **, asymbol **)); 167 168 const bfd_target * 169 riscix_some_aout_object_p PARAMS ((bfd *, struct internal_exec *, const bfd_target *(*) (bfd *))); 170 146 171 147 172 static reloc_howto_type riscix_std_reloc_howto[] = { 148 173 /* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone */ 149 HOWTO( 0, 0, 0, 8, false, 0, complain_overflow_bitfield,0,"8", true, 0x000000ff,0x000000ff, false),150 HOWTO( 1, 0, 1, 16, false, 0, complain_overflow_bitfield,0,"16", true, 0x0000ffff,0x0000ffff, false),151 HOWTO( 2, 0, 2, 32, false, 0, complain_overflow_bitfield,0,"32", true, 0xffffffff,0xffffffff, false),152 HOWTO( 3, 2, 3, 26, true, 0, complain_overflow_signed, riscix_fix_pcrel_26 , "ARM26", true, 0x00ffffff,0x00ffffff, false),153 HOWTO( 4, 0, 0, 8, true, 0, complain_overflow_signed, 0,"DISP8", true, 0x000000ff,0x000000ff, true),154 HOWTO( 5, 0, 1, 16, true, 0, complain_overflow_signed, 0,"DISP16", true, 0x0000ffff,0x0000ffff, true),155 HOWTO( 6, 0, 2, 32, true, 0, complain_overflow_signed, 0,"DISP32", true, 0xffffffff,0xffffffff, true),156 HOWTO( 7, 2, 3, 26, false, 0, complain_overflow_signed, riscix_fix_pcrel_26_done, "ARM26D",true,0x00ffffff,0x00ffffff, false),174 HOWTO( 0, 0, 0, 8, FALSE, 0, complain_overflow_bitfield,0,"8", TRUE, 0x000000ff,0x000000ff, FALSE), 175 HOWTO( 1, 0, 1, 16, FALSE, 0, complain_overflow_bitfield,0,"16", TRUE, 0x0000ffff,0x0000ffff, FALSE), 176 HOWTO( 2, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,0,"32", TRUE, 0xffffffff,0xffffffff, FALSE), 177 HOWTO( 3, 2, 3, 26, TRUE, 0, complain_overflow_signed, riscix_fix_pcrel_26 , "ARM26", TRUE, 0x00ffffff,0x00ffffff, FALSE), 178 HOWTO( 4, 0, 0, 8, TRUE, 0, complain_overflow_signed, 0,"DISP8", TRUE, 0x000000ff,0x000000ff, TRUE), 179 HOWTO( 5, 0, 1, 16, TRUE, 0, complain_overflow_signed, 0,"DISP16", TRUE, 0x0000ffff,0x0000ffff, TRUE), 180 HOWTO( 6, 0, 2, 32, TRUE, 0, complain_overflow_signed, 0,"DISP32", TRUE, 0xffffffff,0xffffffff, TRUE), 181 HOWTO( 7, 2, 3, 26, FALSE, 0, complain_overflow_signed, riscix_fix_pcrel_26_done, "ARM26D",TRUE,0x00ffffff,0x00ffffff, FALSE), 157 182 EMPTY_HOWTO (-1), 158 HOWTO( 9, 0, -1, 16, false, 0, complain_overflow_bitfield,0,"NEG16", true, 0x0000ffff,0x0000ffff, false),159 HOWTO( 10, 0, -2, 32, false, 0, complain_overflow_bitfield,0,"NEG32", true, 0xffffffff,0xffffffff, false)183 HOWTO( 9, 0, -1, 16, FALSE, 0, complain_overflow_bitfield,0,"NEG16", TRUE, 0x0000ffff,0x0000ffff, FALSE), 184 HOWTO( 10, 0, -2, 32, FALSE, 0, complain_overflow_bitfield,0,"NEG32", TRUE, 0xffffffff,0xffffffff, FALSE) 160 185 }; 161 186 … … 223 248 flag = bfd_reloc_overflow; 224 249 } 225 else if (relocation & ~ 0x03ffffff)250 else if (relocation & ~ (bfd_vma) 0x03ffffff) 226 251 flag = bfd_reloc_overflow; 227 252 228 253 target &= ~0x00ffffff; 229 254 target |= (relocation >> 2) & 0x00ffffff; 230 bfd_put_32 (abfd, target, (bfd_byte *) data + addr);255 bfd_put_32 (abfd, (bfd_vma) target, (bfd_byte *) data + addr); 231 256 232 257 /* Now the ARM magic... Change the reloc type so that it is marked as done. … … 372 397 } 373 398 374 b oolean399 bfd_boolean 375 400 riscix_squirt_out_relocs (abfd, section) 376 401 bfd *abfd; … … 382 407 383 408 unsigned int count = section->reloc_count; 384 size_t natsize; 385 386 if (count == 0) return true; 409 bfd_size_type natsize; 410 411 if (count == 0) 412 return TRUE; 387 413 388 414 each_size = obj_reloc_entry_size (abfd); 389 natsize = each_size * count; 415 natsize = each_size; 416 natsize *= count; 390 417 native = (unsigned char *) bfd_zalloc (abfd, natsize); 391 418 if (!native) 392 return false;419 return FALSE; 393 420 394 421 generic = section->orelocation; … … 400 427 (struct reloc_std_external *) natptr); 401 428 402 if ( bfd_write ((PTR) native, 1, natsize, abfd) != natsize)403 { 404 bfd_release (abfd, native);405 return false;429 if (bfd_bwrite ((PTR) native, natsize, abfd) != natsize) 430 { 431 bfd_release (abfd, native); 432 return FALSE; 406 433 } 407 434 408 435 bfd_release (abfd, native); 409 return true;436 return TRUE; 410 437 } 411 438 … … 471 498 struct aout_data_struct *rawptr, *oldrawptr; 472 499 const bfd_target *result; 473 474 rawptr = ((struct aout_data_struct *) 475 bfd_zalloc (abfd, sizeof (struct aout_data_struct )));500 bfd_size_type amt = sizeof (struct aout_data_struct); 501 502 rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, amt); 476 503 477 504 if (rawptr == NULL) … … 615 642 const bfd_target *target; 616 643 617 if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) 618 != EXEC_BYTES_SIZE) { 619 if (bfd_get_error () != bfd_error_system_call) 620 bfd_set_error (bfd_error_wrong_format); 621 return 0; 622 } 623 624 exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info); 644 if (bfd_bread ((PTR) &exec_bytes, (bfd_size_type) EXEC_BYTES_SIZE, abfd) 645 != EXEC_BYTES_SIZE) 646 { 647 if (bfd_get_error () != bfd_error_system_call) 648 bfd_set_error (bfd_error_wrong_format); 649 return 0; 650 } 651 652 exec.a_info = H_GET_32 (abfd, exec_bytes.e_info); 625 653 626 654 if (N_BADMAG (exec)) return 0; -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.