Changeset 609 for branches/GNU/src/binutils/bfd/aout-arm.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-arm.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* BFD back-end for raw ARM a.out binaries. 2 Copyright 1994, 1995, 1997, 1998, 1999, 2000 2 Copyright 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002 3 3 Free Software Foundation, Inc. 4 4 Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org) … … 20 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 21 21 22 #define N_TXTADDR(x) \ 23 ((N_MAGIC(x) == NMAGIC) ? 0x8000 : \ 24 (N_MAGIC(x) != ZMAGIC) ? 0 : \ 25 (N_SHARED_LIB(x)) ? ((x).a_entry & ~(TARGET_PAGE_SIZE - 1)) : \ 26 TEXT_START_ADDR) 22 #include "bfd.h" 23 #include "sysdep.h" 24 25 /* Avoid multiple defininitions from aoutx if supporting standarad a.out 26 as well as our own. */ 27 /* Do not "beautify" the CONCAT* macro args. Traditional C will not 28 remove whitespace added here, and thus will fail to concatenate 29 the tokens. */ 30 #define NAME(x,y) CONCAT3 (aoutarm,_32_,y) 31 32 #define N_TXTADDR(x) \ 33 ((N_MAGIC (x) == NMAGIC) \ 34 ? (bfd_vma) 0x8000 \ 35 : ((N_MAGIC (x) != ZMAGIC) \ 36 ? (bfd_vma) 0 \ 37 : ((N_SHARED_LIB (x)) \ 38 ? ((x).a_entry & ~(bfd_vma) (TARGET_PAGE_SIZE - 1)) \ 39 : (bfd_vma) TEXT_START_ADDR))) 27 40 28 41 #define TEXT_START_ADDR 0x8000 … … 31 44 #define DEFAULT_ARCH bfd_arch_arm 32 45 33 #define MY(OP) C AT(aoutarm_,OP)46 #define MY(OP) CONCAT2 (aoutarm_,OP) 34 47 #define N_BADMAG(x) ((((x).a_info & ~007200) != ZMAGIC) && \ 35 48 (((x).a_info & ~006000) != OMAGIC) && \ … … 37 50 #define N_MAGIC(x) ((x).a_info & ~07200) 38 51 39 #include "bfd.h"40 #include "sysdep.h"41 42 #define MYARM(OP) CAT(aoutarm_,OP)43 reloc_howto_type *MYARM(bfd_reloc_type_lookup)44 PARAMS((bfd *, bfd_reloc_code_real_type));45 static boolean MYARM(write_object_contents) PARAMS((bfd *));46 47 /* Avoid multiple defininitions from aoutx if supporting standarad a.out48 as well as our own. */49 #define NAME(x,y) CAT3(aoutarm,_32_,y)50 51 52 #define MY_bfd_reloc_type_lookup aoutarm_bfd_reloc_type_lookup 52 53 … … 54 55 #include "aout/aout64.h" 55 56 56 static bfd_reloc_status_type 57 MY(fix_pcrel_26_done) PARAMS ((bfd *, arelent *, asymbol *, PTR, 58 asection *, bfd *, char **)); 59 60 static bfd_reloc_status_type 61 MY(fix_pcrel_26) PARAMS ((bfd *, arelent *, asymbol *, PTR, 62 asection *, bfd *, char **)); 63 static void MY(swap_std_reloc_in) PARAMS ((bfd *, struct reloc_std_external *, 64 arelent *, asymbol **, 65 bfd_size_type)); 66 void MY(swap_std_reloc_out) PARAMS ((bfd *, arelent *, 67 struct reloc_std_external *)); 57 static bfd_boolean MY(write_object_contents) 58 PARAMS ((bfd *)); 59 static bfd_reloc_status_type MY(fix_pcrel_26_done) 60 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); 61 static bfd_reloc_status_type MY(fix_pcrel_26) 62 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); 63 static void MY(swap_std_reloc_in) 64 PARAMS ((bfd *, struct reloc_std_external *, arelent *, asymbol **, 65 bfd_size_type)); 66 reloc_howto_type *MY(bfd_reloc_type_lookup) 67 PARAMS ((bfd *, bfd_reloc_code_real_type)); 68 reloc_howto_type * MY(reloc_howto) 69 PARAMS ((bfd *, struct reloc_std_external *, int *, int *, int *)); 70 void MY(put_reloc) 71 PARAMS ((bfd *, int, int, bfd_vma, reloc_howto_type *, 72 struct reloc_std_external *)); 73 void MY(relocatable_reloc) 74 PARAMS ((reloc_howto_type *, bfd *, struct reloc_std_external *, bfd_vma *, 75 bfd_vma)); 76 void MY(swap_std_reloc_out) 77 PARAMS ((bfd *, arelent *, struct reloc_std_external *)); 78 68 79 69 80 reloc_howto_type MY(howto_table)[] = 70 {71 /* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask72 pcdone*/73 HOWTO (0, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "8", true,74 0x000000ff, 0x000000ff, false),75 HOWTO (1, 0, 1, 16, false, 0, complain_overflow_bitfield, 0, "16", true,76 0x0000ffff, 0x0000ffff, false),77 HOWTO (2, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "32", true,78 0xffffffff, 0xffffffff, false),79 HOWTO (3, 2, 2, 26, true, 0, complain_overflow_signed, MY(fix_pcrel_26),80 "ARM26", true, 0x00ffffff, 0x00ffffff, true),81 HOWTO (4, 0, 0, 8, true, 0, complain_overflow_signed, 0, "DISP8", true,82 0x000000ff, 0x000000ff, true),83 HOWTO (5, 0, 1, 16, true, 0, complain_overflow_signed, 0, "DISP16", true,84 0x0000ffff, 0x0000ffff, true),85 HOWTO (6, 0, 2, 32, true, 0, complain_overflow_signed, 0, "DISP32", true,86 0xffffffff, 0xffffffff, true),87 HOWTO (7, 2, 2, 26, false, 0, complain_overflow_signed,88 MY(fix_pcrel_26_done), "ARM26D", true, 0x0, 0x0,89 false),90 EMPTY_HOWTO (-1),91 HOWTO (9, 0, -1, 16, false, 0, complain_overflow_bitfield, 0, "NEG16", true,92 0x0000ffff, 0x0000ffff, false),93 HOWTO (10, 0, -2, 32, false, 0, complain_overflow_bitfield, 0, "NEG32", true,94 0xffffffff, 0xffffffff, false)95 };81 { 82 /* Type rs size bsz pcrel bitpos ovrf sf name part_inpl 83 readmask setmask pcdone. */ 84 HOWTO (0, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, 0, "8", TRUE, 85 0x000000ff, 0x000000ff, FALSE), 86 HOWTO (1, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, 0, "16", TRUE, 87 0x0000ffff, 0x0000ffff, FALSE), 88 HOWTO (2, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, 0, "32", TRUE, 89 0xffffffff, 0xffffffff, FALSE), 90 HOWTO (3, 2, 2, 26, TRUE, 0, complain_overflow_signed, MY(fix_pcrel_26), 91 "ARM26", TRUE, 0x00ffffff, 0x00ffffff, TRUE), 92 HOWTO (4, 0, 0, 8, TRUE, 0, complain_overflow_signed, 0, "DISP8", TRUE, 93 0x000000ff, 0x000000ff, TRUE), 94 HOWTO (5, 0, 1, 16, TRUE, 0, complain_overflow_signed, 0, "DISP16", TRUE, 95 0x0000ffff, 0x0000ffff, TRUE), 96 HOWTO (6, 0, 2, 32, TRUE, 0, complain_overflow_signed, 0, "DISP32", TRUE, 97 0xffffffff, 0xffffffff, TRUE), 98 HOWTO (7, 2, 2, 26, FALSE, 0, complain_overflow_signed, 99 MY(fix_pcrel_26_done), "ARM26D", TRUE, 0x0, 0x0, 100 FALSE), 101 EMPTY_HOWTO (-1), 102 HOWTO (9, 0, -1, 16, FALSE, 0, complain_overflow_bitfield, 0, "NEG16", TRUE, 103 0x0000ffff, 0x0000ffff, FALSE), 104 HOWTO (10, 0, -2, 32, FALSE, 0, complain_overflow_bitfield, 0, "NEG32", TRUE, 105 0xffffffff, 0xffffffff, FALSE) 106 }; 96 107 97 108 #define RELOC_ARM_BITS_NEG_BIG ((unsigned int) 0x08) … … 149 160 int r_extern; 150 161 int r_index; 151 longvalue;162 bfd_vma value; 152 163 reloc_howto_type *howto; 153 164 struct reloc_std_external *reloc; … … 158 169 159 170 PUT_WORD (abfd, value, reloc->r_address); 160 r_length = howto->size ; /* Size as a power of two */ 171 /* Size as a power of two. */ 172 r_length = howto->size; 161 173 162 174 /* Special case for branch relocations. */ … … 164 176 r_length = 3; 165 177 166 r_pcrel = howto->type & 4; /* PC Relative done? */ 167 r_neg = howto->type & 8; /* Negative relocation */ 178 r_pcrel = howto->type & 4; /* PC Relative done? */ 179 r_neg = howto->type & 8; /* Negative relocation. */ 180 168 181 if (bfd_header_big_endian (abfd)) 169 182 { … … 256 269 bfd_vma relocation; 257 270 bfd_size_type addr = reloc_entry->address; 258 longtarget = bfd_get_32 (abfd, (bfd_byte *) data + addr);271 bfd_vma target = bfd_get_32 (abfd, (bfd_byte *) data + addr); 259 272 bfd_reloc_status_type flag = bfd_reloc_ok; 260 273 261 /* If this is an undefined symbol, return error */274 /* If this is an undefined symbol, return error. */ 262 275 if (symbol->section == &bfd_und_section 263 276 && (symbol->flags & BSF_WEAK) == 0) … … 271 284 272 285 relocation = (target & 0x00ffffff) << 2; 273 relocation = (relocation ^ 0x02000000) - 0x02000000; /* Sign extend */286 relocation = (relocation ^ 0x02000000) - 0x02000000; /* Sign extend. */ 274 287 relocation += symbol->value; 275 288 relocation += symbol->section->output_section->vma; … … 282 295 return bfd_reloc_overflow; 283 296 284 /* Check for overflow */297 /* Check for overflow. */ 285 298 if (relocation & 0x02000000) 286 299 { … … 288 301 flag = bfd_reloc_overflow; 289 302 } 290 else if (relocation & ~ 0x03ffffff)303 else if (relocation & ~ (bfd_vma) 0x03ffffff) 291 304 flag = bfd_reloc_overflow; 292 305 293 target &= ~ 0x00ffffff;306 target &= ~ (bfd_vma) 0x00ffffff; 294 307 target |= (relocation >> 2) & 0x00ffffff; 295 308 bfd_put_32 (abfd, target, (bfd_byte *) data + addr); … … 314 327 code = BFD_RELOC_32; 315 328 break; 316 default: return (CONST struct reloc_howto_struct *) 0; 329 default: 330 return (const struct reloc_howto_struct *) 0; 317 331 } 318 332 … … 325 339 ASTD (BFD_RELOC_16_PCREL, 5); 326 340 ASTD (BFD_RELOC_32_PCREL, 6); 327 default: return (CONST struct reloc_howto_struct *) 0; 341 default: 342 return (const struct reloc_howto_struct *) 0; 328 343 } 329 344 } … … 351 366 struct aoutdata *su = &(abfd->tdata.aout_data->a); 352 367 353 cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);368 cache_ptr->address = H_GET_32 (abfd, bytes->r_address); 354 369 355 370 cache_ptr->howto = MY_reloc_howto (abfd, bytes, r_index, r_extern, r_pcrel); … … 420 435 { 421 436 /* Whoops, looked like an abs symbol, but is really an offset 422 from the abs section */437 from the abs section. */ 423 438 r_index = 0; 424 439 r_extern = 0; … … 426 441 else 427 442 { 428 /* Fill in symbol */443 /* Fill in symbol. */ 429 444 r_extern = 1; 430 445 r_index = (*(g->sym_ptr_ptr))->KEEPIT; … … 433 448 else 434 449 { 435 /* Just an ordinary section */450 /* Just an ordinary section. */ 436 451 r_extern = 0; 437 452 r_index = output_section->target_index; 438 453 } 439 454 440 /* now the fun stuff*/455 /* Now the fun stuff. */ 441 456 if (bfd_header_big_endian (abfd)) 442 457 { … … 470 485 471 486 const bfd_target aout_arm_little_vec = 472 {473 "a.out-arm-little", /* name */474 bfd_target_aout_flavour,475 BFD_ENDIAN_LITTLE, /* target byte order (little) */476 BFD_ENDIAN_LITTLE, /* target headers byte order (little) */477 (HAS_RELOC | EXEC_P | /* object flags */478 HAS_LINENO | HAS_DEBUG |479 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),480 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),481 MY_symbol_leading_char,482 AR_PAD_CHAR, /* ar_pad_char */483 15, /* ar_max_namelen */484 bfd_getl64, bfd_getl_signed_64, bfd_putl64,485 486 bfd_getl16, bfd_getl_signed_16, bfd_putl16,/* data */487 bfd_getl64, bfd_getl_signed_64, bfd_putl64,488 489 bfd_getl16, bfd_getl_signed_16, bfd_putl16,/* hdrs */490 {_bfd_dummy_target, MY_object_p, 491 492 {bfd_false, MY_mkobject, 493 494 {bfd_false, MY_write_object_contents, 495 496 497 498 499 500 501 502 503 504 505 506 507 & aout_arm_big_vec,508 509 (PTR) MY_backend_data,510 };487 { 488 "a.out-arm-little", /* name */ 489 bfd_target_aout_flavour, 490 BFD_ENDIAN_LITTLE, /* target byte order (little) */ 491 BFD_ENDIAN_LITTLE, /* target headers byte order (little) */ 492 (HAS_RELOC | EXEC_P | /* object flags */ 493 HAS_LINENO | HAS_DEBUG | 494 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), 495 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA), 496 MY_symbol_leading_char, 497 AR_PAD_CHAR, /* ar_pad_char */ 498 15, /* ar_max_namelen */ 499 bfd_getl64, bfd_getl_signed_64, bfd_putl64, 500 bfd_getl32, bfd_getl_signed_32, bfd_putl32, 501 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */ 502 bfd_getl64, bfd_getl_signed_64, bfd_putl64, 503 bfd_getl32, bfd_getl_signed_32, bfd_putl32, 504 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */ 505 {_bfd_dummy_target, MY_object_p, /* bfd_check_format */ 506 bfd_generic_archive_p, MY_core_file_p}, 507 {bfd_false, MY_mkobject, /* bfd_set_format */ 508 _bfd_generic_mkarchive, bfd_false}, 509 {bfd_false, MY_write_object_contents, /* bfd_write_contents */ 510 _bfd_write_archive_contents, bfd_false}, 511 512 BFD_JUMP_TABLE_GENERIC (MY), 513 BFD_JUMP_TABLE_COPY (MY), 514 BFD_JUMP_TABLE_CORE (MY), 515 BFD_JUMP_TABLE_ARCHIVE (MY), 516 BFD_JUMP_TABLE_SYMBOLS (MY), 517 BFD_JUMP_TABLE_RELOCS (MY), 518 BFD_JUMP_TABLE_WRITE (MY), 519 BFD_JUMP_TABLE_LINK (MY), 520 BFD_JUMP_TABLE_DYNAMIC (MY), 521 522 & aout_arm_big_vec, 523 524 (PTR) MY_backend_data, 525 }; 511 526 512 527 const bfd_target aout_arm_big_vec = 513 {514 "a.out-arm-big",/* name */515 bfd_target_aout_flavour,516 BFD_ENDIAN_BIG, /* target byte order (big) */517 BFD_ENDIAN_BIG, /* target headers byte order (big) */518 (HAS_RELOC | EXEC_P | /* object flags */519 HAS_LINENO | HAS_DEBUG |520 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),521 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),522 MY_symbol_leading_char,523 AR_PAD_CHAR,/* ar_pad_char */524 15,/* ar_max_namelen */525 bfd_getb64, bfd_getb_signed_64, bfd_putb64,526 527 bfd_getb16, bfd_getb_signed_16, bfd_putb16,/* data */528 bfd_getb64, bfd_getb_signed_64, bfd_putb64,529 530 bfd_getb16, bfd_getb_signed_16, bfd_putb16,/* hdrs */531 {_bfd_dummy_target, MY_object_p, 532 533 {bfd_false, MY_mkobject, 534 535 {bfd_false, MY_write_object_contents, 536 537 538 539 540 541 542 543 544 545 546 547 548 & aout_arm_little_vec,549 550 (PTR) MY_backend_data,551 };528 { 529 "a.out-arm-big", /* name */ 530 bfd_target_aout_flavour, 531 BFD_ENDIAN_BIG, /* target byte order (big) */ 532 BFD_ENDIAN_BIG, /* target headers byte order (big) */ 533 (HAS_RELOC | EXEC_P | /* object flags */ 534 HAS_LINENO | HAS_DEBUG | 535 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), 536 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA), 537 MY_symbol_leading_char, 538 AR_PAD_CHAR, /* ar_pad_char */ 539 15, /* ar_max_namelen */ 540 bfd_getb64, bfd_getb_signed_64, bfd_putb64, 541 bfd_getb32, bfd_getb_signed_32, bfd_putb32, 542 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */ 543 bfd_getb64, bfd_getb_signed_64, bfd_putb64, 544 bfd_getb32, bfd_getb_signed_32, bfd_putb32, 545 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ 546 {_bfd_dummy_target, MY_object_p, /* bfd_check_format */ 547 bfd_generic_archive_p, MY_core_file_p}, 548 {bfd_false, MY_mkobject, /* bfd_set_format */ 549 _bfd_generic_mkarchive, bfd_false}, 550 {bfd_false, MY_write_object_contents, /* bfd_write_contents */ 551 _bfd_write_archive_contents, bfd_false}, 552 553 BFD_JUMP_TABLE_GENERIC (MY), 554 BFD_JUMP_TABLE_COPY (MY), 555 BFD_JUMP_TABLE_CORE (MY), 556 BFD_JUMP_TABLE_ARCHIVE (MY), 557 BFD_JUMP_TABLE_SYMBOLS (MY), 558 BFD_JUMP_TABLE_RELOCS (MY), 559 BFD_JUMP_TABLE_WRITE (MY), 560 BFD_JUMP_TABLE_LINK (MY), 561 BFD_JUMP_TABLE_DYNAMIC (MY), 562 563 & aout_arm_little_vec, 564 565 (PTR) MY_backend_data, 566 }; -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.