Changeset 609 for branches/GNU/src/binutils/bfd/coff-a29k.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-a29k.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* BFD back-end for AMD 29000 COFF binaries. 2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1997, 1999, 2000, 2001 2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002 3 3 Free Software Foundation, Inc. 4 4 Contributed by David Wood at New York University 7/8/91. … … 32 32 static bfd_reloc_status_type a29k_reloc 33 33 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); 34 static b oolean coff_a29k_relocate_section34 static bfd_boolean coff_a29k_relocate_section 35 35 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 36 36 struct internal_reloc *, struct internal_syment *, asection **)); 37 static b oolean coff_a29k_adjust_symndx37 static bfd_boolean coff_a29k_adjust_symndx 38 38 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, 39 struct internal_reloc *, boolean *)); 39 struct internal_reloc *, bfd_boolean *)); 40 static void reloc_processing 41 PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *)); 40 42 41 43 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2) … … 48 50 (((HWORD) ^ 0x8000) - 0x8000) 49 51 50 /* Provided the symbol, returns the value reffed */ 52 /* Provided the symbol, returns the value reffed. */ 53 51 54 static long 52 55 get_symbol_value (symbol) … … 56 59 57 60 if (bfd_is_com_section (symbol->section)) 58 { 59 relocation = 0; 60 } 61 relocation = 0; 61 62 else 62 { 63 relocation = symbol->value + 64 symbol->section->output_section->vma + 65 symbol->section->output_offset; 66 } 67 68 return(relocation); 63 relocation = symbol->value + 64 symbol->section->output_section->vma + 65 symbol->section->output_offset; 66 67 return relocation; 69 68 } 70 69 71 /* this function is in charge of performing all the 29k relocations*/70 /* This function is in charge of performing all the 29k relocations. */ 72 71 73 72 static bfd_reloc_status_type … … 82 81 char **error_message; 83 82 { 84 /* the consth relocation comes in two parts, we have to remember85 the state between calls, in these variables */86 static b oolean part1_consth_active = false;83 /* The consth relocation comes in two parts, we have to remember 84 the state between calls, in these variables. */ 85 static bfd_boolean part1_consth_active = FALSE; 87 86 static unsigned long part1_consth_value; 88 89 87 unsigned long insn; 90 88 unsigned long sym_value; … … 92 90 unsigned short r_type; 93 91 long signed_value; 94 95 92 unsigned long addr = reloc_entry->address ; /*+ input_section->vma*/ 96 93 bfd_byte *hit_data =addr + (bfd_byte *) (data); … … 100 97 if (output_bfd) 101 98 { 102 /* Partial linking - do nothing */99 /* Partial linking - do nothing. */ 103 100 reloc_entry->address += input_section->output_offset; 104 101 return bfd_reloc_ok; 105 106 102 } 107 103 … … 109 105 && bfd_is_und_section (symbol_in->section)) 110 106 { 111 /* Keep the state machine happy in case we're called again */107 /* Keep the state machine happy in case we're called again. */ 112 108 if (r_type == R_IHIHALF) 113 109 { 114 part1_consth_active = true;110 part1_consth_active = TRUE; 115 111 part1_consth_value = 0; 116 112 } 117 return (bfd_reloc_undefined);113 return bfd_reloc_undefined; 118 114 } 119 115 120 116 if ((part1_consth_active) && (r_type != R_IHCONST)) 121 117 { 122 part1_consth_active = false;118 part1_consth_active = FALSE; 123 119 *error_message = (char *) _("Missing IHCONST"); 124 return(bfd_reloc_dangerous); 120 121 return bfd_reloc_dangerous; 125 122 } 126 123 … … 131 128 case R_IREL: 132 129 insn = bfd_get_32 (abfd, hit_data); 133 /* Take the value in the field and sign extend it */130 /* Take the value in the field and sign extend it. */ 134 131 signed_value = EXTRACT_HWORD(insn); 135 132 signed_value = SIGN_EXTEND_HWORD(signed_value); … … 143 140 if ((signed_value & ~0x3ffff) == 0) 144 141 { /* Absolute jmp/call */ 145 insn |= (1 <<24); /* Make it absolute */146 /* FIXME: Should we change r_type to R_IABS */142 insn |= (1 << 24); /* Make it absolute */ 143 /* FIXME: Should we change r_type to R_IABS. */ 147 144 } 148 145 else 149 146 { 150 147 /* Relative jmp/call, so subtract from the value the 151 address of the place we're coming from */148 address of the place we're coming from. */ 152 149 signed_value -= (reloc_entry->address 153 150 + input_section->output_section->vma 154 151 + input_section->output_offset); 155 if (signed_value >0x1ffff || signed_value<-0x20000)156 return (bfd_reloc_overflow);152 if (signed_value > 0x1ffff || signed_value < -0x20000) 153 return bfd_reloc_overflow; 157 154 } 158 155 signed_value >>= 2; 159 insn = INSERT_HWORD (insn, signed_value);160 bfd_put_32 (abfd, insn ,hit_data);156 insn = INSERT_HWORD (insn, signed_value); 157 bfd_put_32 (abfd, (bfd_vma) insn ,hit_data); 161 158 break; 162 159 case R_ILOHALF: … … 165 162 unsigned_value += sym_value + reloc_entry->addend; 166 163 insn = INSERT_HWORD(insn, unsigned_value); 167 bfd_put_32 (abfd, insn, hit_data);164 bfd_put_32 (abfd, (bfd_vma) insn, hit_data); 168 165 break; 169 166 case R_IHIHALF: 170 167 insn = bfd_get_32 (abfd, hit_data); 171 168 /* consth, part 1 172 Just get the symbol value that is referenced */173 part1_consth_active = true;169 Just get the symbol value that is referenced. */ 170 part1_consth_active = TRUE; 174 171 part1_consth_value = sym_value + reloc_entry->addend; 175 /* Don't modify insn until R_IHCONST */172 /* Don't modify insn until R_IHCONST. */ 176 173 break; 177 174 case R_IHCONST: 178 175 insn = bfd_get_32 (abfd, hit_data); 179 176 /* consth, part 2 180 Now relocate the reference */181 if ( part1_consth_active == false)177 Now relocate the reference. */ 178 if (! part1_consth_active) 182 179 { 183 180 *error_message = (char *) _("Missing IHIHALF"); 184 return (bfd_reloc_dangerous);181 return bfd_reloc_dangerous; 185 182 } 186 183 /* sym_ptr_ptr = r_symndx, in coff_slurp_reloc_table() */ … … 190 187 unsigned_value = unsigned_value >> 16; 191 188 insn = INSERT_HWORD(insn, unsigned_value); 192 part1_consth_active = false;193 bfd_put_32 (abfd, insn, hit_data);189 part1_consth_active = FALSE; 190 bfd_put_32 (abfd, (bfd_vma) insn, hit_data); 194 191 break; 195 192 case R_BYTE: … … 197 194 unsigned_value = insn + sym_value + reloc_entry->addend; 198 195 if (unsigned_value & 0xffffff00) 199 return (bfd_reloc_overflow);196 return bfd_reloc_overflow; 200 197 bfd_put_8 (abfd, unsigned_value, hit_data); 201 198 break; … … 204 201 unsigned_value = insn + sym_value + reloc_entry->addend; 205 202 if (unsigned_value & 0xffff0000) 206 return (bfd_reloc_overflow);207 bfd_put_16 (abfd, insn, hit_data);203 return bfd_reloc_overflow; 204 bfd_put_16 (abfd, (bfd_vma) insn, hit_data); 208 205 break; 209 206 case R_WORD: 210 207 insn = bfd_get_32 (abfd, hit_data); 211 208 insn += sym_value + reloc_entry->addend; 212 bfd_put_32 (abfd, insn, hit_data);209 bfd_put_32 (abfd, (bfd_vma) insn, hit_data); 213 210 break; 214 211 default: 215 212 *error_message = _("Unrecognized reloc"); 216 return (bfd_reloc_dangerous);213 return bfd_reloc_dangerous; 217 214 } 218 215 … … 220 217 } 221 218 222 /* type rightshift 223 size 224 bitsize 225 pc-relative 226 bitpos 227 absolute 228 complain_on_overflow 229 special_function 230 relocation name 231 partial_inplace 232 src_mask 233 */ 234 235 /*FIXME: I'm not real sure about this table */ 219 /*FIXME: I'm not real sure about this table. */ 236 220 static reloc_howto_type howto_table[] = 237 {238 {R_ABS, 0, 3, 32, false, 0, complain_overflow_bitfield,a29k_reloc,"ABS", true, 0xffffffff,0xffffffff, false},239 EMPTY_HOWTO (1),240 EMPTY_HOWTO (2),241 EMPTY_HOWTO (3),242 EMPTY_HOWTO (4),243 EMPTY_HOWTO (5),244 EMPTY_HOWTO (6),245 EMPTY_HOWTO (7),246 EMPTY_HOWTO (8),247 EMPTY_HOWTO (9),248 EMPTY_HOWTO (10),249 EMPTY_HOWTO (11),250 EMPTY_HOWTO (12),251 EMPTY_HOWTO (13),252 EMPTY_HOWTO (14),253 EMPTY_HOWTO (15),254 EMPTY_HOWTO (16),255 EMPTY_HOWTO (17),256 EMPTY_HOWTO (18),257 EMPTY_HOWTO (19),258 EMPTY_HOWTO (20),259 EMPTY_HOWTO (21),260 EMPTY_HOWTO (22),261 EMPTY_HOWTO (23),262 {R_IREL, 0, 3, 32, true, 0, complain_overflow_signed,a29k_reloc,"IREL", true, 0xffffffff,0xffffffff, false},263 {R_IABS, 0, 3, 32, false, 0, complain_overflow_bitfield, a29k_reloc,"IABS", true, 0xffffffff,0xffffffff, false},264 {R_ILOHALF, 0, 3, 16, true, 0, complain_overflow_signed, a29k_reloc,"ILOHALF", true, 0x0000ffff,0x0000ffff, false},265 {R_IHIHALF, 0, 3, 16, true, 16, complain_overflow_signed, a29k_reloc,"IHIHALF", true, 0xffff0000,0xffff0000, false},266 {R_IHCONST, 0, 3, 16, true, 0, complain_overflow_signed, a29k_reloc,"IHCONST", true, 0xffff0000,0xffff0000, false},267 {R_BYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, a29k_reloc,"BYTE", true, 0x000000ff,0x000000ff, false},268 {R_HWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, a29k_reloc,"HWORD", true, 0x0000ffff,0x0000ffff, false},269 {R_WORD, 0, 2, 32, false, 0, complain_overflow_bitfield, a29k_reloc,"WORD", true, 0xffffffff,0xffffffff, false},270 };221 { 222 {R_ABS, 0, 3, 32, FALSE, 0, complain_overflow_bitfield,a29k_reloc,"ABS", TRUE, 0xffffffff,0xffffffff, FALSE}, 223 EMPTY_HOWTO (1), 224 EMPTY_HOWTO (2), 225 EMPTY_HOWTO (3), 226 EMPTY_HOWTO (4), 227 EMPTY_HOWTO (5), 228 EMPTY_HOWTO (6), 229 EMPTY_HOWTO (7), 230 EMPTY_HOWTO (8), 231 EMPTY_HOWTO (9), 232 EMPTY_HOWTO (10), 233 EMPTY_HOWTO (11), 234 EMPTY_HOWTO (12), 235 EMPTY_HOWTO (13), 236 EMPTY_HOWTO (14), 237 EMPTY_HOWTO (15), 238 EMPTY_HOWTO (16), 239 EMPTY_HOWTO (17), 240 EMPTY_HOWTO (18), 241 EMPTY_HOWTO (19), 242 EMPTY_HOWTO (20), 243 EMPTY_HOWTO (21), 244 EMPTY_HOWTO (22), 245 EMPTY_HOWTO (23), 246 {R_IREL, 0, 3, 32, TRUE, 0, complain_overflow_signed,a29k_reloc,"IREL", TRUE, 0xffffffff,0xffffffff, FALSE}, 247 {R_IABS, 0, 3, 32, FALSE, 0, complain_overflow_bitfield, a29k_reloc,"IABS", TRUE, 0xffffffff,0xffffffff, FALSE}, 248 {R_ILOHALF, 0, 3, 16, TRUE, 0, complain_overflow_signed, a29k_reloc,"ILOHALF", TRUE, 0x0000ffff,0x0000ffff, FALSE}, 249 {R_IHIHALF, 0, 3, 16, TRUE, 16, complain_overflow_signed, a29k_reloc,"IHIHALF", TRUE, 0xffff0000,0xffff0000, FALSE}, 250 {R_IHCONST, 0, 3, 16, TRUE, 0, complain_overflow_signed, a29k_reloc,"IHCONST", TRUE, 0xffff0000,0xffff0000, FALSE}, 251 {R_BYTE, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, a29k_reloc,"BYTE", TRUE, 0x000000ff,0x000000ff, FALSE}, 252 {R_HWORD, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, a29k_reloc,"HWORD", TRUE, 0x0000ffff,0x0000ffff, FALSE}, 253 {R_WORD, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, a29k_reloc,"WORD", TRUE, 0xffffffff,0xffffffff, FALSE}, 254 }; 271 255 272 256 #define BADMAG(x) A29KBADMAG(x) … … 305 289 { 306 290 asymbol *ptr; 307 relent->sym_ptr_ptr = symbols + obj_convert(abfd)[reloc->r_symndx]; 291 292 relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx]; 308 293 309 294 ptr = *(relent->sym_ptr_ptr); … … 311 296 if (ptr 312 297 && bfd_asymbol_bfd(ptr) == abfd 313 314 && ((ptr->flags & BSF_OLD_COMMON)== 0)) 315 { 316 relent->addend = 0; 317 } 298 && ((ptr->flags & BSF_OLD_COMMON) == 0)) 299 relent->addend = 0; 318 300 else 319 { 320 relent->addend = 0; 321 } 301 relent->addend = 0; 302 322 303 relent->address-= section->vma; 323 304 if (reloc->r_type == R_IHIHALF) … … 330 311 /* The reloc processing routine for the optimized COFF linker. */ 331 312 332 static b oolean313 static bfd_boolean 333 314 coff_a29k_relocate_section (output_bfd, info, input_bfd, input_section, 334 315 contents, relocs, syms, sections) … … 344 325 struct internal_reloc *rel; 345 326 struct internal_reloc *relend; 346 b oolean hihalf;327 bfd_boolean hihalf; 347 328 bfd_vma hihalf_val; 348 329 … … 351 332 addresses and symbol indices. */ 352 333 if (info->relocateable) 353 return true;354 355 hihalf = false;334 return TRUE; 335 336 hihalf = FALSE; 356 337 hihalf_val = 0; 357 338 … … 366 347 asection *sec; 367 348 bfd_vma val; 368 b oolean overflow;349 bfd_boolean overflow; 369 350 unsigned long insn; 370 351 long signed_value; … … 405 386 else 406 387 { 407 if ( h->root.type == bfd_link_hash_defined388 if ( h->root.type == bfd_link_hash_defined 408 389 || h->root.type == bfd_link_hash_defweak) 409 390 { … … 417 398 if (! ((*info->callbacks->undefined_symbol) 418 399 (info, h->root.root.string, input_bfd, input_section, 419 rel->r_vaddr - input_section->vma, true)))420 return false;400 rel->r_vaddr - input_section->vma, TRUE))) 401 return FALSE; 421 402 } 422 403 } … … 427 408 (info, _("missing IHCONST reloc"), input_bfd, 428 409 input_section, rel->r_vaddr - input_section->vma))) 429 return false;430 hihalf = false;431 } 432 } 433 434 overflow = false;410 return FALSE; 411 hihalf = FALSE; 412 } 413 } 414 415 overflow = FALSE; 435 416 436 417 switch (rel->r_type) … … 438 419 default: 439 420 bfd_set_error (bfd_error_bad_value); 440 return false;421 return FALSE; 441 422 442 423 case R_IREL: … … 485 466 if (signed_value > 0x1ffff || signed_value < - 0x20000) 486 467 { 487 overflow = true;468 overflow = TRUE; 488 469 signed_value = 0; 489 470 } … … 495 476 496 477 bfd_put_32 (input_bfd, (bfd_vma) insn, loc); 497 498 478 break; 499 479 … … 503 483 unsigned_value += val; 504 484 insn = INSERT_HWORD (insn, unsigned_value); 505 bfd_put_32 (input_bfd, insn, loc);485 bfd_put_32 (input_bfd, (bfd_vma) insn, loc); 506 486 break; 507 487 508 488 case R_IHIHALF: 509 489 /* Save the value for the R_IHCONST reloc. */ 510 hihalf = true;490 hihalf = TRUE; 511 491 hihalf_val = val; 512 492 break; … … 518 498 (info, _("missing IHIHALF reloc"), input_bfd, 519 499 input_section, rel->r_vaddr - input_section->vma))) 520 return false;500 return FALSE; 521 501 hihalf_val = 0; 522 502 } … … 528 508 bfd_put_32 (input_bfd, (bfd_vma) insn, loc); 529 509 530 hihalf = false;510 hihalf = FALSE; 531 511 532 512 break; … … 538 518 input_bfd, val, loc); 539 519 if (rstat == bfd_reloc_overflow) 540 overflow = true;520 overflow = TRUE; 541 521 else if (rstat != bfd_reloc_ok) 542 522 abort (); … … 569 549 input_bfd, input_section, 570 550 rel->r_vaddr - input_section->vma))) 571 return false;572 } 573 } 574 575 return true;551 return FALSE; 552 } 553 } 554 555 return TRUE; 576 556 } 577 557 … … 581 561 is actually an addend, not a symbol index at all. */ 582 562 583 static b oolean563 static bfd_boolean 584 564 coff_a29k_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp) 585 565 bfd *obfd ATTRIBUTE_UNUSED; … … 588 568 asection *sec ATTRIBUTE_UNUSED; 589 569 struct internal_reloc *irel; 590 b oolean *adjustedp;570 bfd_boolean *adjustedp; 591 571 { 592 572 if (irel->r_type == R_IHCONST) 593 *adjustedp = true;573 *adjustedp = TRUE; 594 574 else 595 *adjustedp = false;596 return true;575 *adjustedp = FALSE; 576 return TRUE; 597 577 } 598 578 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.