Changeset 609 for branches/GNU/src/binutils/bfd/coff-h8300.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-h8300.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 /* BFD back-end for HitachiH8/300 COFF binaries.1 /* BFD back-end for Renesas H8/300 COFF binaries. 2 2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 3 2000 3 2000, 2001, 2002, 2003 4 4 Free Software Foundation, Inc. 5 5 Written by Steve Chamberlain, <sac@cygnus.com>. 6 6 7 This file is part of BFD, the Binary File Descriptor library.8 9 This program is free software; you can redistribute it and/or modify10 it under the terms of the GNU General Public License as published by11 the Free Software Foundation; either version 2 of the License, or12 (at your option) any later version.13 14 This program is distributed in the hope that it will be useful,15 but WITHOUT ANY WARRANTY; without even the implied warranty of16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the17 GNU General Public License for more details.18 19 You should have received a copy of the GNU General Public License20 along with this program; if not, write to the Free Software21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */7 This file is part of BFD, the Binary File Descriptor library. 8 9 This program is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation; either version 2 of the License, or 12 (at your option) any later version. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software 21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 22 22 23 23 #include "bfd.h" … … 29 29 #include "coff/internal.h" 30 30 #include "libcoff.h" 31 #include "libiberty.h" 31 32 32 33 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1) … … 39 40 40 41 struct funcvec_hash_entry 41 {42 /* The basic hash table entry. */43 struct bfd_hash_entry root;44 45 /* The offset within the vectors section where46 this entry lives. */47 bfd_vma offset;48 };42 { 43 /* The basic hash table entry. */ 44 struct bfd_hash_entry root; 45 46 /* The offset within the vectors section where 47 this entry lives. */ 48 bfd_vma offset; 49 }; 49 50 50 51 struct funcvec_hash_table 51 {52 /* The basic hash table. */53 struct bfd_hash_table root;54 55 bfd *abfd;56 57 /* Offset at which we'll add the next entry. */58 unsigned int offset;59 };52 { 53 /* The basic hash table. */ 54 struct bfd_hash_table root; 55 56 bfd *abfd; 57 58 /* Offset at which we'll add the next entry. */ 59 unsigned int offset; 60 }; 60 61 61 62 static struct bfd_hash_entry * … … 63 64 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); 64 65 65 static b oolean66 static bfd_boolean 66 67 funcvec_hash_table_init 67 68 PARAMS ((struct funcvec_hash_table *, bfd *, 68 struct bfd_hash_entry *(*) PARAMS ((struct bfd_hash_entry *, 69 struct bfd_hash_table *, 70 const char *)))); 69 struct bfd_hash_entry *(*) (struct bfd_hash_entry *, 70 struct bfd_hash_table *, 71 const char *))); 72 73 static bfd_reloc_status_type special 74 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); 75 static int select_reloc 76 PARAMS ((reloc_howto_type *)); 77 static void rtype2howto 78 PARAMS ((arelent *, struct internal_reloc *)); 79 static void reloc_processing 80 PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *)); 81 static bfd_boolean h8300_symbol_address_p 82 PARAMS ((bfd *, asection *, bfd_vma)); 83 static int h8300_reloc16_estimate 84 PARAMS ((bfd *, asection *, arelent *, unsigned int, 85 struct bfd_link_info *)); 86 static void h8300_reloc16_extra_cases 87 PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *, 88 bfd_byte *, unsigned int *, unsigned int *)); 89 static bfd_boolean h8300_bfd_link_add_symbols 90 PARAMS ((bfd *, struct bfd_link_info *)); 71 91 72 92 /* To lookup a value in the function vector hash table. */ … … 79 99 table! We use this to attach additional data structures we 80 100 need while linking on the h8300. */ 81 struct h8300_coff_link_hash_table 82 { 101 struct h8300_coff_link_hash_table { 83 102 /* The main hash table. */ 84 103 struct generic_link_hash_table root; … … 120 139 if (ret == NULL) 121 140 ret = ((struct funcvec_hash_entry *) 122 123 141 bfd_hash_allocate (gen_table, 142 sizeof (struct funcvec_hash_entry))); 124 143 if (ret == NULL) 125 144 return NULL; … … 127 146 /* Call the allocation method of the superclass. */ 128 147 ret = ((struct funcvec_hash_entry *) 129 148 bfd_hash_newfunc ((struct bfd_hash_entry *) ret, gen_table, string)); 130 149 131 150 if (ret == NULL) … … 152 171 /* Initialize the function vector hash table. */ 153 172 154 static b oolean173 static bfd_boolean 155 174 funcvec_hash_table_init (table, abfd, newfunc) 156 175 struct funcvec_hash_table *table; 157 176 bfd *abfd; 158 struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,159 160 177 struct bfd_hash_entry *(*newfunc) 178 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, 179 const char *)); 161 180 { 162 181 /* Initialize our local fields, then call the generic initialization … … 168 187 169 188 /* Create the derived linker hash table. We use a derived hash table 170 basically to hold "static" information during an h8/300 coff link189 basically to hold "static" information during an H8/300 coff link 171 190 without using static variables. */ 172 191 … … 176 195 { 177 196 struct h8300_coff_link_hash_table *ret; 178 ret = ((struct h8300_coff_link_hash_table *) 179 bfd_alloc (abfd, sizeof (struct h8300_coff_link_hash_table))); 197 bfd_size_type amt = sizeof (struct h8300_coff_link_hash_table); 198 199 ret = (struct h8300_coff_link_hash_table *) bfd_malloc (amt); 180 200 if (ret == NULL) 181 201 return NULL; 182 if (!_bfd_link_hash_table_init (&ret->root.root, abfd, _bfd_generic_link_hash_newfunc)) 202 if (!_bfd_link_hash_table_init (&ret->root.root, abfd, 203 _bfd_generic_link_hash_newfunc)) 183 204 { 184 bfd_release (abfd,ret);205 free (ret); 185 206 return NULL; 186 207 } … … 190 211 ret->funcvec_hash_table = NULL; 191 212 192 /* OK. Everything's in tialized, return the base pointer. */213 /* OK. Everything's initialized, return the base pointer. */ 193 214 return &ret->root.root; 194 215 } … … 222 243 } 223 244 224 static reloc_howto_type howto_table[] = 225 { 226 HOWTO (R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "8", false, 0x000000ff, 0x000000ff, false), 227 HOWTO (R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "16", false, 0x0000ffff, 0x0000ffff, false), 228 HOWTO (R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, special, "32", false, 0xffffffff, 0xffffffff, false), 229 HOWTO (R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, special, "DISP8", false, 0x000000ff, 0x000000ff, true), 230 HOWTO (R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, special, "DISP16", false, 0x0000ffff, 0x0000ffff, true), 231 HOWTO (R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, special, "DISP32", false, 0xffffffff, 0xffffffff, true), 232 HOWTO (R_MOV16B1, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "relaxable mov.b:16", false, 0x0000ffff, 0x0000ffff, false), 233 HOWTO (R_MOV16B2, 0, 1, 8, false, 0, complain_overflow_bitfield, special, "relaxed mov.b:16", false, 0x000000ff, 0x000000ff, false), 234 HOWTO (R_JMP1, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "16/pcrel", false, 0x0000ffff, 0x0000ffff, false), 235 HOWTO (R_JMP2, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "pcrecl/16", false, 0x000000ff, 0x000000ff, false), 236 HOWTO (R_JMPL1, 0, 2, 32, false, 0, complain_overflow_bitfield, special, "24/pcrell", false, 0x00ffffff, 0x00ffffff, false), 237 HOWTO (R_JMPL2, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "pc8/24", false, 0x000000ff, 0x000000ff, false), 238 HOWTO (R_MOV24B1, 0, 1, 32, false, 0, complain_overflow_bitfield, special, "relaxable mov.b:24", false, 0xffffffff, 0xffffffff, false), 239 HOWTO (R_MOV24B2, 0, 1, 8, false, 0, complain_overflow_bitfield, special, "relaxed mov.b:24", false, 0x0000ffff, 0x0000ffff, false), 245 static reloc_howto_type howto_table[] = { 246 HOWTO (R_RELBYTE, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, special, "8", FALSE, 0x000000ff, 0x000000ff, FALSE), 247 HOWTO (R_RELWORD, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, special, "16", FALSE, 0x0000ffff, 0x0000ffff, FALSE), 248 HOWTO (R_RELLONG, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, special, "32", FALSE, 0xffffffff, 0xffffffff, FALSE), 249 HOWTO (R_PCRBYTE, 0, 0, 8, TRUE, 0, complain_overflow_signed, special, "DISP8", FALSE, 0x000000ff, 0x000000ff, TRUE), 250 HOWTO (R_PCRWORD, 0, 1, 16, TRUE, 0, complain_overflow_signed, special, "DISP16", FALSE, 0x0000ffff, 0x0000ffff, TRUE), 251 HOWTO (R_PCRLONG, 0, 2, 32, TRUE, 0, complain_overflow_signed, special, "DISP32", FALSE, 0xffffffff, 0xffffffff, TRUE), 252 HOWTO (R_MOV16B1, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, special, "relaxable mov.b:16", FALSE, 0x0000ffff, 0x0000ffff, FALSE), 253 HOWTO (R_MOV16B2, 0, 1, 8, FALSE, 0, complain_overflow_bitfield, special, "relaxed mov.b:16", FALSE, 0x000000ff, 0x000000ff, FALSE), 254 HOWTO (R_JMP1, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, special, "16/pcrel", FALSE, 0x0000ffff, 0x0000ffff, FALSE), 255 HOWTO (R_JMP2, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, special, "pcrecl/16", FALSE, 0x000000ff, 0x000000ff, FALSE), 256 HOWTO (R_JMPL1, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, special, "24/pcrell", FALSE, 0x00ffffff, 0x00ffffff, FALSE), 257 HOWTO (R_JMPL2, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, special, "pc8/24", FALSE, 0x000000ff, 0x000000ff, FALSE), 258 HOWTO (R_MOV24B1, 0, 1, 32, FALSE, 0, complain_overflow_bitfield, special, "relaxable mov.b:24", FALSE, 0xffffffff, 0xffffffff, FALSE), 259 HOWTO (R_MOV24B2, 0, 1, 8, FALSE, 0, complain_overflow_bitfield, special, "relaxed mov.b:24", FALSE, 0x0000ffff, 0x0000ffff, FALSE), 240 260 241 261 /* An indirect reference to a function. This causes the function's address 242 262 to be added to the function vector in lo-mem and puts the address of 243 263 the function vector's entry in the jsr instruction. */ 244 HOWTO (R_MEM_INDIRECT, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "8/indirect", false, 0x000000ff, 0x000000ff, false),264 HOWTO (R_MEM_INDIRECT, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, special, "8/indirect", FALSE, 0x000000ff, 0x000000ff, FALSE), 245 265 246 266 /* Internal reloc for relaxing. This is created when a 16bit pc-relative 247 267 branch is turned into an 8bit pc-relative branch. */ 248 HOWTO (R_PCRWORD_B, 0, 0, 8, true, 0, complain_overflow_bitfield, special, "relaxed bCC:16", false, 0x000000ff, 0x000000ff, false),249 250 HOWTO (R_MOVL1, 0, 2, 32, false, 0, complain_overflow_bitfield,special, "32/24 relaxable move", false, 0xffffffff, 0xffffffff, false),251 252 HOWTO (R_MOVL2, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "32/24 relaxed move", false, 0x0000ffff, 0x0000ffff, false),253 254 HOWTO (R_BCC_INV, 0, 0, 8, true, 0, complain_overflow_signed, special, "DISP8 inverted", false, 0x000000ff, 0x000000ff, true),255 256 HOWTO (R_JMP_DEL, 0, 0, 8, true, 0, complain_overflow_signed, special, "Deleted jump", false, 0x000000ff, 0x000000ff, true),268 HOWTO (R_PCRWORD_B, 0, 0, 8, TRUE, 0, complain_overflow_bitfield, special, "relaxed bCC:16", FALSE, 0x000000ff, 0x000000ff, FALSE), 269 270 HOWTO (R_MOVL1, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,special, "32/24 relaxable move", FALSE, 0xffffffff, 0xffffffff, FALSE), 271 272 HOWTO (R_MOVL2, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, special, "32/24 relaxed move", FALSE, 0x0000ffff, 0x0000ffff, FALSE), 273 274 HOWTO (R_BCC_INV, 0, 0, 8, TRUE, 0, complain_overflow_signed, special, "DISP8 inverted", FALSE, 0x000000ff, 0x000000ff, TRUE), 275 276 HOWTO (R_JMP_DEL, 0, 0, 8, TRUE, 0, complain_overflow_signed, special, "Deleted jump", FALSE, 0x000000ff, 0x000000ff, TRUE), 257 277 }; 258 278 … … 260 280 261 281 #define SELECT_RELOC(x,howto) \ 262 { x.r_type = select_reloc(howto); } 263 264 #define BADMAG(x) (H8300BADMAG(x) && H8300HBADMAG(x) && H8300SBADMAG(x)) 265 #define H8300 1 /* Customize coffcode.h */ 282 { x.r_type = select_reloc (howto); } 283 284 #define BADMAG(x) (H8300BADMAG (x) && H8300HBADMAG (x) && H8300SBADMAG (x) \ 285 && H8300HNBADMAG(x) && H8300SNBADMAG(x)) 286 #define H8300 1 /* Customize coffcode.h */ 266 287 #define __A_MAGIC_SET__ 267 288 268 289 /* Code to swap in the reloc. */ 269 #define SWAP_IN_RELOC_OFFSET bfd_h_get_32270 #define SWAP_OUT_RELOC_OFFSET bfd_h_put_32290 #define SWAP_IN_RELOC_OFFSET H_GET_32 291 #define SWAP_OUT_RELOC_OFFSET H_PUT_32 271 292 #define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \ 272 293 dst->r_stuff[0] = 'S'; \ … … 355 376 } 356 377 357 #define RTYPE2HOWTO(internal, relocentry) rtype2howto (internal,relocentry)378 #define RTYPE2HOWTO(internal, relocentry) rtype2howto (internal, relocentry) 358 379 359 380 /* Perform any necessary magic to the addend in a reloc entry. */ 360 381 361 382 #define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \ 362 cache_ptr->addend = 383 cache_ptr->addend = ext_reloc.r_offset; 363 384 364 385 #define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \ 365 reloc_processing (relent, reloc, symbols, abfd, section)386 reloc_processing (relent, reloc, symbols, abfd, section) 366 387 367 388 static void … … 377 398 378 399 if (((int) reloc->r_symndx) > 0) 379 { 380 relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx]; 381 } 400 relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx]; 382 401 else 383 { 384 relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; 385 } 402 relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; 386 403 387 404 relent->addend = reloc->r_offset; … … 393 410 } 394 411 395 static b oolean412 static bfd_boolean 396 413 h8300_symbol_address_p (abfd, input_section, address) 397 414 bfd *abfd; … … 409 426 { 410 427 asymbol *p = *s; 428 411 429 if (p->section == input_section 412 430 && (input_section->output_section->vma 413 431 + input_section->output_offset 414 432 + p->value) == address) 415 return true;433 return TRUE; 416 434 s++; 417 435 } 418 return false;436 return FALSE; 419 437 } 420 438 … … 453 471 switch (reloc->howto->type) 454 472 { 455 /* This is the 16/24 bit absolute branch which could become an 8 bit456 473 /* This is the 16/24 bit absolute branch which could become an 8 bit 474 pc-relative branch. */ 457 475 case R_JMP1: 458 476 case R_JMPL1: … … 473 491 this jump. +128 is valid since the target will move two bytes 474 492 closer if we do relax this branch. */ 475 if ((int)gap >= -128 && (int)gap <= 128 ) 476 { 493 if ((int) gap >= -128 && (int) gap <= 128) 494 { 495 bfd_byte code; 496 497 if (!bfd_get_section_contents (abfd, input_section, & code, 498 reloc->address, 1)) 499 break; 500 code = bfd_get_8 (abfd, & code); 501 477 502 /* It's possible we may be able to eliminate this branch entirely; 478 503 if the previous instruction is a branch around this instruction, … … 486 511 487 512 This saves 4 bytes instead of two, and should be relatively 488 common. */ 489 490 if (gap <= 126 513 common. 514 515 Only perform this optimisation for jumps (code 0x5a) not 516 subroutine calls, as otherwise it could transform: 517 518 mov.w r0,r0 519 beq .L1 520 jsr @_bar 521 .L1: rts 522 _bar: rts 523 into: 524 mov.w r0,r0 525 bne _bar 526 rts 527 _bar: rts 528 529 which changes the call (jsr) into a branch (bne). */ 530 if (code == 0x5a 531 && gap <= 126 491 532 && last_reloc 492 533 && last_reloc->howto->type == R_PCRBYTE) … … 523 564 case R_PCRWORD: 524 565 /* Get the address of the target of this branch, add one to the value 525 566 because the addend field in PCrel jumps is off by -1. */ 526 567 value = bfd_coff_reloc16_get_value (reloc, link_info, input_section) + 1; 527 568 … … 536 577 this jump. +128 is valid since the target will move two bytes 537 578 closer if we do relax this branch. */ 538 if ((int) gap >= -128 && (int)gap <= 128)579 if ((int) gap >= -128 && (int) gap <= 128) 539 580 { 540 581 /* Change the reloc type. */ … … 608 649 609 650 /* If this address is in 0x0000..0x7fff inclusive or 610 651 0xff8000..0xffffff inclusive, then it can be relaxed. */ 611 652 if (value <= 0x7fff || value >= 0xff8000) 612 653 { … … 678 719 /* Everything looks OK. Apply the relocation and update the 679 720 src/dst address appropriately. */ 680 681 721 bfd_put_8 (abfd, gap, data + dst_address); 682 722 dst_address++; … … 710 750 /* Everything looks OK. Apply the relocation and update the 711 751 src/dst address appropriately. */ 712 713 bfd_put_16 (abfd, gap, data + dst_address); 752 bfd_put_16 (abfd, (bfd_vma) gap, data + dst_address); 714 753 dst_address += 2; 715 754 src_address += 2; … … 726 765 if (value <= 0xff 727 766 || (value >= 0x0000ff00 && value <= 0x0000ffff) 728 767 || (value >= 0x00ffff00 && value <= 0x00ffffff) 729 768 || (value >= 0xffffff00 && value <= 0xffffffff)) 730 769 { 731 770 /* Everything looks OK. Apply the relocation and update the 732 771 src/dst address appropriately. */ 733 734 772 bfd_put_8 (abfd, value & 0xff, data + dst_address); 735 773 dst_address += 1; … … 794 832 /* Fix the opcode. For all the move insns, we simply 795 833 need to turn off bit 0x20 in the previous byte. */ 796 834 data[dst_address - 1] &= ~0x20; 797 835 dst_address += 2; 798 836 src_address += 4; … … 805 843 input_section, reloc->address))) 806 844 abort (); 807 845 } 808 846 break; 809 847 … … 902 940 } 903 941 904 905 906 907 908 909 910 911 942 /* Output the target. */ 943 bfd_put_8 (abfd, gap, data + dst_address - 1); 944 945 /* We don't advance dst_address -- the 8bit reloc is applied at 946 dst_address - 1, so the next insn should begin at dst_address. */ 947 src_address += 2; 948 949 break; 912 950 913 951 /* Similarly for a 24bit absolute that is now 8 bits. */ … … 1047 1085 address in the function vector table. */ 1048 1086 asymbol *symbol; 1049 bfd_vma value;1050 1087 const char *name; 1088 struct funcvec_hash_table *ftab; 1051 1089 struct funcvec_hash_entry *h; 1052 asection *vectors_sec = h8300_coff_hash_table (link_info)->vectors_sec; 1090 struct h8300_coff_link_hash_table *htab; 1091 asection *vectors_sec; 1092 1093 if (link_info->hash->creator != abfd->xvec) 1094 { 1095 (*_bfd_error_handler) 1096 (_("cannot handle R_MEM_INDIRECT reloc when using %s output"), 1097 link_info->hash->creator->name); 1098 1099 /* What else can we do? This function doesn't allow return 1100 of an error, and we don't want to call abort as that 1101 indicates an internal error. */ 1102 #ifndef EXIT_FAILURE 1103 #define EXIT_FAILURE 1 1104 #endif 1105 xexit (EXIT_FAILURE); 1106 } 1107 htab = h8300_coff_hash_table (link_info); 1108 vectors_sec = htab->vectors_sec; 1053 1109 1054 1110 /* First see if this is a reloc against the absolute symbol … … 1089 1145 if (symbol->flags & BSF_LOCAL) 1090 1146 { 1091 char *new_name = bfd_malloc ( strlen (name) + 9);1147 char *new_name = bfd_malloc ((bfd_size_type) strlen (name) + 9); 1092 1148 if (new_name == NULL) 1093 1149 abort (); … … 1099 1155 } 1100 1156 1101 h = funcvec_hash_lookup (h8300_coff_hash_table (link_info)->funcvec_hash_table,1102 name, false, false);1157 ftab = htab->funcvec_hash_table; 1158 h = funcvec_hash_lookup (ftab, name, FALSE, FALSE); 1103 1159 1104 1160 /* This shouldn't ever happen. If it does that means we've got 1105 1161 data corruption of some kind. Aborting seems like a reasonable 1106 thin kto do here. */1162 thing to do here. */ 1107 1163 if (h == NULL || vectors_sec == NULL) 1108 1164 abort (); … … 1139 1195 vectors_sec->output_section, 1140 1196 vectors_sec->contents, 1141 vectors_sec->output_offset,1197 (file_ptr) vectors_sec->output_offset, 1142 1198 vectors_sec->_raw_size); 1143 1199 break; … … 1165 1221 selected static symbols to the bfd linker hash table. */ 1166 1222 1167 static b oolean1223 static bfd_boolean 1168 1224 h8300_bfd_link_add_symbols (abfd, info) 1169 1225 bfd *abfd; … … 1172 1228 asection *sec; 1173 1229 struct funcvec_hash_table *funcvec_hash_table; 1230 bfd_size_type amt; 1231 struct h8300_coff_link_hash_table *htab; 1232 1233 /* Add the symbols using the generic code. */ 1234 _bfd_generic_link_add_symbols (abfd, info); 1235 1236 if (info->hash->creator != abfd->xvec) 1237 return TRUE; 1238 1239 htab = h8300_coff_hash_table (info); 1174 1240 1175 1241 /* If we haven't created a vectors section, do so now. */ 1176 if (!h 8300_coff_hash_table (info)->vectors_sec)1242 if (!htab->vectors_sec) 1177 1243 { 1178 1244 flagword flags; … … 1181 1247 flags = (SEC_ALLOC | SEC_LOAD 1182 1248 | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_READONLY); 1183 h8300_coff_hash_table (info)->vectors_sec = bfd_make_section (abfd, 1184 ".vectors"); 1249 htab->vectors_sec = bfd_make_section (abfd, ".vectors"); 1185 1250 1186 1251 /* If the section wasn't created, or we couldn't set the flags, 1187 quit quickly now, rather than dieing a painful death later. */ 1188 if (! h8300_coff_hash_table (info)->vectors_sec 1189 || ! bfd_set_section_flags (abfd, 1190 h8300_coff_hash_table(info)->vectors_sec, 1191 flags)) 1192 return false; 1252 quit quickly now, rather than dying a painful death later. */ 1253 if (!htab->vectors_sec 1254 || !bfd_set_section_flags (abfd, htab->vectors_sec, flags)) 1255 return FALSE; 1193 1256 1194 1257 /* Also create the vector hash table. */ 1195 funcvec_hash_table = ((struct funcvec_hash_table *)1196 bfd_alloc (abfd, sizeof (struct funcvec_hash_table)));1258 amt = sizeof (struct funcvec_hash_table); 1259 funcvec_hash_table = (struct funcvec_hash_table *) bfd_alloc (abfd, amt); 1197 1260 1198 1261 if (!funcvec_hash_table) 1199 return false;1262 return FALSE; 1200 1263 1201 1264 /* And initialize the funcvec hash table. */ … … 1204 1267 { 1205 1268 bfd_release (abfd, funcvec_hash_table); 1206 return false;1269 return FALSE; 1207 1270 } 1208 1271 1209 1272 /* Store away a pointer to the funcvec hash table. */ 1210 h 8300_coff_hash_table (info)->funcvec_hash_table = funcvec_hash_table;1273 htab->funcvec_hash_table = funcvec_hash_table; 1211 1274 } 1212 1275 1213 1276 /* Load up the function vector hash table. */ 1214 funcvec_hash_table = h8300_coff_hash_table (info)->funcvec_hash_table; 1215 1216 /* Add the symbols using the generic code. */ 1217 _bfd_generic_link_add_symbols (abfd, info); 1277 funcvec_hash_table = htab->funcvec_hash_table; 1218 1278 1219 1279 /* Now scan the relocs for all the sections in this bfd; create … … 1230 1290 continue; 1231 1291 1232 relocs = (arelent **) bfd_malloc (( size_t) reloc_size);1292 relocs = (arelent **) bfd_malloc ((bfd_size_type) reloc_size); 1233 1293 if (!relocs) 1234 return false;1294 return FALSE; 1235 1295 1236 1296 /* The symbols should have been read in by _bfd_generic link_add_symbols … … 1261 1321 1262 1322 { 1323 struct funcvec_hash_table *ftab; 1263 1324 struct funcvec_hash_entry *h; 1264 1325 … … 1266 1327 if (symbol->flags & BSF_LOCAL) 1267 1328 { 1268 char *new_name = bfd_malloc (strlen (name) + 9); 1269 1329 char *new_name; 1330 1331 new_name = bfd_malloc ((bfd_size_type) strlen (name) + 9); 1270 1332 if (new_name == NULL) 1271 1333 abort (); … … 1278 1340 1279 1341 /* Look this symbol up in the function vector hash table. */ 1280 h = funcvec_hash_lookup (h8300_coff_hash_table (info)->funcvec_hash_table,1281 name, false, false);1342 ftab = htab->funcvec_hash_table; 1343 h = funcvec_hash_lookup (ftab, name, FALSE, FALSE); 1282 1344 1283 1345 /* If this symbol isn't already in the hash table, add … … 1285 1347 if (h == NULL) 1286 1348 { 1287 h = funcvec_hash_lookup (h8300_coff_hash_table (info)->funcvec_hash_table, 1288 name, true, true); 1349 h = funcvec_hash_lookup (ftab, name, TRUE, TRUE); 1289 1350 if (h == NULL) 1290 1351 { 1291 1352 free (relocs); 1292 return false;1353 return FALSE; 1293 1354 } 1294 1355 … … 1296 1357 takes 2 bytes on the h8300 and 4 bytes on the h8300h. */ 1297 1358 if (bfd_get_mach (abfd) == bfd_mach_h8300) 1298 h 8300_coff_hash_table (info)->vectors_sec->_raw_size += 2;1359 htab->vectors_sec->_raw_size += 2; 1299 1360 else if (bfd_get_mach (abfd) == bfd_mach_h8300h 1300 1361 || bfd_get_mach (abfd) == bfd_mach_h8300s) 1301 h 8300_coff_hash_table (info)->vectors_sec->_raw_size += 4;1362 htab->vectors_sec->_raw_size += 4; 1302 1363 } 1303 1364 } … … 1310 1371 /* Now actually allocate some space for the function vector. It's 1311 1372 wasteful to do this more than once, but this is easier. */ 1312 if (h8300_coff_hash_table (info)->vectors_sec->_raw_size != 0) 1373 sec = htab->vectors_sec; 1374 if (sec->_raw_size != 0) 1313 1375 { 1314 1376 /* Free the old contents. */ 1315 if ( h8300_coff_hash_table (info)->vectors_sec->contents)1316 free ( h8300_coff_hash_table (info)->vectors_sec->contents);1377 if (sec->contents) 1378 free (sec->contents); 1317 1379 1318 1380 /* Allocate new contents. */ 1319 h8300_coff_hash_table (info)->vectors_sec->contents 1320 = bfd_malloc (h8300_coff_hash_table (info)->vectors_sec->_raw_size); 1381 sec->contents = bfd_malloc (sec->_raw_size); 1321 1382 } 1322 1383 1323 return true;1384 return TRUE; 1324 1385 } 1325 1386 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.