Changeset 609 for branches/GNU/src/binutils/bfd/coff-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/coff-arm.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* BFD back-end for ARM COFF files. 2 2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 3 2000, 2001 3 2000, 2001, 2002 4 4 Free Software Foundation, Inc. 5 5 Written by Cygnus Support. … … 37 37 /* Macros for manipulation the bits in the flags field of the coff data 38 38 structure. */ 39 #define APCS_26_FLAG( abfd ) (coff_data (abfd)->flags & F_APCS_26) 40 #define APCS_FLOAT_FLAG( abfd ) (coff_data (abfd)->flags & F_APCS_FLOAT) 41 #define PIC_FLAG( abfd ) (coff_data (abfd)->flags & F_PIC) 42 #define APCS_SET( abfd ) (coff_data (abfd)->flags & F_APCS_SET) 43 #define SET_APCS_FLAGS( abfd, flgs) (coff_data (abfd)->flags = \ 44 (coff_data (abfd)->flags & ~ (F_APCS_26 | F_APCS_FLOAT | F_PIC)) \ 45 | (flgs | F_APCS_SET)) 46 #define INTERWORK_FLAG( abfd ) (coff_data (abfd)->flags & F_INTERWORK) 47 #define INTERWORK_SET( abfd ) (coff_data (abfd)->flags & F_INTERWORK_SET) 48 #define SET_INTERWORK_FLAG( abfd, flg ) (coff_data (abfd)->flags = \ 49 (coff_data (abfd)->flags & ~ F_INTERWORK) \ 50 | (flg | F_INTERWORK_SET)) 39 #define APCS_26_FLAG(abfd) \ 40 (coff_data (abfd)->flags & F_APCS_26) 41 42 #define APCS_FLOAT_FLAG(abfd) \ 43 (coff_data (abfd)->flags & F_APCS_FLOAT) 44 45 #define PIC_FLAG(abfd) \ 46 (coff_data (abfd)->flags & F_PIC) 47 48 #define APCS_SET(abfd) \ 49 (coff_data (abfd)->flags & F_APCS_SET) 50 51 #define SET_APCS_FLAGS(abfd, flgs) \ 52 do \ 53 { \ 54 coff_data (abfd)->flags &= ~(F_APCS_26 | F_APCS_FLOAT | F_PIC); \ 55 coff_data (abfd)->flags |= (flgs) | F_APCS_SET; \ 56 } \ 57 while (0) 58 59 #define INTERWORK_FLAG(abfd) \ 60 (coff_data (abfd)->flags & F_INTERWORK) 61 62 #define INTERWORK_SET(abfd) \ 63 (coff_data (abfd)->flags & F_INTERWORK_SET) 64 65 #define SET_INTERWORK_FLAG(abfd, flg) \ 66 do \ 67 { \ 68 coff_data (abfd)->flags &= ~F_INTERWORK; \ 69 coff_data (abfd)->flags |= (flg) | F_INTERWORK_SET; \ 70 } \ 71 while (0) 51 72 52 73 #ifndef NUM_ELEM … … 60 81 61 82 /* Forward declarations for stupid compilers. */ 62 static b oolean coff_arm_relocate_section83 static bfd_boolean coff_arm_relocate_section 63 84 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 64 85 struct internal_reloc *, struct internal_syment *, asection **)); … … 67 88 static bfd_reloc_status_type aoutarm_fix_pcrel_26 68 89 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); 90 #ifndef ARM_WINCE 69 91 static bfd_reloc_status_type coff_thumb_pcrel_23 70 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));71 static bfd_reloc_status_type coff_thumb_pcrel_1272 92 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); 73 93 static bfd_reloc_status_type coff_thumb_pcrel_9 74 94 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); 95 static insn32 insert_thumb_branch 96 PARAMS ((insn32, int)); 97 #endif 98 static bfd_reloc_status_type coff_thumb_pcrel_12 99 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); 75 100 static bfd_reloc_status_type coff_arm_reloc 76 101 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); 77 static b oolean coff_arm_adjust_symndx102 static bfd_boolean coff_arm_adjust_symndx 78 103 PARAMS ((bfd *, struct bfd_link_info *, bfd *, 79 asection *, struct internal_reloc *, b oolean *));104 asection *, struct internal_reloc *, bfd_boolean *)); 80 105 static reloc_howto_type * coff_arm_rtype_to_howto 81 106 PARAMS ((bfd *, asection *, struct internal_reloc *, 82 struct coff_link_hash_entry *, struct internal_syment *, bfd_vma *)); 107 struct coff_link_hash_entry *, struct internal_syment *, 108 bfd_vma *)); 83 109 static bfd_reloc_status_type coff_thumb_pcrel_common 84 110 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **, 85 111 thumb_pcrel_branchtype)); 86 static CONSTstruct reloc_howto_struct * coff_arm_reloc_type_lookup112 static const struct reloc_howto_struct * coff_arm_reloc_type_lookup 87 113 PARAMS ((bfd *, bfd_reloc_code_real_type)); 88 114 static struct bfd_link_hash_table * coff_arm_link_hash_table_create 89 115 PARAMS ((bfd *)); 90 static insn32 insert_thumb_branch91 PARAMS ((insn32, int));92 116 static struct coff_link_hash_entry * find_thumb_glue 93 PARAMS ((struct bfd_link_info *, CONSTchar *, bfd *));117 PARAMS ((struct bfd_link_info *, const char *, bfd *)); 94 118 static struct coff_link_hash_entry * find_arm_glue 95 PARAMS ((struct bfd_link_info *, CONSTchar *, bfd *));119 PARAMS ((struct bfd_link_info *, const char *, bfd *)); 96 120 #ifndef COFF_IMAGE_WITH_PE 97 121 static void record_arm_to_thumb_glue 98 122 PARAMS ((struct bfd_link_info *, struct coff_link_hash_entry *)); 123 #ifndef ARM_WINCE 99 124 static void record_thumb_to_arm_glue 100 125 PARAMS ((struct bfd_link_info *, struct coff_link_hash_entry *)); 101 126 #endif 102 static boolean coff_arm_merge_private_bfd_data 127 #endif 128 static bfd_boolean coff_arm_merge_private_bfd_data 103 129 PARAMS ((bfd *, bfd *)); 104 static b oolean coff_arm_print_private_bfd_data130 static bfd_boolean coff_arm_print_private_bfd_data 105 131 PARAMS ((bfd *, PTR)); 106 static b oolean _bfd_coff_arm_set_private_flags132 static bfd_boolean _bfd_coff_arm_set_private_flags 107 133 PARAMS ((bfd *, flagword)); 108 static b oolean coff_arm_copy_private_bfd_data134 static bfd_boolean coff_arm_copy_private_bfd_data 109 135 PARAMS ((bfd *, bfd *)); 110 static b oolean coff_arm_is_local_label_name136 static bfd_boolean coff_arm_is_local_label_name 111 137 PARAMS ((bfd *, const char *)); 112 static b oolean coff_arm_link_output_has_begun138 static bfd_boolean coff_arm_link_output_has_begun 113 139 PARAMS ((bfd *, struct coff_final_link_info *)); 114 static b oolean coff_arm_final_link_postscript140 static bfd_boolean coff_arm_final_link_postscript 115 141 PARAMS ((bfd *, struct coff_final_link_info *)); 142 static void arm_emit_base_file_entry 143 PARAMS ((struct bfd_link_info *, bfd *, asection *, bfd_vma)); 116 144 117 145 /* The linker script knows the section names for placement. 118 146 The entry_names are used to do simple name mangling on the stubs. 119 147 Given a function name, and its type, the stub can be found. The 120 name can be changed. The only requirement is the %s be present. 121 */ 148 name can be changed. The only requirement is the %s be present. */ 122 149 123 150 #define THUMB2ARM_GLUE_SECTION_NAME ".glue_7t" … … 128 155 129 156 /* Used by the assembler. */ 157 130 158 static bfd_reloc_status_type 131 159 coff_arm_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, … … 145 173 diff = reloc_entry->addend; 146 174 147 #define DOIT(x) \ 148 x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask)) 175 #define DOIT(x) \ 176 x = ((x & ~howto->dst_mask) \ 177 | (((x & howto->src_mask) + diff) & howto->dst_mask)) 149 178 150 179 if (diff != 0) … … 167 196 short x = bfd_get_16 (abfd, addr); 168 197 DOIT (x); 169 bfd_put_16 (abfd, x, addr);198 bfd_put_16 (abfd, (bfd_vma) x, addr); 170 199 } 171 200 break; … … 175 204 long x = bfd_get_32 (abfd, addr); 176 205 DOIT (x); 177 bfd_put_32 (abfd, x, addr);206 bfd_put_32 (abfd, (bfd_vma) x, addr); 178 207 } 179 208 break; … … 196 225 197 226 #ifndef PCRELOFFSET 198 #define PCRELOFFSET true227 #define PCRELOFFSET TRUE 199 228 #endif 200 229 … … 234 263 235 264 static reloc_howto_type aoutarm_std_reloc_howto[] = 236 { 237 /* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone */ 265 { 238 266 #ifdef ARM_WINCE 239 EMPTY_HOWTO (-1),240 HOWTO (ARM_32,241 0,242 2,243 32,244 false,245 0,246 complain_overflow_bitfield,247 coff_arm_reloc,248 "ARM_32",249 true,250 0xffffffff,251 0xffffffff,252 PCRELOFFSET),253 HOWTO (ARM_RVA32,254 0,255 2,256 32,257 false,258 0,259 complain_overflow_bitfield,260 coff_arm_reloc,261 "ARM_RVA32",262 true,263 0xffffffff,264 0xffffffff,265 PCRELOFFSET),266 HOWTO (ARM_26,267 2,268 2,269 24,270 true,271 0,272 complain_overflow_signed,273 aoutarm_fix_pcrel_26 ,274 "ARM_26",275 false,276 0x00ffffff,277 0x00ffffff,278 PCRELOFFSET),279 HOWTO (ARM_THUMB12,280 1,281 1,282 11,283 true,284 0,285 complain_overflow_signed,286 coff_thumb_pcrel_12 ,287 "ARM_THUMB12",288 false,289 0x000007ff,290 0x000007ff,291 PCRELOFFSET),292 HOWTO (ARM_26D,293 2,294 2,295 24,296 false,297 0,298 complain_overflow_dont,299 aoutarm_fix_pcrel_26_done,300 "ARM_26D",301 true,302 0x00ffffff,303 0x0,304 false),305 EMPTY_HOWTO (-1),306 EMPTY_HOWTO (-1),307 EMPTY_HOWTO (-1),308 EMPTY_HOWTO (-1),309 EMPTY_HOWTO (-1),310 EMPTY_HOWTO (-1),311 EMPTY_HOWTO (-1),312 EMPTY_HOWTO (-1),313 HOWTO (ARM_SECTION,314 0,315 1,316 16,317 false,318 0,319 complain_overflow_bitfield,320 coff_arm_reloc,321 "ARM_16",322 true,323 0x0000ffff,324 0x0000ffff,325 PCRELOFFSET),326 HOWTO (ARM_SECREL,327 0,328 2,329 32,330 false,331 0,332 complain_overflow_bitfield,333 coff_arm_reloc,334 "ARM_32",335 true,336 0xffffffff,337 0xffffffff,338 PCRELOFFSET),267 EMPTY_HOWTO (-1), 268 HOWTO (ARM_32, 269 0, 270 2, 271 32, 272 FALSE, 273 0, 274 complain_overflow_bitfield, 275 coff_arm_reloc, 276 "ARM_32", 277 TRUE, 278 0xffffffff, 279 0xffffffff, 280 PCRELOFFSET), 281 HOWTO (ARM_RVA32, 282 0, 283 2, 284 32, 285 FALSE, 286 0, 287 complain_overflow_bitfield, 288 coff_arm_reloc, 289 "ARM_RVA32", 290 TRUE, 291 0xffffffff, 292 0xffffffff, 293 PCRELOFFSET), 294 HOWTO (ARM_26, 295 2, 296 2, 297 24, 298 TRUE, 299 0, 300 complain_overflow_signed, 301 aoutarm_fix_pcrel_26 , 302 "ARM_26", 303 FALSE, 304 0x00ffffff, 305 0x00ffffff, 306 PCRELOFFSET), 307 HOWTO (ARM_THUMB12, 308 1, 309 1, 310 11, 311 TRUE, 312 0, 313 complain_overflow_signed, 314 coff_thumb_pcrel_12 , 315 "ARM_THUMB12", 316 FALSE, 317 0x000007ff, 318 0x000007ff, 319 PCRELOFFSET), 320 HOWTO (ARM_26D, 321 2, 322 2, 323 24, 324 FALSE, 325 0, 326 complain_overflow_dont, 327 aoutarm_fix_pcrel_26_done, 328 "ARM_26D", 329 TRUE, 330 0x00ffffff, 331 0x0, 332 FALSE), 333 EMPTY_HOWTO (-1), 334 EMPTY_HOWTO (-1), 335 EMPTY_HOWTO (-1), 336 EMPTY_HOWTO (-1), 337 EMPTY_HOWTO (-1), 338 EMPTY_HOWTO (-1), 339 EMPTY_HOWTO (-1), 340 EMPTY_HOWTO (-1), 341 HOWTO (ARM_SECTION, 342 0, 343 1, 344 16, 345 FALSE, 346 0, 347 complain_overflow_bitfield, 348 coff_arm_reloc, 349 "ARM_16", 350 TRUE, 351 0x0000ffff, 352 0x0000ffff, 353 PCRELOFFSET), 354 HOWTO (ARM_SECREL, 355 0, 356 2, 357 32, 358 FALSE, 359 0, 360 complain_overflow_bitfield, 361 coff_arm_reloc, 362 "ARM_32", 363 TRUE, 364 0xffffffff, 365 0xffffffff, 366 PCRELOFFSET), 339 367 #else /* not ARM_WINCE */ 340 HOWTO(ARM_8,/* type */341 0, /* rightshift */342 0, /* size */343 8, /* bitsize */344 false,/* pc_relative */345 0, /* bitpos */346 complain_overflow_bitfield, /* complain_on_overflow */347 coff_arm_reloc,/* special_function */348 "ARM_8", /* name */349 true,/* partial_inplace */350 0x000000ff, /* src_mask */351 0x000000ff, /* dst_mask */352 PCRELOFFSET /* pcrel_offset */),353 HOWTO(ARM_16,354 0,355 1,356 16,357 false,358 0,359 complain_overflow_bitfield,360 coff_arm_reloc,361 "ARM_16",362 true,363 0x0000ffff,364 0x0000ffff,365 PCRELOFFSET),366 HOWTO(ARM_32,367 0,368 2,369 32,370 false,371 0,372 complain_overflow_bitfield,373 coff_arm_reloc,374 "ARM_32",375 true,376 0xffffffff,377 0xffffffff,378 PCRELOFFSET),379 HOWTO(ARM_26,380 2,381 2,382 24,383 true,384 0,385 complain_overflow_signed,386 aoutarm_fix_pcrel_26 ,387 "ARM_26",388 false,389 0x00ffffff,390 0x00ffffff,391 PCRELOFFSET),392 HOWTO(ARM_DISP8,393 0,394 0,395 8,396 true,397 0,398 complain_overflow_signed,399 coff_arm_reloc,400 "ARM_DISP8",401 true,402 0x000000ff,403 0x000000ff,404 true),405 HOWTO(ARM_DISP16,406 0,407 1,408 16,409 true,410 0,411 complain_overflow_signed,412 coff_arm_reloc,413 "ARM_DISP16",414 true,415 0x0000ffff,416 0x0000ffff,417 true),418 HOWTO(ARM_DISP32,419 0,420 2,421 32,422 true,423 0,424 complain_overflow_signed,425 426 "ARM_DISP32",427 true,428 0xffffffff,429 0xffffffff,430 true),431 HOWTO(ARM_26D,432 2,433 2,434 24,435 false,436 0,437 complain_overflow_dont,438 aoutarm_fix_pcrel_26_done,439 "ARM_26D",440 true,441 0x00ffffff,442 0x0,443 false),444 /* 8 is unused */445 EMPTY_HOWTO (-1),446 HOWTO(ARM_NEG16,447 0,448 -1,449 16,450 false,451 0,452 complain_overflow_bitfield,453 coff_arm_reloc,454 "ARM_NEG16",455 true,456 0x0000ffff,457 0x0000ffff,458 false),459 HOWTO(ARM_NEG32,460 0,461 -2,462 32,463 false,464 0,465 complain_overflow_bitfield,466 coff_arm_reloc,467 "ARM_NEG32",468 true,469 0xffffffff,470 0xffffffff,471 false),472 HOWTO(ARM_RVA32,473 0,474 2,475 32,476 false,477 0,478 complain_overflow_bitfield,479 coff_arm_reloc,480 "ARM_RVA32",481 true,482 0xffffffff,483 0xffffffff,484 PCRELOFFSET),485 HOWTO(ARM_THUMB9,486 1,487 1,488 8,489 true,490 0,491 complain_overflow_signed,492 coff_thumb_pcrel_9 ,493 "ARM_THUMB9",494 false,495 0x000000ff,496 0x000000ff,497 PCRELOFFSET),498 HOWTO(ARM_THUMB12,499 1,500 1,501 11,502 true,503 0,504 complain_overflow_signed,505 coff_thumb_pcrel_12 ,506 "ARM_THUMB12",507 false,508 0x000007ff,509 0x000007ff,510 PCRELOFFSET),511 HOWTO(ARM_THUMB23,512 1,513 2,514 22,515 true,516 0,517 complain_overflow_signed,518 coff_thumb_pcrel_23 ,519 "ARM_THUMB23",520 false,521 0x07ff07ff,522 0x07ff07ff,523 PCRELOFFSET)368 HOWTO (ARM_8, /* type */ 369 0, /* rightshift */ 370 0, /* size */ 371 8, /* bitsize */ 372 FALSE, /* pc_relative */ 373 0, /* bitpos */ 374 complain_overflow_bitfield, /* complain_on_overflow */ 375 coff_arm_reloc, /* special_function */ 376 "ARM_8", /* name */ 377 TRUE, /* partial_inplace */ 378 0x000000ff, /* src_mask */ 379 0x000000ff, /* dst_mask */ 380 PCRELOFFSET /* pcrel_offset */), 381 HOWTO (ARM_16, 382 0, 383 1, 384 16, 385 FALSE, 386 0, 387 complain_overflow_bitfield, 388 coff_arm_reloc, 389 "ARM_16", 390 TRUE, 391 0x0000ffff, 392 0x0000ffff, 393 PCRELOFFSET), 394 HOWTO (ARM_32, 395 0, 396 2, 397 32, 398 FALSE, 399 0, 400 complain_overflow_bitfield, 401 coff_arm_reloc, 402 "ARM_32", 403 TRUE, 404 0xffffffff, 405 0xffffffff, 406 PCRELOFFSET), 407 HOWTO (ARM_26, 408 2, 409 2, 410 24, 411 TRUE, 412 0, 413 complain_overflow_signed, 414 aoutarm_fix_pcrel_26 , 415 "ARM_26", 416 FALSE, 417 0x00ffffff, 418 0x00ffffff, 419 PCRELOFFSET), 420 HOWTO (ARM_DISP8, 421 0, 422 0, 423 8, 424 TRUE, 425 0, 426 complain_overflow_signed, 427 coff_arm_reloc, 428 "ARM_DISP8", 429 TRUE, 430 0x000000ff, 431 0x000000ff, 432 TRUE), 433 HOWTO (ARM_DISP16, 434 0, 435 1, 436 16, 437 TRUE, 438 0, 439 complain_overflow_signed, 440 coff_arm_reloc, 441 "ARM_DISP16", 442 TRUE, 443 0x0000ffff, 444 0x0000ffff, 445 TRUE), 446 HOWTO (ARM_DISP32, 447 0, 448 2, 449 32, 450 TRUE, 451 0, 452 complain_overflow_signed, 453 coff_arm_reloc, 454 "ARM_DISP32", 455 TRUE, 456 0xffffffff, 457 0xffffffff, 458 TRUE), 459 HOWTO (ARM_26D, 460 2, 461 2, 462 24, 463 FALSE, 464 0, 465 complain_overflow_dont, 466 aoutarm_fix_pcrel_26_done, 467 "ARM_26D", 468 TRUE, 469 0x00ffffff, 470 0x0, 471 FALSE), 472 /* 8 is unused */ 473 EMPTY_HOWTO (-1), 474 HOWTO (ARM_NEG16, 475 0, 476 -1, 477 16, 478 FALSE, 479 0, 480 complain_overflow_bitfield, 481 coff_arm_reloc, 482 "ARM_NEG16", 483 TRUE, 484 0x0000ffff, 485 0x0000ffff, 486 FALSE), 487 HOWTO (ARM_NEG32, 488 0, 489 -2, 490 32, 491 FALSE, 492 0, 493 complain_overflow_bitfield, 494 coff_arm_reloc, 495 "ARM_NEG32", 496 TRUE, 497 0xffffffff, 498 0xffffffff, 499 FALSE), 500 HOWTO (ARM_RVA32, 501 0, 502 2, 503 32, 504 FALSE, 505 0, 506 complain_overflow_bitfield, 507 coff_arm_reloc, 508 "ARM_RVA32", 509 TRUE, 510 0xffffffff, 511 0xffffffff, 512 PCRELOFFSET), 513 HOWTO (ARM_THUMB9, 514 1, 515 1, 516 8, 517 TRUE, 518 0, 519 complain_overflow_signed, 520 coff_thumb_pcrel_9 , 521 "ARM_THUMB9", 522 FALSE, 523 0x000000ff, 524 0x000000ff, 525 PCRELOFFSET), 526 HOWTO (ARM_THUMB12, 527 1, 528 1, 529 11, 530 TRUE, 531 0, 532 complain_overflow_signed, 533 coff_thumb_pcrel_12 , 534 "ARM_THUMB12", 535 FALSE, 536 0x000007ff, 537 0x000007ff, 538 PCRELOFFSET), 539 HOWTO (ARM_THUMB23, 540 1, 541 2, 542 22, 543 TRUE, 544 0, 545 complain_overflow_signed, 546 coff_thumb_pcrel_23 , 547 "ARM_THUMB23", 548 FALSE, 549 0x07ff07ff, 550 0x07ff07ff, 551 PCRELOFFSET) 524 552 #endif /* not ARM_WINCE */ 525 };553 }; 526 554 527 555 #define NUM_RELOCS NUM_ELEM (aoutarm_std_reloc_howto) 528 556 529 557 #ifdef COFF_WITH_PE 530 /* Return true if this relocation should 558 static bfd_boolean in_reloc_p PARAMS ((bfd *, reloc_howto_type *)); 559 /* Return TRUE if this relocation should 531 560 appear in the output .reloc section. */ 532 561 533 static b oolean562 static bfd_boolean 534 563 in_reloc_p (abfd, howto) 535 564 bfd * abfd ATTRIBUTE_UNUSED; … … 569 598 return howto; 570 599 } 600 571 601 /* Used by the assembler. */ 572 602 … … 604 634 bfd_reloc_status_type flag = bfd_reloc_ok; 605 635 606 /* If this is an undefined symbol, return error */636 /* If this is an undefined symbol, return error. */ 607 637 if (symbol->section == &bfd_und_section 608 638 && (symbol->flags & BSF_WEAK) == 0) … … 616 646 617 647 relocation = (target & 0x00ffffff) << 2; 618 relocation = (relocation ^ 0x02000000) - 0x02000000; /* Sign extend */648 relocation = (relocation ^ 0x02000000) - 0x02000000; /* Sign extend. */ 619 649 relocation += symbol->value; 620 650 relocation += symbol->section->output_section->vma; … … 628 658 return bfd_reloc_overflow; 629 659 630 /* Check for overflow */660 /* Check for overflow. */ 631 661 if (relocation & 0x02000000) 632 662 { … … 634 664 flag = bfd_reloc_overflow; 635 665 } 636 else if (relocation & ~ 0x03ffffff)666 else if (relocation & ~(bfd_vma) 0x03ffffff) 637 667 flag = bfd_reloc_overflow; 638 668 639 669 target &= ~0x00ffffff; 640 670 target |= (relocation >> 2) & 0x00ffffff; 641 bfd_put_32 (abfd, target, (bfd_byte *) data + addr);671 bfd_put_32 (abfd, (bfd_vma) target, (bfd_byte *) data + addr); 642 672 643 673 /* Now the ARM magic... Change the reloc type so that it is marked as done. … … 695 725 } 696 726 697 /* If this is an undefined symbol, return error */727 /* If this is an undefined symbol, return error. */ 698 728 if (symbol->section == &bfd_und_section 699 729 && (symbol->flags & BSF_WEAK) == 0) … … 724 754 } 725 755 726 relocation = (relocation ^ signbit) - signbit; /* Sign extend */756 relocation = (relocation ^ signbit) - signbit; /* Sign extend. */ 727 757 relocation += symbol->value; 728 758 relocation += symbol->section->output_section->vma; … … 736 766 return bfd_reloc_overflow; 737 767 738 /* Check for overflow */768 /* Check for overflow. */ 739 769 if (relocation & signbit) 740 770 { … … 755 785 case b23: 756 786 if (bfd_big_endian (abfd)) 757 target |= ((relocation & 0xfff) >> 1) | ((relocation << 4) & 0x07ff0000); 787 target |= (((relocation & 0xfff) >> 1) 788 | ((relocation << 4) & 0x07ff0000)); 758 789 else 759 target |= ((relocation & 0xffe) << 15) | ((relocation >> 12) & 0x7ff); 790 target |= (((relocation & 0xffe) << 15) 791 | ((relocation >> 12) & 0x7ff)); 760 792 break; 761 793 … … 764 796 } 765 797 766 bfd_put_32 (abfd, target, (bfd_byte *) data + addr);798 bfd_put_32 (abfd, (bfd_vma) target, (bfd_byte *) data + addr); 767 799 768 800 /* Now the ARM magic... Change the reloc type so that it is marked as done. … … 770 802 reloc_entry->howto = & aoutarm_std_reloc_howto [ARM_26D]; 771 803 772 /* TODO: We should possibly have DONE entries for the THUMB PCREL relocations */804 /* TODO: We should possibly have DONE entries for the THUMB PCREL relocations. */ 773 805 return flag; 774 806 } 775 807 808 #ifndef ARM_WINCE 776 809 static bfd_reloc_status_type 777 810 coff_thumb_pcrel_23 (abfd, reloc_entry, symbol, data, input_section, … … 786 819 { 787 820 return coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data, 788 input_section, output_bfd, error_message, b23); 789 } 821 input_section, output_bfd, error_message, 822 b23); 823 } 824 825 static bfd_reloc_status_type 826 coff_thumb_pcrel_9 (abfd, reloc_entry, symbol, data, input_section, 827 output_bfd, error_message) 828 bfd *abfd; 829 arelent *reloc_entry; 830 asymbol *symbol; 831 PTR data; 832 asection *input_section; 833 bfd *output_bfd; 834 char **error_message; 835 { 836 return coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data, 837 input_section, output_bfd, error_message, 838 b9); 839 } 840 #endif /* not ARM_WINCE */ 790 841 791 842 static bfd_reloc_status_type … … 801 852 { 802 853 return coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data, 803 input_section, output_bfd, error_message, b12); 804 } 805 806 static bfd_reloc_status_type 807 coff_thumb_pcrel_9 (abfd, reloc_entry, symbol, data, input_section, 808 output_bfd, error_message) 809 bfd *abfd; 810 arelent *reloc_entry; 811 asymbol *symbol; 812 PTR data; 813 asection *input_section; 814 bfd *output_bfd; 815 char **error_message; 816 { 817 return coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data, 818 input_section, output_bfd, error_message, b9); 819 } 820 821 static CONST struct reloc_howto_struct * 854 input_section, output_bfd, error_message, 855 b12); 856 } 857 858 static const struct reloc_howto_struct * 822 859 coff_arm_reloc_type_lookup (abfd, code) 823 860 bfd * abfd; … … 832 869 code = BFD_RELOC_32; 833 870 break; 834 default: return (CONST struct reloc_howto_struct *) 0; 871 default: 872 return (const struct reloc_howto_struct *) 0; 835 873 } 836 874 … … 857 895 ASTD (BFD_RELOC_THUMB_PCREL_BLX, ARM_THUMB23); 858 896 #endif 859 default: return ( CONSTstruct reloc_howto_struct *) 0;897 default: return (const struct reloc_howto_struct *) 0; 860 898 } 861 899 } … … 868 906 #define BADMAG(x) ARMBADMAG(x) 869 907 #define ARM 1 /* Customize coffcode.h */ 908 909 #ifndef ARM_WINCE 910 /* Make sure that the 'r_offset' field is copied properly 911 so that identical binaries will compare the same. */ 912 #define SWAP_IN_RELOC_OFFSET H_GET_32 913 #define SWAP_OUT_RELOC_OFFSET H_PUT_32 914 #endif 870 915 871 916 /* Extend the coff_link_hash_table structure with a few ARM specific fields. … … 873 918 global variables, which is a no-no in the BFD world. */ 874 919 struct coff_arm_link_hash_table 875 {876 /* The original coff_link_hash_table structure. MUST be first field. */877 struct coff_link_hash_table root;878 879 /* The size in bytes of the section containg the Thumb-to-ARM glue. */880 long intthumb_glue_size;881 882 /* The size in bytes of the section containg the ARM-to-Thumb glue. */883 long intarm_glue_size;884 885 /* An arbitary input BFD chosen to hold the glue sections. */886 bfd *bfd_of_glue_owner;887 888 /* Support interworking with old, non-interworking aware ARM code. */889 intsupport_old_code;920 { 921 /* The original coff_link_hash_table structure. MUST be first field. */ 922 struct coff_link_hash_table root; 923 924 /* The size in bytes of the section containg the Thumb-to-ARM glue. */ 925 bfd_size_type thumb_glue_size; 926 927 /* The size in bytes of the section containg the ARM-to-Thumb glue. */ 928 bfd_size_type arm_glue_size; 929 930 /* An arbitary input BFD chosen to hold the glue sections. */ 931 bfd * bfd_of_glue_owner; 932 933 /* Support interworking with old, non-interworking aware ARM code. */ 934 int support_old_code; 890 935 }; 891 936 … … 901 946 { 902 947 struct coff_arm_link_hash_table * ret; 903 904 ret = ((struct coff_arm_link_hash_table *) 905 bfd_alloc (abfd, sizeof (struct coff_arm_link_hash_table)));948 bfd_size_type amt = sizeof (struct coff_arm_link_hash_table); 949 950 ret = (struct coff_arm_link_hash_table *) bfd_malloc (amt); 906 951 if (ret == (struct coff_arm_link_hash_table *) NULL) 907 952 return NULL; … … 910 955 (& ret->root, abfd, _bfd_coff_link_hash_newfunc)) 911 956 { 912 bfd_release (abfd,ret);957 free (ret); 913 958 return (struct bfd_link_hash_table *) NULL; 914 959 } … … 933 978 + input_section->output_section->vma; 934 979 935 if (coff_data(output_bfd)->pe) 936 addr -= pe_data(output_bfd)->pe_opthdr.ImageBase; 937 fwrite (&addr, 1, sizeof (addr), (FILE *) info->base_file); 938 939 } 940 941 980 if (coff_data (output_bfd)->pe) 981 addr -= pe_data (output_bfd)->pe_opthdr.ImageBase; 982 fwrite (& addr, 1, sizeof (addr), (FILE *) info->base_file); 983 984 } 985 986 987 #ifndef ARM_WINCE 942 988 /* The thumb form of a long branch is a bit finicky, because the offset 943 989 encoding is split over two fields, each in it's own instruction. They … … 966 1012 in the sequence. The problem, however is that whilst little endian code 967 1013 stores the instructions in HI then LOW order, big endian code does the 968 reverse. nickc@cygnus.com */1014 reverse. nickc@cygnus.com. */ 969 1015 970 1016 #define LOW_HI_ORDER 0xF800F000 … … 990 1036 br_insn = HI_LOW_ORDER | (high_bits << 16) | low_bits; 991 1037 else 992 abort (); /* error - not a valid branch instruction form */993 994 /* FIXME: abort is probably not the right call. krk@cygnus.com*/1038 /* FIXME: the BFD library should never abort except for internal errors 1039 - it should return an error status. */ 1040 abort (); /* Error - not a valid branch instruction form. */ 995 1041 996 1042 return br_insn; 997 1043 } 1044 998 1045 999 1046 1000 1047 static struct coff_link_hash_entry * 1001 1048 find_thumb_glue (info, name, input_bfd) 1002 struct bfd_link_info * 1003 CONST char *name;1004 bfd * 1005 { 1006 char * 1007 struct coff_link_hash_entry * 1008 1009 tmp_name = ((char *) 1010 bfd_malloc (strlen (name) + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1));1049 struct bfd_link_info *info; 1050 const char *name; 1051 bfd *input_bfd; 1052 { 1053 char *tmp_name; 1054 struct coff_link_hash_entry *myh; 1055 bfd_size_type amt = strlen (name) + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1; 1056 1057 tmp_name = (char *) bfd_malloc (amt); 1011 1058 1012 1059 BFD_ASSERT (tmp_name); … … 1015 1062 1016 1063 myh = coff_link_hash_lookup 1017 (coff_hash_table (info), tmp_name, false, false, true);1064 (coff_hash_table (info), tmp_name, FALSE, FALSE, TRUE); 1018 1065 1019 1066 if (myh == NULL) 1020 1067 /* xgettext:c-format */ 1021 1068 _bfd_error_handler (_("%s: unable to find THUMB glue '%s' for `%s'"), 1022 bfd_ get_filename (input_bfd), tmp_name, name);1069 bfd_archive_filename (input_bfd), tmp_name, name); 1023 1070 1024 1071 free (tmp_name); … … 1026 1073 return myh; 1027 1074 } 1075 #endif /* not ARM_WINCE */ 1028 1076 1029 1077 static struct coff_link_hash_entry * 1030 1078 find_arm_glue (info, name, input_bfd) 1031 struct bfd_link_info * 1032 CONST char *name;1033 bfd * 1034 { 1035 char * 1079 struct bfd_link_info *info; 1080 const char *name; 1081 bfd *input_bfd; 1082 { 1083 char *tmp_name; 1036 1084 struct coff_link_hash_entry * myh; 1037 1038 tmp_name = ((char *) 1039 bfd_malloc (strlen (name) + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1));1085 bfd_size_type amt = strlen (name) + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1; 1086 1087 tmp_name = (char *) bfd_malloc (amt); 1040 1088 1041 1089 BFD_ASSERT (tmp_name); … … 1044 1092 1045 1093 myh = coff_link_hash_lookup 1046 (coff_hash_table (info), tmp_name, false, false, true);1094 (coff_hash_table (info), tmp_name, FALSE, FALSE, TRUE); 1047 1095 1048 1096 if (myh == NULL) 1049 1097 /* xgettext:c-format */ 1050 1098 _bfd_error_handler (_("%s: unable to find ARM glue '%s' for `%s'"), 1051 bfd_ get_filename (input_bfd), tmp_name, name);1099 bfd_archive_filename (input_bfd), tmp_name, name); 1052 1100 1053 1101 free (tmp_name); … … 1143 1191 is different from the original. */ 1144 1192 1145 static b oolean1193 static bfd_boolean 1146 1194 coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, 1147 1195 contents, relocs, syms, sections) … … 1199 1247 sym, &addend); 1200 1248 if (howto == NULL) 1201 return false;1249 return FALSE; 1202 1250 1203 1251 /* The relocation_section function will skip pcrel_offset relocs … … 1211 1259 && (h->root.type == bfd_link_hash_defined 1212 1260 || h->root.type == bfd_link_hash_defweak) 1213 && h->root.u.def.section->output_section == input_section->output_section) 1261 && (h->root.u.def.section->output_section 1262 == input_section->output_section)) 1214 1263 { 1215 1264 static reloc_howto_type fake_arm26_reloc = … … 1218 1267 2, 1219 1268 24, 1220 true,1269 TRUE, 1221 1270 0, 1222 1271 complain_overflow_signed, 1223 1272 aoutarm_fix_pcrel_26 , 1224 1273 "ARM_26", 1225 false,1274 FALSE, 1226 1275 0x00ffffff, 1227 1276 0x00ffffff, 1228 false);1277 FALSE); 1229 1278 1230 1279 addend -= rel->r_vaddr - input_section->vma; … … 1235 1284 /* MS ARM-CE makes the reloc relative to the opcode's pc, not 1236 1285 the next opcode's pc, so is off by one. */ 1286 #if 0 /* This appears to have been true for WINCE 2.0, but it is not 1287 true for WINCE 3.0. */ 1237 1288 if (howto->pc_relative && !info->relocateable) 1238 1289 addend -= 8; 1290 #endif 1239 1291 #endif 1240 1292 … … 1249 1301 /* FIXME - it is not clear which targets need this next test 1250 1302 and which do not. It is known that it is needed for the 1251 V Xworks target (hence the #ifdef), but it is also known1252 that it was supressed for other (arm) targets. This ought1253 to besorted out one day. */1254 #ifdef VXWORKS1303 VxWorks and EPOC-PE targets, but it is also known that it 1304 was supressed for other ARM targets. This ought to be 1305 sorted out one day. */ 1306 #ifdef ARM_COFF_BUGFIX 1255 1307 /* We must not ignore the symbol value. If the symbol is 1256 1308 within the same section, the relocation should have already … … 1309 1361 || h->class == C_THUMBEXTFUNC) 1310 1362 { 1311 /* Arm code calling a Thumb function */1363 /* Arm code calling a Thumb function. */ 1312 1364 unsigned long int tmp; 1313 long intmy_offset;1365 bfd_vma my_offset; 1314 1366 asection * s; 1315 1367 long int ret_offset; … … 1319 1371 myh = find_arm_glue (info, name, input_bfd); 1320 1372 if (myh == NULL) 1321 return false;1373 return FALSE; 1322 1374 1323 1375 globals = coff_arm_hash_table (info); … … 1343 1395 /* xgettext:c-format */ 1344 1396 (_("%s(%s): warning: interworking not enabled."), 1345 bfd_ get_filename (h_sec->owner), name);1397 bfd_archive_filename (h_sec->owner), name); 1346 1398 _bfd_error_handler 1347 1399 /* xgettext:c-format */ 1348 1400 (_(" first occurrence: %s: arm call to thumb"), 1349 bfd_ get_filename (input_bfd));1401 bfd_archive_filename (input_bfd)); 1350 1402 } 1351 1403 … … 1353 1405 myh->root.u.def.value = my_offset; 1354 1406 1355 bfd_put_32 (output_bfd, a2t1_ldr_insn,1407 bfd_put_32 (output_bfd, (bfd_vma) a2t1_ldr_insn, 1356 1408 s->contents + my_offset); 1357 1409 1358 bfd_put_32 (output_bfd, a2t2_bx_r12_insn,1410 bfd_put_32 (output_bfd, (bfd_vma) a2t2_bx_r12_insn, 1359 1411 s->contents + my_offset + 4); 1360 1412 … … 1365 1417 if (info->base_file) 1366 1418 arm_emit_base_file_entry (info, output_bfd, s, 1367 1419 my_offset + 8); 1368 1420 1369 1421 } … … 1388 1440 tmp = tmp | ((ret_offset >> 2) & 0x00FFFFFF); 1389 1441 1390 bfd_put_32 (output_bfd, tmp, contents + rel->r_vaddr1391 - input_section->vma);1442 bfd_put_32 (output_bfd, (bfd_vma) tmp, 1443 contents + rel->r_vaddr - input_section->vma); 1392 1444 done = 1; 1393 1445 } … … 1395 1447 1396 1448 #ifndef ARM_WINCE 1397 /* Note: We used to check for ARM_THUMB9 and ARM_THUMB12 */1449 /* Note: We used to check for ARM_THUMB9 and ARM_THUMB12. */ 1398 1450 else if (howto->type == ARM_THUMB23) 1399 1451 { … … 1404 1456 /* Thumb code calling an ARM function */ 1405 1457 asection * s = 0; 1406 long intmy_offset;1458 bfd_vma my_offset; 1407 1459 unsigned long int tmp; 1408 1460 long int ret_offset; … … 1412 1464 myh = find_thumb_glue (info, name, input_bfd); 1413 1465 if (myh == NULL) 1414 return false;1466 return FALSE; 1415 1467 1416 1468 globals = coff_arm_hash_table (info); … … 1438 1490 /* xgettext:c-format */ 1439 1491 (_("%s(%s): warning: interworking not enabled."), 1440 bfd_ get_filename (h_sec->owner), name);1492 bfd_archive_filename (h_sec->owner), name); 1441 1493 _bfd_error_handler 1442 1494 /* xgettext:c-format */ 1443 1495 (_(" first occurrence: %s: thumb call to arm"), 1444 bfd_ get_filename (input_bfd));1496 bfd_archive_filename (input_bfd)); 1445 1497 _bfd_error_handler 1446 1498 (_(" consider relinking with --support-old-code enabled")); … … 1452 1504 if (globals->support_old_code) 1453 1505 { 1454 bfd_put_16 (output_bfd, t2a1_push_insn,1506 bfd_put_16 (output_bfd, (bfd_vma) t2a1_push_insn, 1455 1507 s->contents + my_offset); 1456 1508 1457 bfd_put_16 (output_bfd, t2a2_ldr_insn,1509 bfd_put_16 (output_bfd, (bfd_vma) t2a2_ldr_insn, 1458 1510 s->contents + my_offset + 2); 1459 1511 1460 bfd_put_16 (output_bfd, t2a3_mov_insn,1512 bfd_put_16 (output_bfd, (bfd_vma) t2a3_mov_insn, 1461 1513 s->contents + my_offset + 4); 1462 1514 1463 bfd_put_16 (output_bfd, t2a4_bx_insn,1515 bfd_put_16 (output_bfd, (bfd_vma) t2a4_bx_insn, 1464 1516 s->contents + my_offset + 6); 1465 1517 1466 bfd_put_32 (output_bfd, t2a5_pop_insn,1518 bfd_put_32 (output_bfd, (bfd_vma) t2a5_pop_insn, 1467 1519 s->contents + my_offset + 8); 1468 1520 1469 bfd_put_32 (output_bfd, t2a6_bx_insn,1521 bfd_put_32 (output_bfd, (bfd_vma) t2a6_bx_insn, 1470 1522 s->contents + my_offset + 12); 1471 1523 … … 1475 1527 1476 1528 if (info->base_file) 1477 arm_emit_base_file_entry (info, output_bfd, s, my_offset + 16); 1529 arm_emit_base_file_entry (info, output_bfd, s, 1530 my_offset + 16); 1478 1531 } 1479 1532 else 1480 1533 { 1481 bfd_put_16 (output_bfd, t2a1_bx_pc_insn,1534 bfd_put_16 (output_bfd, (bfd_vma) t2a1_bx_pc_insn, 1482 1535 s->contents + my_offset); 1483 1536 1484 bfd_put_16 (output_bfd, t2a2_noop_insn,1537 bfd_put_16 (output_bfd, (bfd_vma) t2a2_noop_insn, 1485 1538 s->contents + my_offset + 2); 1486 1539 1487 1540 ret_offset = 1488 ((bfd_signed_vma) h_val) /* Address of destination of the stub */1541 ((bfd_signed_vma) h_val) /* Address of destination of the stub. */ 1489 1542 - ((bfd_signed_vma) 1490 1543 (s->output_offset /* Offset from the start of the current section to the start of the stubs. */ … … 1495 1548 1496 1549 bfd_put_32 (output_bfd, 1497 t2a3_b_insn | ((ret_offset >> 2) & 0x00FFFFFF),1550 (bfd_vma) t2a3_b_insn | ((ret_offset >> 2) & 0x00FFFFFF), 1498 1551 s->contents + my_offset + 4); 1499 1552 … … 1516 1569 1517 1570 bfd_put_32 (output_bfd, 1518 insert_thumb_branch (tmp, ret_offset),1519 contents + rel->r_vaddr1520 - input_section->vma);1571 (bfd_vma) insert_thumb_branch (tmp, 1572 ret_offset), 1573 contents + rel->r_vaddr - input_section->vma); 1521 1574 1522 1575 done = 1; … … 1549 1602 if (! ((*info->callbacks->undefined_symbol) 1550 1603 (info, h->root.root.string, input_bfd, input_section, 1551 rel->r_vaddr - input_section->vma, true)))1552 return false;1604 rel->r_vaddr - input_section->vma, TRUE))) 1605 return FALSE; 1553 1606 } 1554 1607 } … … 1558 1611 /* Emit a reloc if the backend thinks it needs it. */ 1559 1612 if (sym && pe_data(output_bfd)->in_reloc_p(output_bfd, howto)) 1560 arm_emit_base_file_entry (info, output_bfd, input_section, rel->r_vaddr); 1613 arm_emit_base_file_entry (info, output_bfd, input_section, 1614 rel->r_vaddr); 1561 1615 } 1562 1616 … … 1583 1637 else 1584 1638 { 1585 bfd_vma relocation= val + addend;1586 int size= bfd_get_reloc_size (howto);1587 b oolean overflow = false;1588 bfd_byte * location= contents + address;1589 bfd_vma x= bfd_get_32 (input_bfd, location);1590 bfd_vma src_mask= 0x007FFFFE;1591 bfd_signed_vma 1592 bfd_signed_vma 1593 bfd_vma 1594 bfd_signed_vma 1595 bfd_vma 1596 bfd_signed_vma 1639 bfd_vma relocation = val + addend; 1640 int size = bfd_get_reloc_size (howto); 1641 bfd_boolean overflow = FALSE; 1642 bfd_byte *location = contents + address; 1643 bfd_vma x = bfd_get_32 (input_bfd, location); 1644 bfd_vma src_mask = 0x007FFFFE; 1645 bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1; 1646 bfd_signed_vma reloc_signed_min = ~reloc_signed_max; 1647 bfd_vma check; 1648 bfd_signed_vma signed_check; 1649 bfd_vma add; 1650 bfd_signed_vma signed_add; 1597 1651 1598 1652 BFD_ASSERT (size == 4); … … 1651 1705 if ( signed_check > reloc_signed_max 1652 1706 || signed_check < reloc_signed_min) 1653 overflow = true; 1654 1655 /* For the BLX(1) instruction remove bit 0 of the adjusted offset. 1656 Bit 0 can only be set if the upper insn is at a half-word boundary, 1657 since the destination address, an ARM instruction, must always be 1658 on a word boundary. The semantics of the BLX (1) instruction, 1659 however, are that bit 0 in the offset must always be 0, and the 1660 corresponding bit 1 in the target address will be set from bit 1661 1 of the source address. */ 1662 if ((x & 0x18000000) == 0x08000000) 1663 relocation &= ~0x2; 1664 1665 /* Put the relocation into the correct bits. */ 1707 overflow = TRUE; 1708 1709 /* Put the relocation into the correct bits. 1710 For a BLX instruction, make sure that the relocation is rounded up 1711 to a word boundary. This follows the semantics of the instruction 1712 which specifies that bit 1 of the target address will come from bit 1713 1 of the base address. */ 1666 1714 if (bfd_big_endian (input_bfd)) 1667 relocation = (((relocation & 0xffe) >> 1) | ((relocation << 4) & 0x07ff0000)); 1715 { 1716 if ((x & 0x1800) == 0x0800 && (relocation & 0x02)) 1717 relocation += 2; 1718 relocation = (((relocation & 0xffe) >> 1) | ((relocation << 4) & 0x07ff0000)); 1719 } 1668 1720 else 1669 relocation = (((relocation & 0xffe) << 15) | ((relocation >> 12) & 0x7ff)); 1721 { 1722 if ((x & 0x18000000) == 0x08000000 && (relocation & 0x02)) 1723 relocation += 2; 1724 relocation = (((relocation & 0xffe) << 15) | ((relocation >> 12) & 0x7ff)); 1725 } 1670 1726 1671 1727 /* Add the relocation to the correct bits of X. */ … … 1696 1752 because the address is the address of a Thumb code symbol. */ 1697 1753 1698 int patchit = false;1754 int patchit = FALSE; 1699 1755 1700 1756 if (h != NULL … … 1702 1758 || h->class == C_THUMBEXTFUNC)) 1703 1759 { 1704 patchit = true;1760 patchit = TRUE; 1705 1761 } 1706 1762 else if (sym != NULL … … 1711 1767 if ( sym->n_sclass == C_THUMBSTATFUNC 1712 1768 || sym->n_sclass == C_THUMBEXTFUNC) 1713 patchit = true;1769 patchit = TRUE; 1714 1770 } 1715 1771 … … 1733 1789 (*_bfd_error_handler) 1734 1790 (_("%s: bad reloc address 0x%lx in section `%s'"), 1735 bfd_ get_filename (input_bfd),1791 bfd_archive_filename (input_bfd), 1736 1792 (unsigned long) rel->r_vaddr, 1737 1793 bfd_get_section_name (input_bfd, input_section)); 1738 return false;1794 return FALSE; 1739 1795 case bfd_reloc_overflow: 1740 1796 { … … 1750 1806 name = _bfd_coff_internal_syment_name (input_bfd, sym, buf); 1751 1807 if (name == NULL) 1752 return false;1808 return FALSE; 1753 1809 } 1754 1810 … … 1756 1812 (info, name, howto->name, (bfd_vma) 0, input_bfd, 1757 1813 input_section, rel->r_vaddr - input_section->vma))) 1758 return false;1814 return FALSE; 1759 1815 } 1760 1816 } 1761 1817 } 1762 1818 1763 return true;1819 return TRUE; 1764 1820 } 1765 1821 1766 1822 #ifndef COFF_IMAGE_WITH_PE 1767 1823 1768 b oolean1824 bfd_boolean 1769 1825 bfd_arm_allocate_interworking_sections (info) 1770 1826 struct bfd_link_info * info; … … 1790 1846 BFD_ASSERT (s != NULL); 1791 1847 1792 foo = (bfd_byte *) bfd_alloc 1793 (globals->bfd_of_glue_owner,globals->arm_glue_size);1848 foo = (bfd_byte *) bfd_alloc (globals->bfd_of_glue_owner, 1849 globals->arm_glue_size); 1794 1850 #if 0 1795 memset (foo, test_char, globals->arm_glue_size);1851 memset (foo, test_char, (size_t) globals->arm_glue_size); 1796 1852 #endif 1797 1853 … … 1809 1865 BFD_ASSERT (s != NULL); 1810 1866 1811 foo = (bfd_byte *) bfd_alloc 1812 (globals->bfd_of_glue_owner,globals->thumb_glue_size);1867 foo = (bfd_byte *) bfd_alloc (globals->bfd_of_glue_owner, 1868 globals->thumb_glue_size); 1813 1869 #if 0 1814 memset (foo, test_char, globals->thumb_glue_size);1870 memset (foo, test_char, (size_t) globals->thumb_glue_size); 1815 1871 #endif 1816 1872 … … 1819 1875 } 1820 1876 1821 return true;1877 return TRUE; 1822 1878 } 1823 1879 … … 1831 1887 char * tmp_name; 1832 1888 struct coff_link_hash_entry * myh; 1889 struct bfd_link_hash_entry * bh; 1833 1890 struct coff_arm_link_hash_table * globals; 1891 bfd_vma val; 1892 bfd_size_type amt; 1834 1893 1835 1894 globals = coff_arm_hash_table (info); … … 1843 1902 BFD_ASSERT (s != NULL); 1844 1903 1845 tmp_name = ((char *)1846 bfd_malloc (strlen (name) + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1));1904 amt = strlen (name) + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1; 1905 tmp_name = (char *) bfd_malloc (amt); 1847 1906 1848 1907 BFD_ASSERT (tmp_name); … … 1851 1910 1852 1911 myh = coff_link_hash_lookup 1853 (coff_hash_table (info), tmp_name, false, false, true);1912 (coff_hash_table (info), tmp_name, FALSE, FALSE, TRUE); 1854 1913 1855 1914 if (myh != NULL) … … 1863 1922 it. */ 1864 1923 1924 bh = NULL; 1925 val = globals->arm_glue_size + 1; 1865 1926 bfd_coff_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name, 1866 BSF_GLOBAL, 1867 s, globals->arm_glue_size + 1, 1868 NULL, true, false, 1869 (struct bfd_link_hash_entry **) & myh); 1927 BSF_GLOBAL, s, val, NULL, TRUE, FALSE, &bh); 1870 1928 1871 1929 free (tmp_name); … … 1876 1934 } 1877 1935 1936 #ifndef ARM_WINCE 1878 1937 static void 1879 1938 record_thumb_to_arm_glue (info, h) … … 1885 1944 char * tmp_name; 1886 1945 struct coff_link_hash_entry * myh; 1946 struct bfd_link_hash_entry * bh; 1887 1947 struct coff_arm_link_hash_table * globals; 1948 bfd_vma val; 1949 bfd_size_type amt; 1888 1950 1889 1951 globals = coff_arm_hash_table (info); … … 1897 1959 BFD_ASSERT (s != NULL); 1898 1960 1899 tmp_name = (char *) bfd_malloc (strlen (name) + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1); 1961 amt = strlen (name) + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1; 1962 tmp_name = (char *) bfd_malloc (amt); 1900 1963 1901 1964 BFD_ASSERT (tmp_name); … … 1904 1967 1905 1968 myh = coff_link_hash_lookup 1906 (coff_hash_table (info), tmp_name, false, false, true);1969 (coff_hash_table (info), tmp_name, FALSE, FALSE, TRUE); 1907 1970 1908 1971 if (myh != NULL) … … 1912 1975 } 1913 1976 1977 bh = NULL; 1978 val = globals->thumb_glue_size + 1; 1914 1979 bfd_coff_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name, 1915 BSF_GLOBAL, s, globals->thumb_glue_size + 1, 1916 NULL, true, false, 1917 (struct bfd_link_hash_entry **) & myh); 1980 BSF_GLOBAL, s, val, NULL, TRUE, FALSE, &bh); 1918 1981 1919 1982 /* If we mark it 'thumb', the disassembler will do a better job. */ 1983 myh = (struct coff_link_hash_entry *) bh; 1920 1984 myh->class = C_THUMBEXTFUNC; 1921 1985 … … 1927 1991 #define BACK_FROM_ARM "__%s_back_from_arm" 1928 1992 1929 tmp_name = (char *) bfd_malloc (strlen (name) + strlen (CHANGE_TO_ARM) + 1); 1993 amt = strlen (name) + strlen (CHANGE_TO_ARM) + 1; 1994 tmp_name = (char *) bfd_malloc (amt); 1930 1995 1931 1996 BFD_ASSERT (tmp_name); … … 1933 1998 sprintf (tmp_name, globals->support_old_code ? BACK_FROM_ARM : CHANGE_TO_ARM, name); 1934 1999 1935 myh = NULL;1936 2000 bh = NULL; 2001 val = globals->thumb_glue_size + (globals->support_old_code ? 8 : 4); 1937 2002 bfd_coff_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name, 1938 BSF_LOCAL, s, globals->thumb_glue_size 1939 + (globals->support_old_code ? 8 : 4), 1940 NULL, true, false, 1941 (struct bfd_link_hash_entry **) & myh); 2003 BSF_LOCAL, s, val, NULL, TRUE, FALSE, &bh); 1942 2004 1943 2005 free (tmp_name); … … 1947 2009 return; 1948 2010 } 2011 #endif /* not ARM_WINCE */ 1949 2012 1950 2013 /* Select a BFD to be used to hold the sections used by the glue code. … … 1952 2015 {armcoff/pe}.em */ 1953 2016 1954 b oolean2017 bfd_boolean 1955 2018 bfd_arm_get_bfd_for_interworking (abfd, info) 1956 2019 bfd * abfd; … … 1964 2027 getting a bfd to hold the glue. */ 1965 2028 if (info->relocateable) 1966 return true;2029 return TRUE; 1967 2030 1968 2031 globals = coff_arm_hash_table (info); … … 1971 2034 1972 2035 if (globals->bfd_of_glue_owner != NULL) 1973 return true;2036 return TRUE; 1974 2037 1975 2038 sec = bfd_get_section_by_name (abfd, ARM2THUMB_GLUE_SECTION_NAME); … … 1984 2047 || ! bfd_set_section_flags (abfd, sec, flags) 1985 2048 || ! bfd_set_section_alignment (abfd, sec, 2)) 1986 return false;2049 return FALSE; 1987 2050 } 1988 2051 … … 1998 2061 || ! bfd_set_section_flags (abfd, sec, flags) 1999 2062 || ! bfd_set_section_alignment (abfd, sec, 2)) 2000 return false;2063 return FALSE; 2001 2064 } 2002 2065 … … 2004 2067 globals->bfd_of_glue_owner = abfd; 2005 2068 2006 return true;2007 } 2008 2009 b oolean2069 return TRUE; 2070 } 2071 2072 bfd_boolean 2010 2073 bfd_arm_process_before_allocation (abfd, info, support_old_code) 2011 2074 bfd * abfd; … … 2019 2082 to construct any glue. */ 2020 2083 if (info->relocateable) 2021 return true;2084 return TRUE; 2022 2085 2023 2086 /* Here we have a bfd that is to be included on the link. We have a hook … … 2037 2100 2038 2101 if (sec == NULL) 2039 return true;2102 return TRUE; 2040 2103 2041 2104 for (; sec != NULL; sec = sec->next) … … 2070 2133 { 2071 2134 _bfd_error_handler (_("%s: illegal symbol index in reloc: %d"), 2072 bfd_ get_filename (abfd), symndx);2135 bfd_archive_filename (abfd), symndx); 2073 2136 continue; 2074 2137 } … … 2121 2184 } 2122 2185 2123 return true;2186 return TRUE; 2124 2187 } 2125 2188 … … 2141 2204 into ARM26D relocs. */ 2142 2205 2143 static b oolean2206 static bfd_boolean 2144 2207 coff_arm_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp) 2145 2208 bfd *obfd ATTRIBUTE_UNUSED; … … 2148 2211 asection *sec; 2149 2212 struct internal_reloc *irel; 2150 b oolean *adjustedp;2213 bfd_boolean *adjustedp; 2151 2214 { 2152 2215 if (irel->r_type == 3) … … 2161 2224 irel->r_type = 7; 2162 2225 } 2163 *adjustedp = false;2164 return true;2226 *adjustedp = FALSE; 2227 return TRUE; 2165 2228 } 2166 2229 … … 2170 2233 targets, eg different CPUs or differents APCS's. */ 2171 2234 2172 static b oolean2235 static bfd_boolean 2173 2236 coff_arm_merge_private_bfd_data (ibfd, obfd) 2174 2237 bfd * ibfd; … … 2178 2241 2179 2242 if (ibfd == obfd) 2180 return true;2243 return TRUE; 2181 2244 2182 2245 /* If the two formats are different we cannot merge anything. … … 2185 2248 if ( ibfd->xvec->flavour != bfd_target_coff_flavour 2186 2249 || obfd->xvec->flavour != bfd_target_coff_flavour) 2187 return true; 2188 2189 /* Verify that the APCS is the same for the two BFDs */ 2250 return TRUE; 2251 2252 /* Determine what should happen if the input ARM architecture 2253 does not match the output ARM architecture. */ 2254 if (! bfd_arm_merge_machines (ibfd, obfd)) 2255 return FALSE; 2256 2257 /* Verify that the APCS is the same for the two BFDs. */ 2190 2258 if (APCS_SET (ibfd)) 2191 2259 { … … 2197 2265 _bfd_error_handler 2198 2266 /* xgettext: c-format */ 2199 (_(" %s: ERROR: compiled for APCS-%d whereas target %s usesAPCS-%d"),2200 bfd_ get_filename (ibfd), APCS_26_FLAG (ibfd) ? 26 : 32,2267 (_("ERROR: %s is compiled for APCS-%d, whereas %s is compiled for APCS-%d"), 2268 bfd_archive_filename (ibfd), APCS_26_FLAG (ibfd) ? 26 : 32, 2201 2269 bfd_get_filename (obfd), APCS_26_FLAG (obfd) ? 26 : 32 2202 2270 ); 2203 2271 2204 2272 bfd_set_error (bfd_error_wrong_format); 2205 return false;2273 return FALSE; 2206 2274 } 2207 2275 … … 2212 2280 if (APCS_FLOAT_FLAG (ibfd)) 2213 2281 /* xgettext: c-format */ 2214 msg = _(" %s: ERROR: passes floats in float registers whereas target %s usesinteger registers");2282 msg = _("ERROR: %s passes floats in float registers, whereas %s passes them in integer registers"); 2215 2283 else 2216 2284 /* xgettext: c-format */ 2217 msg = _(" %s: ERROR: passes floats in integer registers whereas target %s usesfloat registers");2218 2219 _bfd_error_handler (msg, bfd_ get_filename (ibfd),2285 msg = _("ERROR: %s passes floats in integer registers, whereas %s passes them in float registers"); 2286 2287 _bfd_error_handler (msg, bfd_archive_filename (ibfd), 2220 2288 bfd_get_filename (obfd)); 2221 2289 2222 2290 bfd_set_error (bfd_error_wrong_format); 2223 return false;2291 return FALSE; 2224 2292 } 2225 2293 … … 2230 2298 if (PIC_FLAG (ibfd)) 2231 2299 /* xgettext: c-format */ 2232 msg = _(" %s: ERROR:compiled as position independent code, whereas target %s is absolute position");2300 msg = _("ERROR: %s is compiled as position independent code, whereas target %s is absolute position"); 2233 2301 else 2234 2302 /* xgettext: c-format */ 2235 msg = _(" %s: ERROR:compiled as absolute position code, whereas target %s is position independent");2236 _bfd_error_handler (msg, bfd_ get_filename (ibfd),2303 msg = _("ERROR: %s is compiled as absolute position code, whereas target %s is position independent"); 2304 _bfd_error_handler (msg, bfd_archive_filename (ibfd), 2237 2305 bfd_get_filename (obfd)); 2238 2306 2239 2307 bfd_set_error (bfd_error_wrong_format); 2240 return false;2308 return FALSE; 2241 2309 } 2242 2310 } … … 2262 2330 if (INTERWORK_FLAG (ibfd)) 2263 2331 /* xgettext: c-format */ 2264 msg = _("Warning: input file %s supports interworking, whereas %s does not.");2332 msg = _("Warning: %s supports interworking, whereas %s does not"); 2265 2333 else 2266 2334 /* xgettext: c-format */ 2267 msg = _("Warning: input file %s does not support interworking, whereas %s does.");2268 2269 _bfd_error_handler (msg, bfd_ get_filename (ibfd),2335 msg = _("Warning: %s does not support interworking, whereas %s does"); 2336 2337 _bfd_error_handler (msg, bfd_archive_filename (ibfd), 2270 2338 bfd_get_filename (obfd)); 2271 2339 } … … 2277 2345 } 2278 2346 2279 return true;2347 return TRUE; 2280 2348 } 2281 2349 2282 2350 /* Display the flags field. */ 2283 2351 2284 static b oolean2352 static bfd_boolean 2285 2353 coff_arm_print_private_bfd_data (abfd, ptr) 2286 2354 bfd * abfd; … … 2319 2387 fputc ('\n', file); 2320 2388 2321 return true;2389 return TRUE; 2322 2390 } 2323 2391 … … 2329 2397 called from both coffcode.h and peicode.h. */ 2330 2398 2331 static b oolean2399 static bfd_boolean 2332 2400 _bfd_coff_arm_set_private_flags (abfd, flags) 2333 2401 bfd * abfd; … … 2347 2415 || (PIC_FLAG (abfd) != (flags & F_PIC)) 2348 2416 )) 2349 return false;2417 return FALSE; 2350 2418 2351 2419 flag |= (flags & (F_APCS_FLOAT | F_PIC)); … … 2363 2431 if (flag) 2364 2432 /* xgettext: c-format */ 2365 _bfd_error_handler (_("Warning: Not setting interworking flag of %s ,since it has already been specified as non-interworking"),2366 bfd_ get_filename (abfd));2433 _bfd_error_handler (_("Warning: Not setting interworking flag of %s since it has already been specified as non-interworking"), 2434 bfd_archive_filename (abfd)); 2367 2435 else 2368 2436 /* xgettext: c-format */ 2369 2437 _bfd_error_handler (_("Warning: Clearing the interworking flag of %s due to outside request"), 2370 bfd_ get_filename (abfd));2438 bfd_archive_filename (abfd)); 2371 2439 flag = 0; 2372 2440 } … … 2374 2442 SET_INTERWORK_FLAG (abfd, flag); 2375 2443 2376 return true;2444 return TRUE; 2377 2445 } 2378 2446 … … 2380 2448 from one instance of a BFD to another. */ 2381 2449 2382 static b oolean2450 static bfd_boolean 2383 2451 coff_arm_copy_private_bfd_data (src, dest) 2384 2452 bfd * src; … … 2388 2456 2389 2457 if (src == dest) 2390 return true;2458 return TRUE; 2391 2459 2392 2460 /* If the destination is not in the same format as the source, do not do 2393 2461 the copy. */ 2394 2462 if (src->xvec != dest->xvec) 2395 return true;2463 return TRUE; 2396 2464 2397 2465 /* copy the flags field */ … … 2402 2470 /* If the src and dest have different APCS flag bits set, fail. */ 2403 2471 if (APCS_26_FLAG (dest) != APCS_26_FLAG (src)) 2404 return false;2472 return FALSE; 2405 2473 2406 2474 if (APCS_FLOAT_FLAG (dest) != APCS_FLOAT_FLAG (src)) 2407 return false;2475 return FALSE; 2408 2476 2409 2477 if (PIC_FLAG (dest) != PIC_FLAG (src)) 2410 return false;2478 return FALSE; 2411 2479 } 2412 2480 else … … 2426 2494 { 2427 2495 /* xgettext:c-format */ 2428 _bfd_error_handler (("Warning: Clearing the interworking bit of %s, because the non-interworking code in %s has been copied into it"), 2496 _bfd_error_handler (("\ 2497 Warning: Clearing the interworking flag of %s because non-interworking code in %s has been linked with it"), 2429 2498 bfd_get_filename (dest), 2430 bfd_ get_filename (src));2499 bfd_archive_filename (src)); 2431 2500 } 2432 2501 … … 2440 2509 } 2441 2510 2442 return true;2511 return TRUE; 2443 2512 } 2444 2513 … … 2455 2524 b) Allow other prefixes than ".", e.g. an empty prefix would cause all 2456 2525 labels of the form Lxxx to be stripped. */ 2457 static b oolean2526 static bfd_boolean 2458 2527 coff_arm_is_local_label_name (abfd, name) 2459 2528 bfd * abfd ATTRIBUTE_UNUSED; … … 2464 2533 { 2465 2534 if (strncmp (name, USER_LABEL_PREFIX, strlen (USER_LABEL_PREFIX)) == 0) 2466 return false;2535 return FALSE; 2467 2536 } 2468 2537 #endif … … 2474 2543 if (LOCAL_LABEL_PREFIX[0] != 0) 2475 2544 { 2476 int len = strlen (LOCAL_LABEL_PREFIX);2545 size_t len = strlen (LOCAL_LABEL_PREFIX); 2477 2546 2478 2547 if (strncmp (name, LOCAL_LABEL_PREFIX, len) != 0) 2479 return false;2548 return FALSE; 2480 2549 2481 2550 /* Perform the checks below for the rest of the name. */ … … 2495 2564 krk@cygnus.com */ 2496 2565 2497 static b oolean2566 static bfd_boolean 2498 2567 coff_arm_link_output_has_begun (sub, info) 2499 2568 bfd * sub; … … 2504 2573 } 2505 2574 2506 static b oolean2575 static bfd_boolean 2507 2576 coff_arm_final_link_postscript (abfd, pfinfo) 2508 2577 bfd * abfd ATTRIBUTE_UNUSED; … … 2518 2587 { 2519 2588 if (! _bfd_coff_link_input_bfd (pfinfo, globals->bfd_of_glue_owner)) 2520 return false;2521 2522 globals->bfd_of_glue_owner->output_has_begun = true;2589 return FALSE; 2590 2591 globals->bfd_of_glue_owner->output_has_begun = TRUE; 2523 2592 } 2524 2593 2525 return true;2594 return bfd_arm_update_notes (abfd, ARM_NOTE_SECTION); 2526 2595 } 2527 2596 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.