Changeset 609 for branches/GNU/src/binutils/bfd/pe-mips.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/pe-mips.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* BFD back-end for MIPS PE COFF files. 2 2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 3 2000, 2001 Free Software Foundation, Inc.3 2000, 2001, 2002 Free Software Foundation, Inc. 4 4 Modified from coff-i386.c by DJ Delorie, dj@cygnus.com 5 5 … … 22 22 #define COFF_WITH_PE 23 23 #define COFF_LONG_SECTION_NAMES 24 #define PCRELOFFSET true24 #define PCRELOFFSET TRUE 25 25 26 26 #include "bfd.h" … … 41 41 PARAMS ((bfd *, asection *, struct internal_reloc *, 42 42 struct coff_link_hash_entry *, struct internal_syment *, 43 44 43 bfd_vma *)); 45 44 #if 0 46 static void mips_ecoff_swap_reloc_in PARAMS ((bfd *, PTR, 47 struct internal_reloc *)); 48 static void mips_ecoff_swap_reloc_out PARAMS ((bfd *, 49 const struct internal_reloc *, 50 PTR)); 51 static void mips_adjust_reloc_in PARAMS ((bfd *, 52 const struct internal_reloc *, 53 arelent *)); 54 static void mips_adjust_reloc_out PARAMS ((bfd *, const arelent *, 55 struct internal_reloc *)); 56 #endif 45 static void mips_ecoff_swap_reloc_in 46 PARAMS ((bfd *, PTR, struct internal_reloc *)); 47 static void mips_ecoff_swap_reloc_out 48 PARAMS ((bfd *, const struct internal_reloc *, PTR)); 49 static void mips_adjust_reloc_in 50 PARAMS ((bfd *, const struct internal_reloc *, arelent *)); 51 static void mips_adjust_reloc_out 52 PARAMS ((bfd *, const arelent *, struct internal_reloc *)); 53 #endif 54 55 static bfd_boolean in_reloc_p 56 PARAMS ((bfd *, reloc_howto_type *)); 57 static reloc_howto_type * coff_mips_reloc_type_lookup 58 PARAMS ((bfd *, bfd_reloc_code_real_type)); 59 static void mips_swap_reloc_in 60 PARAMS ((bfd *, PTR, PTR)); 61 static unsigned int mips_swap_reloc_out 62 PARAMS ((bfd *, PTR, PTR)); 63 static bfd_boolean coff_pe_mips_relocate_section 64 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 65 struct internal_reloc *, struct internal_syment *, asection **)); 66 57 67 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2) 58 68 /* The page size is a guess based on ELF. */ … … 145 155 short x = bfd_get_16 (abfd, addr); 146 156 DOIT (x); 147 bfd_put_16 (abfd, x, addr);157 bfd_put_16 (abfd, (bfd_vma) x, addr); 148 158 } 149 159 break; … … 153 163 long x = bfd_get_32 (abfd, addr); 154 164 DOIT (x); 155 bfd_put_32 (abfd, x, addr);165 bfd_put_32 (abfd, (bfd_vma) x, addr); 156 166 } 157 167 break; … … 167 177 168 178 #ifdef COFF_WITH_PE 169 /* Return trueif this relocation should179 /* Return TRUE if this relocation should 170 180 appear in the output .reloc section. */ 171 181 172 static boolean in_reloc_p(abfd, howto) 182 static bfd_boolean 183 in_reloc_p (abfd, howto) 173 184 bfd * abfd ATTRIBUTE_UNUSED; 174 185 reloc_howto_type *howto; … … 179 190 180 191 #ifndef PCRELOFFSET 181 #define PCRELOFFSET false192 #define PCRELOFFSET FALSE 182 193 #endif 183 194 … … 191 202 0, /* size (0 = byte, 1 = short, 2 = long) */ 192 203 8, /* bitsize */ 193 false, /* pc_relative */204 FALSE, /* pc_relative */ 194 205 0, /* bitpos */ 195 206 complain_overflow_dont, /* complain_on_overflow */ 196 207 0, /* special_function */ 197 208 "IGNORE", /* name */ 198 false, /* partial_inplace */209 FALSE, /* partial_inplace */ 199 210 0, /* src_mask */ 200 211 0, /* dst_mask */ 201 false), /* pcrel_offset */212 FALSE), /* pcrel_offset */ 202 213 203 214 /* A 16 bit reference to a symbol, normally from a data section. */ … … 206 217 1, /* size (0 = byte, 1 = short, 2 = long) */ 207 218 16, /* bitsize */ 208 false, /* pc_relative */219 FALSE, /* pc_relative */ 209 220 0, /* bitpos */ 210 221 complain_overflow_bitfield, /* complain_on_overflow */ 211 222 coff_mips_reloc, /* special_function */ 212 223 "REFHALF", /* name */ 213 true, /* partial_inplace */224 TRUE, /* partial_inplace */ 214 225 0xffff, /* src_mask */ 215 226 0xffff, /* dst_mask */ 216 false), /* pcrel_offset */227 FALSE), /* pcrel_offset */ 217 228 218 229 /* A 32 bit reference to a symbol, normally from a data section. */ … … 221 232 2, /* size (0 = byte, 1 = short, 2 = long) */ 222 233 32, /* bitsize */ 223 false, /* pc_relative */234 FALSE, /* pc_relative */ 224 235 0, /* bitpos */ 225 236 complain_overflow_bitfield, /* complain_on_overflow */ 226 237 coff_mips_reloc, /* special_function */ 227 238 "REFWORD", /* name */ 228 true, /* partial_inplace */239 TRUE, /* partial_inplace */ 229 240 0xffffffff, /* src_mask */ 230 241 0xffffffff, /* dst_mask */ 231 false), /* pcrel_offset */242 FALSE), /* pcrel_offset */ 232 243 233 244 /* A 26 bit absolute jump address. */ … … 236 247 2, /* size (0 = byte, 1 = short, 2 = long) */ 237 248 26, /* bitsize */ 238 false, /* pc_relative */249 FALSE, /* pc_relative */ 239 250 0, /* bitpos */ 240 251 complain_overflow_dont, /* complain_on_overflow */ … … 244 255 coff_mips_reloc, /* special_function */ 245 256 "JMPADDR", /* name */ 246 true, /* partial_inplace */257 TRUE, /* partial_inplace */ 247 258 0x3ffffff, /* src_mask */ 248 259 0x3ffffff, /* dst_mask */ 249 false), /* pcrel_offset */260 FALSE), /* pcrel_offset */ 250 261 251 262 /* The high 16 bits of a symbol value. Handled by the function … … 255 266 2, /* size (0 = byte, 1 = short, 2 = long) */ 256 267 16, /* bitsize */ 257 false, /* pc_relative */268 FALSE, /* pc_relative */ 258 269 0, /* bitpos */ 259 270 complain_overflow_bitfield, /* complain_on_overflow */ 260 271 coff_mips_reloc, /* special_function */ 261 272 "REFHI", /* name */ 262 true, /* partial_inplace */273 TRUE, /* partial_inplace */ 263 274 0xffff, /* src_mask */ 264 275 0xffff, /* dst_mask */ 265 false), /* pcrel_offset */276 FALSE), /* pcrel_offset */ 266 277 267 278 /* The low 16 bits of a symbol value. */ … … 270 281 2, /* size (0 = byte, 1 = short, 2 = long) */ 271 282 16, /* bitsize */ 272 false, /* pc_relative */283 FALSE, /* pc_relative */ 273 284 0, /* bitpos */ 274 285 complain_overflow_dont, /* complain_on_overflow */ 275 286 coff_mips_reloc, /* special_function */ 276 287 "REFLO", /* name */ 277 true, /* partial_inplace */288 TRUE, /* partial_inplace */ 278 289 0xffff, /* src_mask */ 279 290 0xffff, /* dst_mask */ 280 false), /* pcrel_offset */291 FALSE), /* pcrel_offset */ 281 292 282 293 /* A reference to an offset from the gp register. Handled by the … … 286 297 2, /* size (0 = byte, 1 = short, 2 = long) */ 287 298 16, /* bitsize */ 288 false, /* pc_relative */299 FALSE, /* pc_relative */ 289 300 0, /* bitpos */ 290 301 complain_overflow_signed, /* complain_on_overflow */ 291 302 coff_mips_reloc, /* special_function */ 292 303 "GPREL", /* name */ 293 true, /* partial_inplace */304 TRUE, /* partial_inplace */ 294 305 0xffff, /* src_mask */ 295 306 0xffff, /* dst_mask */ 296 false), /* pcrel_offset */307 FALSE), /* pcrel_offset */ 297 308 298 309 /* A reference to a literal using an offset from the gp register. … … 302 313 2, /* size (0 = byte, 1 = short, 2 = long) */ 303 314 16, /* bitsize */ 304 false, /* pc_relative */315 FALSE, /* pc_relative */ 305 316 0, /* bitpos */ 306 317 complain_overflow_signed, /* complain_on_overflow */ 307 318 coff_mips_reloc, /* special_function */ 308 319 "LITERAL", /* name */ 309 true, /* partial_inplace */320 TRUE, /* partial_inplace */ 310 321 0xffff, /* src_mask */ 311 322 0xffff, /* dst_mask */ 312 false), /* pcrel_offset */323 FALSE), /* pcrel_offset */ 313 324 314 325 EMPTY_HOWTO (8), … … 342 353 2, /* size (0 = byte, 1 = short, 2 = long) */ 343 354 32, /* bitsize */ 344 false, /* pc_relative */355 FALSE, /* pc_relative */ 345 356 0, /* bitpos */ 346 357 complain_overflow_bitfield, /* complain_on_overflow */ 347 358 coff_mips_reloc, /* special_function */ 348 359 "rva32", /* name */ 349 true, /* partial_inplace */360 TRUE, /* partial_inplace */ 350 361 0xffffffff, /* src_mask */ 351 362 0xffffffff, /* dst_mask */ 352 false), /* pcrel_offset */363 FALSE), /* pcrel_offset */ 353 364 EMPTY_HOWTO (35), 354 365 EMPTY_HOWTO (36), … … 357 368 2, /* size (0 = byte, 1 = short, 2 = long) */ 358 369 32, /* bitsize */ 359 false, /* pc_relative */370 FALSE, /* pc_relative */ 360 371 0, /* bitpos */ 361 372 complain_overflow_bitfield, /* complain_on_overflow */ 362 373 coff_mips_reloc, /* special_function */ 363 374 "PAIR", /* name */ 364 true, /* partial_inplace */375 TRUE, /* partial_inplace */ 365 376 0xffffffff, /* src_mask */ 366 377 0xffffffff, /* dst_mask */ 367 false), /* pcrel_offset */378 FALSE), /* pcrel_offset */ 368 379 }; 369 380 … … 518 529 mips_type = MIPS_R_REFLO; 519 530 break; 520 case BFD_RELOC_ MIPS_GPREL:531 case BFD_RELOC_GPREL16: 521 532 mips_type = MIPS_R_GPREL; 522 533 break; … … 558 569 struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; 559 570 560 reloc_dst->r_vaddr = bfd_h_get_32(abfd, (bfd_byte *)reloc_src->r_vaddr); 561 reloc_dst->r_symndx = 562 bfd_h_get_signed_32(abfd, (bfd_byte *) reloc_src->r_symndx); 563 reloc_dst->r_type = bfd_h_get_16(abfd, (bfd_byte *) reloc_src->r_type); 571 reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); 572 reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); 573 reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); 564 574 reloc_dst->r_size = 0; 565 575 reloc_dst->r_extern = 0; … … 605 615 PAIR reloc and output it accordingly. The symndx is really 606 616 the low 16 bits of the addend */ 607 bfd_h_put_32 (abfd, reloc_src->r_vaddr, 608 (bfd_byte *) reloc_dst->r_vaddr); 609 bfd_h_put_32 (abfd, reloc_src->r_symndx, 610 (bfd_byte *) reloc_dst->r_symndx); 611 612 bfd_h_put_16(abfd, MIPS_R_PAIR, (bfd_byte *) 613 reloc_dst->r_type); 617 H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr); 618 H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx); 619 H_PUT_16 (abfd, MIPS_R_PAIR, reloc_dst->r_type); 614 620 return RELSZ; 615 621 } … … 617 623 } 618 624 619 bfd_h_put_32(abfd, reloc_src->r_vaddr, (bfd_byte *) reloc_dst->r_vaddr); 620 bfd_h_put_32(abfd, reloc_src->r_symndx, (bfd_byte *) reloc_dst->r_symndx); 621 622 bfd_h_put_16(abfd, reloc_src->r_type, (bfd_byte *) 623 reloc_dst->r_type); 625 H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr); 626 H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx); 627 628 H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type); 624 629 return RELSZ; 625 630 } … … 629 634 #define NO_COFF_RELOCS 630 635 631 static b oolean636 static bfd_boolean 632 637 coff_pe_mips_relocate_section (output_bfd, info, input_bfd, 633 638 input_section, contents, relocs, syms, … … 643 648 { 644 649 bfd_vma gp; 645 b oolean gp_undefined;650 bfd_boolean gp_undefined; 646 651 size_t adjust; 647 652 struct internal_reloc *rel; 648 653 struct internal_reloc *rel_end; 649 654 unsigned int i; 650 b oolean got_lo;655 bfd_boolean got_lo; 651 656 652 657 if (info->relocateable) … … 654 659 (*_bfd_error_handler) (_("\ 655 660 %s: `ld -r' not supported with PE MIPS objects\n"), 656 bfd_get_filename (input_bfd));661 bfd_archive_filename (input_bfd)); 657 662 bfd_set_error (bfd_error_bad_value); 658 return false;663 return FALSE; 659 664 } 660 665 … … 670 675 gp = _bfd_get_gp_value (output_bfd); 671 676 if (gp == 0) 672 gp_undefined = true;677 gp_undefined = TRUE; 673 678 else 674 gp_undefined = false;675 676 got_lo = false;679 gp_undefined = FALSE; 680 681 got_lo = FALSE; 677 682 678 683 adjust = 0; … … 716 721 sym, &addend); 717 722 if (howto == NULL) 718 return false;723 return FALSE; 719 724 720 725 /* If we are doing a relocateable link, then we can just ignore … … 768 773 if (! ((*info->callbacks->undefined_symbol) 769 774 (info, h->root.root.string, input_bfd, input_section, 770 rel->r_vaddr - input_section->vma, true)))771 return false;775 rel->r_vaddr - input_section->vma, TRUE))) 776 return FALSE; 772 777 } 773 778 } … … 789 794 790 795 #define UI(x) (*_bfd_error_handler) (_("%s: unimplemented %s\n"), \ 791 bfd_get_filename (input_bfd), x); \796 bfd_archive_filename (input_bfd), x); \ 792 797 bfd_set_error (bfd_error_bad_value); 793 798 … … 815 820 { 816 821 (*_bfd_error_handler) (_("%s: jump too far away\n"), 817 bfd_get_filename (input_bfd));822 bfd_archive_filename (input_bfd)); 818 823 bfd_set_error (bfd_error_bad_value); 819 return false;824 return FALSE; 820 825 } 821 826 tmp &= 0xfc000000; … … 842 847 default: 843 848 (*_bfd_error_handler) (_("%s: bad pair/reflo after refhi\n"), 844 bfd_get_filename (input_bfd));849 bfd_archive_filename (input_bfd)); 845 850 bfd_set_error (bfd_error_bad_value); 846 return false;851 return FALSE; 847 852 } 848 853 tmp &= 0xffff0000; … … 895 900 } 896 901 897 return true;902 return TRUE; 898 903 } 899 904 … … 906 911 we treat all symbols starting with L as local. */ 907 912 908 static boolean coff_mips_is_local_label_name PARAMS ((bfd *, const char *)); 909 910 static boolean 913 static bfd_boolean coff_mips_is_local_label_name 914 PARAMS ((bfd *, const char *)); 915 916 static bfd_boolean 911 917 coff_mips_is_local_label_name (abfd, name) 912 918 bfd *abfd; … … 914 920 { 915 921 if (name[0] == 'L') 916 return true;922 return TRUE; 917 923 918 924 return _bfd_coff_is_local_label_name (abfd, name); -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.