Changeset 609 for branches/GNU/src/binutils/bfd/coff-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/coff-mips.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* BFD back-end for MIPS Extended-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 Original version by Per Bothner. … … 37 37 /* Prototypes for static functions. */ 38 38 39 static boolean mips_ecoff_bad_format_hook PARAMS ((bfd *abfd, PTR filehdr)); 40 static void mips_ecoff_swap_reloc_in PARAMS ((bfd *, PTR, 41 struct internal_reloc *)); 42 static void mips_ecoff_swap_reloc_out PARAMS ((bfd *, 43 const struct internal_reloc *, 44 PTR)); 45 static void mips_adjust_reloc_in PARAMS ((bfd *, 46 const struct internal_reloc *, 47 arelent *)); 48 static void mips_adjust_reloc_out PARAMS ((bfd *, const arelent *, 49 struct internal_reloc *)); 50 static bfd_reloc_status_type mips_generic_reloc PARAMS ((bfd *abfd, 51 arelent *reloc, 52 asymbol *symbol, 53 PTR data, 54 asection *section, 55 bfd *output_bfd, 56 char **error)); 57 static bfd_reloc_status_type mips_refhi_reloc PARAMS ((bfd *abfd, 58 arelent *reloc, 59 asymbol *symbol, 60 PTR data, 61 asection *section, 62 bfd *output_bfd, 63 char **error)); 64 static bfd_reloc_status_type mips_reflo_reloc PARAMS ((bfd *abfd, 65 arelent *reloc, 66 asymbol *symbol, 67 PTR data, 68 asection *section, 69 bfd *output_bfd, 70 char **error)); 71 static bfd_reloc_status_type mips_gprel_reloc PARAMS ((bfd *abfd, 72 arelent *reloc, 73 asymbol *symbol, 74 PTR data, 75 asection *section, 76 bfd *output_bfd, 77 char **error)); 78 static bfd_reloc_status_type mips_relhi_reloc PARAMS ((bfd *abfd, 79 arelent *reloc, 80 asymbol *symbol, 81 PTR data, 82 asection *section, 83 bfd *output_bfd, 84 char **error)); 85 static bfd_reloc_status_type mips_rello_reloc PARAMS ((bfd *abfd, 86 arelent *reloc, 87 asymbol *symbol, 88 PTR data, 89 asection *section, 90 bfd *output_bfd, 91 char **error)); 92 static bfd_reloc_status_type mips_switch_reloc PARAMS ((bfd *abfd, 93 arelent *reloc, 94 asymbol *symbol, 95 PTR data, 96 asection *section, 97 bfd *output_bfd, 98 char **error)); 99 static void mips_relocate_hi PARAMS ((struct internal_reloc *refhi, 100 struct internal_reloc *reflo, 101 bfd *input_bfd, 102 asection *input_section, 103 bfd_byte *contents, 104 size_t adjust, 105 bfd_vma relocation, 106 boolean pcrel)); 107 static boolean mips_relocate_section PARAMS ((bfd *, struct bfd_link_info *, 108 bfd *, asection *, 109 bfd_byte *, PTR)); 110 static boolean mips_read_relocs PARAMS ((bfd *, asection *)); 111 static boolean mips_relax_section PARAMS ((bfd *, asection *, 112 struct bfd_link_info *, 113 boolean *)); 114 static boolean mips_relax_pcrel16 PARAMS ((struct bfd_link_info *, bfd *, 115 asection *, 116 struct ecoff_link_hash_entry *, 117 bfd_byte *, bfd_vma)); 39 static bfd_boolean mips_ecoff_bad_format_hook 40 PARAMS ((bfd *abfd, PTR filehdr)); 41 static void mips_ecoff_swap_reloc_in 42 PARAMS ((bfd *, PTR, struct internal_reloc *)); 43 static void mips_ecoff_swap_reloc_out 44 PARAMS ((bfd *, const struct internal_reloc *, PTR)); 45 static void mips_adjust_reloc_in 46 PARAMS ((bfd *, const struct internal_reloc *, arelent *)); 47 static void mips_adjust_reloc_out 48 PARAMS ((bfd *, const arelent *, struct internal_reloc *)); 49 static bfd_reloc_status_type mips_generic_reloc 50 PARAMS ((bfd *abfd, arelent *reloc, asymbol *symbol, PTR data, 51 asection *section, bfd *output_bfd, char **error)); 52 static bfd_reloc_status_type mips_refhi_reloc 53 PARAMS ((bfd *abfd, arelent *reloc, asymbol *symbol, PTR data, 54 asection *section, bfd *output_bfd, char **error)); 55 static bfd_reloc_status_type mips_reflo_reloc 56 PARAMS ((bfd *abfd, arelent *reloc, asymbol *symbol, PTR data, 57 asection *section, bfd *output_bfd, char **error)); 58 static bfd_reloc_status_type mips_gprel_reloc 59 PARAMS ((bfd *abfd, arelent *reloc, asymbol *symbol, PTR data, 60 asection *section, bfd *output_bfd, char **error)); 61 static bfd_reloc_status_type mips_relhi_reloc 62 PARAMS ((bfd *abfd, arelent *reloc, asymbol *symbol, PTR data, 63 asection *section, bfd *output_bfd, char **error)); 64 static bfd_reloc_status_type mips_rello_reloc 65 PARAMS ((bfd *abfd, arelent *reloc, asymbol *symbol, PTR data, 66 asection *section, bfd *output_bfd, char **error)); 67 static bfd_reloc_status_type mips_switch_reloc 68 PARAMS ((bfd *abfd, arelent *reloc, asymbol *symbol, PTR data, 69 asection *section, bfd *output_bfd, char **error)); 70 static void mips_relocate_hi 71 PARAMS ((struct internal_reloc *refhi, struct internal_reloc *reflo, 72 bfd *input_bfd, asection *input_section, bfd_byte *contents, 73 size_t adjust, bfd_vma relocation, bfd_boolean pcrel)); 74 static bfd_boolean mips_relocate_section 75 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, PTR)); 76 static bfd_boolean mips_read_relocs 77 PARAMS ((bfd *, asection *)); 78 static bfd_boolean mips_relax_section 79 PARAMS ((bfd *, asection *, struct bfd_link_info *, bfd_boolean *)); 80 static bfd_boolean mips_relax_pcrel16 81 PARAMS ((struct bfd_link_info *, bfd *, asection *, 82 struct ecoff_link_hash_entry *, bfd_byte *, bfd_vma)); 118 83 static reloc_howto_type *mips_bfd_reloc_type_lookup 119 84 PARAMS ((bfd *, bfd_reloc_code_real_type)); … … 156 121 0, /* size (0 = byte, 1 = short, 2 = long) */ 157 122 8, /* bitsize */ 158 false, /* pc_relative */123 FALSE, /* pc_relative */ 159 124 0, /* bitpos */ 160 125 complain_overflow_dont, /* complain_on_overflow */ 161 126 0, /* special_function */ 162 127 "IGNORE", /* name */ 163 false, /* partial_inplace */128 FALSE, /* partial_inplace */ 164 129 0, /* src_mask */ 165 130 0, /* dst_mask */ 166 false), /* pcrel_offset */131 FALSE), /* pcrel_offset */ 167 132 168 133 /* A 16 bit reference to a symbol, normally from a data section. */ … … 171 136 1, /* size (0 = byte, 1 = short, 2 = long) */ 172 137 16, /* bitsize */ 173 false, /* pc_relative */138 FALSE, /* pc_relative */ 174 139 0, /* bitpos */ 175 140 complain_overflow_bitfield, /* complain_on_overflow */ 176 141 mips_generic_reloc, /* special_function */ 177 142 "REFHALF", /* name */ 178 true, /* partial_inplace */143 TRUE, /* partial_inplace */ 179 144 0xffff, /* src_mask */ 180 145 0xffff, /* dst_mask */ 181 false), /* pcrel_offset */146 FALSE), /* pcrel_offset */ 182 147 183 148 /* A 32 bit reference to a symbol, normally from a data section. */ … … 186 151 2, /* size (0 = byte, 1 = short, 2 = long) */ 187 152 32, /* bitsize */ 188 false, /* pc_relative */153 FALSE, /* pc_relative */ 189 154 0, /* bitpos */ 190 155 complain_overflow_bitfield, /* complain_on_overflow */ 191 156 mips_generic_reloc, /* special_function */ 192 157 "REFWORD", /* name */ 193 true, /* partial_inplace */158 TRUE, /* partial_inplace */ 194 159 0xffffffff, /* src_mask */ 195 160 0xffffffff, /* dst_mask */ 196 false), /* pcrel_offset */161 FALSE), /* pcrel_offset */ 197 162 198 163 /* A 26 bit absolute jump address. */ … … 201 166 2, /* size (0 = byte, 1 = short, 2 = long) */ 202 167 26, /* bitsize */ 203 false, /* pc_relative */168 FALSE, /* pc_relative */ 204 169 0, /* bitpos */ 205 170 complain_overflow_dont, /* complain_on_overflow */ … … 209 174 mips_generic_reloc, /* special_function */ 210 175 "JMPADDR", /* name */ 211 true, /* partial_inplace */176 TRUE, /* partial_inplace */ 212 177 0x3ffffff, /* src_mask */ 213 178 0x3ffffff, /* dst_mask */ 214 false), /* pcrel_offset */179 FALSE), /* pcrel_offset */ 215 180 216 181 /* The high 16 bits of a symbol value. Handled by the function … … 220 185 2, /* size (0 = byte, 1 = short, 2 = long) */ 221 186 16, /* bitsize */ 222 false, /* pc_relative */187 FALSE, /* pc_relative */ 223 188 0, /* bitpos */ 224 189 complain_overflow_bitfield, /* complain_on_overflow */ 225 190 mips_refhi_reloc, /* special_function */ 226 191 "REFHI", /* name */ 227 true, /* partial_inplace */192 TRUE, /* partial_inplace */ 228 193 0xffff, /* src_mask */ 229 194 0xffff, /* dst_mask */ 230 false), /* pcrel_offset */195 FALSE), /* pcrel_offset */ 231 196 232 197 /* The low 16 bits of a symbol value. */ … … 235 200 2, /* size (0 = byte, 1 = short, 2 = long) */ 236 201 16, /* bitsize */ 237 false, /* pc_relative */202 FALSE, /* pc_relative */ 238 203 0, /* bitpos */ 239 204 complain_overflow_dont, /* complain_on_overflow */ 240 205 mips_reflo_reloc, /* special_function */ 241 206 "REFLO", /* name */ 242 true, /* partial_inplace */207 TRUE, /* partial_inplace */ 243 208 0xffff, /* src_mask */ 244 209 0xffff, /* dst_mask */ 245 false), /* pcrel_offset */210 FALSE), /* pcrel_offset */ 246 211 247 212 /* A reference to an offset from the gp register. Handled by the … … 251 216 2, /* size (0 = byte, 1 = short, 2 = long) */ 252 217 16, /* bitsize */ 253 false, /* pc_relative */218 FALSE, /* pc_relative */ 254 219 0, /* bitpos */ 255 220 complain_overflow_signed, /* complain_on_overflow */ 256 221 mips_gprel_reloc, /* special_function */ 257 222 "GPREL", /* name */ 258 true, /* partial_inplace */223 TRUE, /* partial_inplace */ 259 224 0xffff, /* src_mask */ 260 225 0xffff, /* dst_mask */ 261 false), /* pcrel_offset */226 FALSE), /* pcrel_offset */ 262 227 263 228 /* A reference to a literal using an offset from the gp register. … … 267 232 2, /* size (0 = byte, 1 = short, 2 = long) */ 268 233 16, /* bitsize */ 269 false, /* pc_relative */234 FALSE, /* pc_relative */ 270 235 0, /* bitpos */ 271 236 complain_overflow_signed, /* complain_on_overflow */ 272 237 mips_gprel_reloc, /* special_function */ 273 238 "LITERAL", /* name */ 274 true, /* partial_inplace */239 TRUE, /* partial_inplace */ 275 240 0xffff, /* src_mask */ 276 241 0xffff, /* dst_mask */ 277 false), /* pcrel_offset */242 FALSE), /* pcrel_offset */ 278 243 279 244 EMPTY_HOWTO (8), … … 290 255 2, /* size (0 = byte, 1 = short, 2 = long) */ 291 256 16, /* bitsize */ 292 true, /* pc_relative */257 TRUE, /* pc_relative */ 293 258 0, /* bitpos */ 294 259 complain_overflow_signed, /* complain_on_overflow */ 295 260 mips_generic_reloc, /* special_function */ 296 261 "PCREL16", /* name */ 297 true, /* partial_inplace */262 TRUE, /* partial_inplace */ 298 263 0xffff, /* src_mask */ 299 264 0xffff, /* dst_mask */ 300 true), /* pcrel_offset */265 TRUE), /* pcrel_offset */ 301 266 302 267 /* This reloc is a Cygnus extension used when generating position … … 311 276 2, /* size (0 = byte, 1 = short, 2 = long) */ 312 277 16, /* bitsize */ 313 true, /* pc_relative */278 TRUE, /* pc_relative */ 314 279 0, /* bitpos */ 315 280 complain_overflow_bitfield, /* complain_on_overflow */ 316 281 mips_relhi_reloc, /* special_function */ 317 282 "RELHI", /* name */ 318 true, /* partial_inplace */283 TRUE, /* partial_inplace */ 319 284 0xffff, /* src_mask */ 320 285 0xffff, /* dst_mask */ 321 true), /* pcrel_offset */286 TRUE), /* pcrel_offset */ 322 287 323 288 /* This reloc is a Cygnus extension used when generating position … … 328 293 2, /* size (0 = byte, 1 = short, 2 = long) */ 329 294 16, /* bitsize */ 330 true, /* pc_relative */295 TRUE, /* pc_relative */ 331 296 0, /* bitpos */ 332 297 complain_overflow_dont, /* complain_on_overflow */ 333 298 mips_rello_reloc, /* special_function */ 334 299 "RELLO", /* name */ 335 true, /* partial_inplace */300 TRUE, /* partial_inplace */ 336 301 0xffff, /* src_mask */ 337 302 0xffff, /* dst_mask */ 338 true), /* pcrel_offset */303 TRUE), /* pcrel_offset */ 339 304 340 305 EMPTY_HOWTO (15), … … 356 321 2, /* size (0 = byte, 1 = short, 2 = long) */ 357 322 32, /* bitsize */ 358 true, /* pc_relative */323 TRUE, /* pc_relative */ 359 324 0, /* bitpos */ 360 325 complain_overflow_dont, /* complain_on_overflow */ 361 326 mips_switch_reloc, /* special_function */ 362 327 "SWITCH", /* name */ 363 true, /* partial_inplace */328 TRUE, /* partial_inplace */ 364 329 0xffffffff, /* src_mask */ 365 330 0xffffffff, /* dst_mask */ 366 true) /* pcrel_offset */331 TRUE) /* pcrel_offset */ 367 332 }; 368 333 … … 370 335 (sizeof mips_howto_table / sizeof mips_howto_table[0]) 371 336 372 /* When the linker is doing relaxing, it may change a external PCREL16337 /* When the linker is doing relaxing, it may change an external PCREL16 373 338 reloc. This typically represents an instruction like 374 339 bal foo … … 389 354 /* See whether the magic number matches. */ 390 355 391 static b oolean356 static bfd_boolean 392 357 mips_ecoff_bad_format_hook (abfd, filehdr) 393 358 bfd *abfd; … … 400 365 case MIPS_MAGIC_1: 401 366 /* I don't know what endianness this implies. */ 402 return true;367 return TRUE; 403 368 404 369 case MIPS_MAGIC_BIG: … … 413 378 414 379 default: 415 return false;380 return FALSE; 416 381 } 417 382 } … … 432 397 const RELOC *ext = (RELOC *) ext_ptr; 433 398 434 intern->r_vaddr = bfd_h_get_32 (abfd, (bfd_byte *)ext->r_vaddr);399 intern->r_vaddr = H_GET_32 (abfd, ext->r_vaddr); 435 400 if (bfd_header_big_endian (abfd)) 436 401 { … … 509 474 } 510 475 511 bfd_h_put_32 (abfd, intern->r_vaddr, (bfd_byte *)ext->r_vaddr);476 H_PUT_32 (abfd, intern->r_vaddr, ext->r_vaddr); 512 477 if (bfd_header_big_endian (abfd)) 513 478 { … … 697 662 698 663 /* Save the information, and let REFLO do the actual relocation. */ 699 n = (struct mips_hi *) bfd_malloc ( sizeof *n);664 n = (struct mips_hi *) bfd_malloc ((bfd_size_type) sizeof *n); 700 665 if (n == NULL) 701 666 return bfd_reloc_outofrange; … … 764 729 val += 0x10000; 765 730 766 insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff);767 bfd_put_32 (abfd, insn, l->addr);731 insn = (insn &~ (unsigned) 0xffff) | ((val >> 16) & 0xffff); 732 bfd_put_32 (abfd, (bfd_vma) insn, l->addr); 768 733 769 734 next = l->next; … … 799 764 char **error_message; 800 765 { 801 b oolean relocateable;766 bfd_boolean relocateable; 802 767 bfd_vma gp; 803 768 bfd_vma relocation; … … 818 783 819 784 if (output_bfd != (bfd *) NULL) 820 relocateable = true;785 relocateable = TRUE; 821 786 else 822 787 { 823 relocateable = false;788 relocateable = FALSE; 824 789 output_bfd = symbol->section->output_section->owner; 825 790 } 826 791 827 if (bfd_is_und_section (symbol->section) 828 && relocateable == false) 792 if (bfd_is_und_section (symbol->section) && ! relocateable) 829 793 return bfd_reloc_undefined; 830 794 … … 836 800 gp = _bfd_get_gp_value (output_bfd); 837 801 if (gp == 0 838 && ( relocateable == false802 && (! relocateable 839 803 || (symbol->flags & BSF_SECTION_SYM) != 0)) 840 804 { 841 if (relocateable != false)805 if (relocateable) 842 806 { 843 807 /* Make up a value. */ … … 860 824 for (i = 0; i < count; i++, sym++) 861 825 { 862 register CONSTchar *name;826 register const char *name; 863 827 864 828 name = bfd_asymbol_name (*sym); … … 905 869 are producing relocateable output, we don't want to do this for 906 870 an external symbol. */ 907 if ( relocateable == false871 if (! relocateable 908 872 || (symbol->flags & BSF_SECTION_SYM) != 0) 909 873 val += relocation - gp; 910 874 911 insn = (insn &~ 0xffff) | (val & 0xffff);912 bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);913 914 if (relocateable != false)875 insn = (insn &~ (unsigned) 0xffff) | (val & 0xffff); 876 bfd_put_32 (abfd, (bfd_vma) insn, (bfd_byte *) data + reloc_entry->address); 877 878 if (relocateable) 915 879 reloc_entry->address += input_section->output_offset; 916 880 … … 988 952 989 953 /* Save the information, and let RELLO do the actual relocation. */ 990 n = (struct mips_hi *) bfd_malloc ( sizeof *n);954 n = (struct mips_hi *) bfd_malloc ((bfd_size_type) sizeof *n); 991 955 if (n == NULL) 992 956 return bfd_reloc_outofrange; … … 1065 1029 val += 0x10000; 1066 1030 1067 insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff);1068 bfd_put_32 (abfd, insn, l->addr);1031 insn = (insn &~ (unsigned) 0xffff) | ((val >> 16) & 0xffff); 1032 bfd_put_32 (abfd, (bfd_vma) insn, l->addr); 1069 1033 1070 1034 next = l->next; … … 1152 1116 mips_type = MIPS_R_REFLO; 1153 1117 break; 1154 case BFD_RELOC_ MIPS_GPREL:1118 case BFD_RELOC_GPREL16: 1155 1119 mips_type = MIPS_R_GPREL; 1156 1120 break; … … 1193 1157 size_t adjust; 1194 1158 bfd_vma relocation; 1195 b oolean pcrel;1159 bfd_boolean pcrel; 1196 1160 { 1197 1161 unsigned long insn; … … 1230 1194 val += 0x10000; 1231 1195 1232 insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff);1196 insn = (insn &~ (unsigned) 0xffff) | ((val >> 16) & 0xffff); 1233 1197 bfd_put_32 (input_bfd, (bfd_vma) insn, 1234 1198 contents + adjust + refhi->r_vaddr - input_section->vma); … … 1237 1201 /* Relocate a section while linking a MIPS ECOFF file. */ 1238 1202 1239 static b oolean1203 static bfd_boolean 1240 1204 mips_relocate_section (output_bfd, info, input_bfd, input_section, 1241 1205 contents, external_relocs) … … 1250 1214 struct ecoff_link_hash_entry **sym_hashes; 1251 1215 bfd_vma gp; 1252 b oolean gp_undefined;1216 bfd_boolean gp_undefined; 1253 1217 size_t adjust; 1254 1218 long *offsets; … … 1256 1220 struct external_reloc *ext_rel_end; 1257 1221 unsigned int i; 1258 b oolean got_lo;1222 bfd_boolean got_lo; 1259 1223 struct internal_reloc lo_int_rel; 1224 bfd_size_type amt; 1260 1225 1261 1226 BFD_ASSERT (input_bfd->xvec->byteorder … … 1268 1233 if (symndx_to_section == (asection **) NULL) 1269 1234 { 1270 symndx_to_section = ((asection **) 1271 bfd_alloc (input_bfd, 1272 (NUM_RELOC_SECTIONS 1273 * sizeof (asection *)))); 1235 amt = NUM_RELOC_SECTIONS * sizeof (asection *); 1236 symndx_to_section = (asection **) bfd_alloc (input_bfd, amt); 1274 1237 if (!symndx_to_section) 1275 return false;1238 return FALSE; 1276 1239 1277 1240 symndx_to_section[RELOC_SECTION_NONE] = NULL; … … 1308 1271 gp = _bfd_get_gp_value (output_bfd); 1309 1272 if (gp == 0) 1310 gp_undefined = true;1273 gp_undefined = TRUE; 1311 1274 else 1312 gp_undefined = false;1313 1314 got_lo = false;1275 gp_undefined = FALSE; 1276 1277 got_lo = FALSE; 1315 1278 1316 1279 adjust = 0; … … 1326 1289 { 1327 1290 struct internal_reloc int_rel; 1328 b oolean use_lo = false;1291 bfd_boolean use_lo = FALSE; 1329 1292 bfd_vma addend; 1330 1293 reloc_howto_type *howto; … … 1339 1302 { 1340 1303 int_rel = lo_int_rel; 1341 got_lo = false;1304 got_lo = FALSE; 1342 1305 } 1343 1306 … … 1374 1337 && int_rel.r_symndx == lo_int_rel.r_symndx) 1375 1338 { 1376 use_lo = true;1339 use_lo = TRUE; 1377 1340 if (lo_ext_rel == ext_rel + 1) 1378 got_lo = true;1341 got_lo = TRUE; 1379 1342 } 1380 1343 } … … 1438 1401 { 1439 1402 if (! ((*info->callbacks->reloc_dangerous) 1440 (info, _("GP relative relocation when GP not defined"),1403 (info, _("GP relative relocation used when GP not defined"), 1441 1404 input_bfd, input_section, 1442 1405 int_rel.r_vaddr - input_section->vma))) 1443 return false;1406 return FALSE; 1444 1407 /* Only give the error once per link. */ 1445 1408 gp = 4; 1446 1409 _bfd_set_gp_value (output_bfd, gp); 1447 gp_undefined = false;1410 gp_undefined = FALSE; 1448 1411 } 1449 1412 if (! int_rel.r_extern) … … 1520 1483 - input_section->vma) 1521 1484 + adjust))) 1522 return false;1485 return FALSE; 1523 1486 1524 1487 /* We must adjust everything else up a notch. */ … … 1703 1666 input_section, 1704 1667 int_rel.r_vaddr - input_section->vma))) 1705 return false;1668 return FALSE; 1706 1669 int_rel.r_symndx = 0; 1707 1670 } … … 1787 1750 (info, h->root.root.string, input_bfd, 1788 1751 input_section, 1789 int_rel.r_vaddr - input_section->vma, true)))1790 return false;1752 int_rel.r_vaddr - input_section->vma, TRUE))) 1753 return FALSE; 1791 1754 relocation = 0; 1792 1755 } … … 1869 1832 input_bfd, input_section, 1870 1833 int_rel.r_vaddr - input_section->vma))) 1871 return false;1834 return FALSE; 1872 1835 } 1873 1836 break; … … 1876 1839 } 1877 1840 1878 return true;1841 return TRUE; 1879 1842 } 1880 1843 … … 1882 1845 /* Read in the relocs for a section. */ 1883 1846 1884 static b oolean1847 static bfd_boolean 1885 1848 mips_read_relocs (abfd, sec) 1886 1849 bfd *abfd; … … 1888 1851 { 1889 1852 struct ecoff_section_tdata *section_tdata; 1853 bfd_size_type amt; 1890 1854 1891 1855 section_tdata = ecoff_section_data (abfd, sec); 1892 1856 if (section_tdata == (struct ecoff_section_tdata *) NULL) 1893 1857 { 1894 sec->used_by_bfd =1895 (PTR) bfd_alloc (abfd, sizeof (struct ecoff_section_tdata));1858 amt = sizeof (struct ecoff_section_tdata); 1859 sec->used_by_bfd = (PTR) bfd_alloc (abfd, amt); 1896 1860 if (sec->used_by_bfd == NULL) 1897 return false;1861 return FALSE; 1898 1862 1899 1863 section_tdata = ecoff_section_data (abfd, sec); … … 1905 1869 if (section_tdata->external_relocs == NULL) 1906 1870 { 1907 bfd_size_type external_relocs_size; 1908 1909 external_relocs_size = (ecoff_backend (abfd)->external_reloc_size 1910 * sec->reloc_count); 1911 1912 section_tdata->external_relocs = 1913 (PTR) bfd_alloc (abfd, external_relocs_size); 1914 if (section_tdata->external_relocs == NULL && external_relocs_size != 0) 1915 return false; 1871 amt = ecoff_backend (abfd)->external_reloc_size; 1872 amt *= sec->reloc_count; 1873 section_tdata->external_relocs = (PTR) bfd_alloc (abfd, amt); 1874 if (section_tdata->external_relocs == NULL && amt != 0) 1875 return FALSE; 1916 1876 1917 1877 if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0 1918 || (bfd_read (section_tdata->external_relocs, 1, 1919 external_relocs_size, abfd) 1920 != external_relocs_size)) 1921 return false; 1878 || bfd_bread (section_tdata->external_relocs, amt, abfd) != amt) 1879 return FALSE; 1922 1880 } 1923 1881 1924 return true;1882 return TRUE; 1925 1883 } 1926 1884 … … 1949 1907 offsets. */ 1950 1908 1951 static b oolean1909 static bfd_boolean 1952 1910 mips_relax_section (abfd, sec, info, again) 1953 1911 bfd *abfd; 1954 1912 asection *sec; 1955 1913 struct bfd_link_info *info; 1956 b oolean *again;1914 bfd_boolean *again; 1957 1915 { 1958 1916 struct ecoff_section_tdata *section_tdata; … … 1964 1922 1965 1923 /* Assume we are not going to need another pass. */ 1966 *again = false;1924 *again = FALSE; 1967 1925 1968 1926 /* If we are not generating an ECOFF file, this is much too 1969 1927 confusing to deal with. */ 1970 1928 if (info->hash->creator->flavour != bfd_get_flavour (abfd)) 1971 return true;1929 return TRUE; 1972 1930 1973 1931 /* If there are no relocs, there is nothing to do. */ 1974 1932 if (sec->reloc_count == 0) 1975 return true;1933 return TRUE; 1976 1934 1977 1935 /* We are only interested in PC relative relocs, and why would there 1978 1936 ever be one from anything but the .text section? */ 1979 1937 if (strcmp (bfd_get_section_name (abfd, sec), ".text") != 0) 1980 return true;1938 return TRUE; 1981 1939 1982 1940 /* Read in the relocs, if we haven't already got them. */ … … 2017 1975 struct ecoff_link_hash_entry **adj_h_ptr_end; 2018 1976 struct ecoff_value_adjust *adjust; 1977 bfd_size_type amt; 2019 1978 2020 1979 /* If we have already expanded this reloc, we certainly don't … … 2093 2052 contents = (bfd_byte *) bfd_alloc (abfd, sec->_raw_size); 2094 2053 else 2095 contents = (bfd_byte *) bfd_malloc ( (size_t)sec->_raw_size);2054 contents = (bfd_byte *) bfd_malloc (sec->_raw_size); 2096 2055 if (contents == (bfd_byte *) NULL) 2097 2056 goto error_return; … … 2122 2081 2123 2082 sec->_cooked_size += PCREL16_EXPANSION_ADJUSTMENT; 2124 *again = true;2083 *again = TRUE; 2125 2084 2126 2085 if (offsets == (long *) NULL) 2127 2086 { 2128 size_tsize;2129 2130 size = sec->reloc_count * sizeof (long);2131 offsets = (long *) bfd_ alloc (abfd, size);2087 bfd_size_type size; 2088 2089 size = (bfd_size_type) sec->reloc_count * sizeof (long); 2090 offsets = (long *) bfd_zalloc (abfd, size); 2132 2091 if (offsets == (long *) NULL) 2133 2092 goto error_return; 2134 memset (offsets, 0, size);2135 2093 section_tdata->offsets = offsets; 2136 2094 } … … 2305 2263 by bfd_ecoff_debug_accumulate to adjust the values of 2306 2264 internal symbols and FDR's. */ 2307 a djust = ((struct ecoff_value_adjust *)2308 bfd_alloc (abfd, sizeof (struct ecoff_value_adjust)));2265 amt = sizeof (struct ecoff_value_adjust); 2266 adjust = (struct ecoff_value_adjust *) bfd_alloc (abfd, amt); 2309 2267 if (adjust == (struct ecoff_value_adjust *) NULL) 2310 2268 goto error_return; … … 2321 2279 free (contents); 2322 2280 2323 return true;2281 return TRUE; 2324 2282 2325 2283 error_return: 2326 2284 if (contents != (bfd_byte *) NULL && ! info->keep_memory) 2327 2285 free (contents); 2328 return false;2286 return FALSE; 2329 2287 } 2330 2288 … … 2334 2292 the reloc. */ 2335 2293 2336 static b oolean2294 static bfd_boolean 2337 2295 mips_relax_pcrel16 (info, input_bfd, input_section, h, location, address) 2338 2296 struct bfd_link_info *info ATTRIBUTE_UNUSED; … … 2359 2317 relocation += 0x10000; 2360 2318 2361 bfd_put_32 (input_bfd, 0x04110001, location); /* bal .+8 */2319 bfd_put_32 (input_bfd, (bfd_vma) 0x04110001, location); /* bal .+8 */ 2362 2320 bfd_put_32 (input_bfd, 2363 2321 0x3c010000 | ((relocation >> 16) & 0xffff), /* lui $at,XX */ … … 2366 2324 0x24210000 | (relocation & 0xffff), /* addiu $at,$at,XX */ 2367 2325 location + 8); 2368 bfd_put_32 (input_bfd, 0x003f0821, location + 12); /* addu $at,$at,$ra */ 2369 bfd_put_32 (input_bfd, 0x0020f809, location + 16); /* jalr $at */ 2370 2371 return true; 2326 bfd_put_32 (input_bfd, 2327 (bfd_vma) 0x003f0821, location + 12); /* addu $at,$at,$ra */ 2328 bfd_put_32 (input_bfd, 2329 (bfd_vma) 0x0020f809, location + 16); /* jalr $at */ 2330 2331 return TRUE; 2372 2332 } 2373 2333 … … 2381 2341 -membedded-pic. */ 2382 2342 2383 b oolean2343 bfd_boolean 2384 2344 bfd_mips_ecoff_create_embedded_relocs (abfd, info, datasec, relsec, errmsg) 2385 2345 bfd *abfd; … … 2394 2354 struct external_reloc *ext_rel_end; 2395 2355 bfd_byte *p; 2356 bfd_size_type amt; 2396 2357 2397 2358 BFD_ASSERT (! info->relocateable); … … 2400 2361 2401 2362 if (datasec->reloc_count == 0) 2402 return true;2363 return TRUE; 2403 2364 2404 2365 sym_hashes = ecoff_data (abfd)->sym_hashes; 2405 2366 2406 2367 if (! mips_read_relocs (abfd, datasec)) 2407 return false; 2408 2409 relsec->contents = (bfd_byte *) bfd_alloc (abfd, datasec->reloc_count * 4); 2368 return FALSE; 2369 2370 amt = (bfd_size_type) datasec->reloc_count * 4; 2371 relsec->contents = (bfd_byte *) bfd_alloc (abfd, amt); 2410 2372 if (relsec->contents == NULL) 2411 return false;2373 return FALSE; 2412 2374 2413 2375 p = relsec->contents; … … 2419 2381 { 2420 2382 struct internal_reloc int_rel; 2421 b oolean text_relative;2383 bfd_boolean text_relative; 2422 2384 2423 2385 mips_ecoff_swap_reloc_in (abfd, (PTR) ext_rel, &int_rel); … … 2439 2401 *errmsg = _("unsupported reloc type"); 2440 2402 bfd_set_error (bfd_error_bad_value); 2441 return false;2403 return FALSE; 2442 2404 } 2443 2405 … … 2455 2417 || h->root.type == bfd_link_hash_defweak) 2456 2418 && (h->root.u.def.section->flags & SEC_CODE) != 0) 2457 text_relative = true;2419 text_relative = TRUE; 2458 2420 else 2459 text_relative = false;2421 text_relative = FALSE; 2460 2422 } 2461 2423 else … … 2464 2426 { 2465 2427 case RELOC_SECTION_TEXT: 2466 text_relative = true;2428 text_relative = TRUE; 2467 2429 break; 2468 2430 case RELOC_SECTION_SDATA: 2469 2431 case RELOC_SECTION_SBSS: 2470 2432 case RELOC_SECTION_LIT8: 2471 text_relative = false;2433 text_relative = FALSE; 2472 2434 break; 2473 2435 default: … … 2476 2438 *errmsg = _("reloc against unsupported section"); 2477 2439 bfd_set_error (bfd_error_bad_value); 2478 return false;2440 return FALSE; 2479 2441 } 2480 2442 } … … 2484 2446 *errmsg = _("reloc not properly aligned"); 2485 2447 bfd_set_error (bfd_error_bad_value); 2486 return false;2448 return FALSE; 2487 2449 } 2488 2450 … … 2493 2455 } 2494 2456 2495 return true;2457 return TRUE; 2496 2458 } 2497 2459 … … 2513 2475 mips_ecoff_swap_filehdr_out, mips_ecoff_swap_aouthdr_out, 2514 2476 mips_ecoff_swap_scnhdr_out, 2515 FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, FILNMLEN, true, false, 4, false, 2,2477 FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, FILNMLEN, TRUE, FALSE, 4, FALSE, 2, 2516 2478 mips_ecoff_swap_filehdr_in, mips_ecoff_swap_aouthdr_in, 2517 2479 mips_ecoff_swap_scnhdr_in, NULL, … … 2529 2491 executable file. E.g., 0x1000. */ 2530 2492 0x1000, 2531 /* T rueif the .rdata section is part of the text segment, as on the2532 Alpha. F alseif .rdata is part of the data segment, as on the2493 /* TRUE if the .rdata section is part of the text segment, as on the 2494 Alpha. FALSE if .rdata is part of the data segment, as on the 2533 2495 MIPS. */ 2534 false,2496 FALSE, 2535 2497 /* Bitsize of constructor entries. */ 2536 2498 32, … … 2609 2571 #define _bfd_ecoff_bfd_gc_sections bfd_generic_gc_sections 2610 2572 2573 /* Merging of sections is not done. */ 2574 #define _bfd_ecoff_bfd_merge_sections bfd_generic_merge_sections 2575 2576 #define _bfd_ecoff_bfd_discard_group bfd_generic_discard_group 2577 2611 2578 extern const bfd_target ecoff_big_vec; 2612 2579 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.