Changeset 609 for branches/GNU/src/binutils/bfd/peicode.h
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/peicode.h
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* Support for the generic parts of PE/PEI, for BFD. 2 Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001 2 Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 3 3 Free Software Foundation, Inc. 4 4 Written by Cygnus Solutions. 5 5 6 This file is part of BFD, the Binary File Descriptor library. 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 2 of the License, or 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 21 22 /* 23 Most of this hacked by Steve Chamberlain, 6 This file is part of BFD, the Binary File Descriptor library. 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 2 of the License, or 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 21 22 /* Most of this hacked by Steve Chamberlain, 24 23 sac@cygnus.com 25 24 26 PE/PEI rearrangement (and code added): Donn Terry 27 Softway Systems, Inc. 28 */ 25 PE/PEI rearrangement (and code added): Donn Terry 26 Softway Systems, Inc. */ 29 27 30 28 /* Hey look, some documentation [and in a place you expect to find it]! … … 54 52 FIXME: Please add more docs here so the next poor fool that has to hack 55 53 on this code has a chance of getting something accomplished without 56 wasting too much time. 57 */ 54 wasting too much time. */ 58 55 59 56 #include "libpei.h" 60 57 61 static b oolean (*pe_saved_coff_bfd_print_private_bfd_data)58 static bfd_boolean (*pe_saved_coff_bfd_print_private_bfd_data) 62 59 PARAMS ((bfd *, PTR)) = 63 60 #ifndef coff_bfd_print_private_bfd_data … … 68 65 #endif 69 66 70 static b oolean pe_print_private_bfd_data PARAMS ((bfd *, PTR));67 static bfd_boolean pe_print_private_bfd_data PARAMS ((bfd *, PTR)); 71 68 #define coff_bfd_print_private_bfd_data pe_print_private_bfd_data 72 69 73 static b oolean (*pe_saved_coff_bfd_copy_private_bfd_data)70 static bfd_boolean (*pe_saved_coff_bfd_copy_private_bfd_data) 74 71 PARAMS ((bfd *, bfd *)) = 75 72 #ifndef coff_bfd_copy_private_bfd_data … … 80 77 #endif 81 78 82 static b oolean pe_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *));79 static bfd_boolean pe_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *)); 83 80 #define coff_bfd_copy_private_bfd_data pe_bfd_copy_private_bfd_data 84 81 … … 92 89 static void coff_swap_filehdr_in PARAMS ((bfd *, PTR, PTR)); 93 90 static void coff_swap_scnhdr_in PARAMS ((bfd *, PTR, PTR)); 94 static b oolean pe_mkobject PARAMS ((bfd *));91 static bfd_boolean pe_mkobject PARAMS ((bfd *)); 95 92 static PTR pe_mkobject_hook PARAMS ((bfd *, PTR, PTR)); 96 93 … … 140 137 static void pe_ILF_save_relocs PARAMS ((pe_ILF_vars *, asection_ptr)); 141 138 static void pe_ILF_make_a_symbol_reloc PARAMS ((pe_ILF_vars *, bfd_vma, bfd_reloc_code_real_type, struct symbol_cache_entry **, unsigned int)); 142 static b oolean pe_ILF_build_a_bfd PARAMS ((bfd *, unsigned short, bfd_byte *, bfd_byte *, unsigned int, unsigned int));139 static bfd_boolean pe_ILF_build_a_bfd PARAMS ((bfd *, unsigned int, bfd_byte *, bfd_byte *, unsigned int, unsigned int)); 143 140 static const bfd_target * pe_ILF_object_p PARAMS ((bfd *)); 144 141 static const bfd_target * pe_bfd_object_p PARAMS ((bfd *)); … … 157 154 struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; 158 155 159 reloc_dst->r_vaddr = bfd_h_get_32(abfd, (bfd_byte *)reloc_src->r_vaddr);160 reloc_dst->r_symndx = bfd_h_get_signed_32(abfd, (bfd_byte *)reloc_src->r_symndx);161 162 reloc_dst->r_type = bfd_h_get_16(abfd, (bfd_byte *)reloc_src->r_type);156 reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); 157 reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); 158 159 reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); 163 160 164 161 #ifdef SWAP_IN_RELOC_OFFSET 165 reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET(abfd, 166 (bfd_byte *) reloc_src->r_offset); 162 reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); 167 163 #endif 168 164 } … … 176 172 struct internal_reloc *reloc_src = (struct internal_reloc *)src; 177 173 struct external_reloc *reloc_dst = (struct external_reloc *)dst; 178 bfd_h_put_32(abfd, reloc_src->r_vaddr, (bfd_byte *) reloc_dst->r_vaddr); 179 bfd_h_put_32(abfd, reloc_src->r_symndx, (bfd_byte *) reloc_dst->r_symndx); 180 181 bfd_h_put_16(abfd, reloc_src->r_type, (bfd_byte *) 182 reloc_dst->r_type); 174 H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr); 175 H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx); 176 177 H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type); 183 178 184 179 #ifdef SWAP_OUT_RELOC_OFFSET 185 SWAP_OUT_RELOC_OFFSET(abfd, 186 reloc_src->r_offset, 187 (bfd_byte *) reloc_dst->r_offset); 180 SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset); 188 181 #endif 189 182 #ifdef SWAP_OUT_RELOC_EXTRA 190 SWAP_OUT_RELOC_EXTRA(abfd, reloc_src, reloc_dst);183 SWAP_OUT_RELOC_EXTRA(abfd, reloc_src, reloc_dst); 191 184 #endif 192 185 return RELSZ; … … 202 195 FILHDR *filehdr_src = (FILHDR *) src; 203 196 struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; 204 filehdr_dst->f_magic = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src->f_magic);205 filehdr_dst->f_nscns = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_nscns);206 filehdr_dst->f_timdat = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_timdat);207 208 filehdr_dst->f_nsyms = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_nsyms);209 filehdr_dst->f_flags = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_flags);210 filehdr_dst->f_symptr = bfd_h_get_32 (abfd, (bfd_byte *)filehdr_src->f_symptr);197 filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); 198 filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src-> f_nscns); 199 filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src-> f_timdat); 200 201 filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src-> f_nsyms); 202 filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src-> f_flags); 203 filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); 211 204 212 205 /* Other people's tools sometimes generate headers with an nsyms but … … 218 211 } 219 212 220 filehdr_dst->f_opthdr = bfd_h_get_16(abfd, 221 (bfd_byte *)filehdr_src-> f_opthdr); 213 filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); 222 214 } 223 215 … … 238 230 239 231 memcpy(scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); 240 scnhdr_int->s_vaddr = 241 GET_SCNHDR_VADDR (abfd, (bfd_byte *) scnhdr_ext->s_vaddr); 242 scnhdr_int->s_paddr = 243 GET_SCNHDR_PADDR (abfd, (bfd_byte *) scnhdr_ext->s_paddr); 244 scnhdr_int->s_size = 245 GET_SCNHDR_SIZE (abfd, (bfd_byte *) scnhdr_ext->s_size); 246 scnhdr_int->s_scnptr = 247 GET_SCNHDR_SCNPTR (abfd, (bfd_byte *) scnhdr_ext->s_scnptr); 248 scnhdr_int->s_relptr = 249 GET_SCNHDR_RELPTR (abfd, (bfd_byte *) scnhdr_ext->s_relptr); 250 scnhdr_int->s_lnnoptr = 251 GET_SCNHDR_LNNOPTR (abfd, (bfd_byte *) scnhdr_ext->s_lnnoptr); 252 scnhdr_int->s_flags = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_flags); 232 scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); 233 scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); 234 scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); 235 scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); 236 scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); 237 scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); 238 scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); 253 239 254 240 /* MS handles overflow of line numbers by carrying into the reloc … … 256 242 *IMAGE* format, that's safe. This is still a bit iffy. */ 257 243 #ifdef COFF_IMAGE_WITH_PE 258 scnhdr_int->s_nlnno = 259 (bfd_h_get_16 (abfd, (bfd_byte *) scnhdr_ext->s_nlnno) 260 + (bfd_h_get_16 (abfd, (bfd_byte *) scnhdr_ext->s_nreloc) << 16)); 244 scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) 245 + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); 261 246 scnhdr_int->s_nreloc = 0; 262 247 #else 263 scnhdr_int->s_nreloc = bfd_h_get_16 (abfd, 264 (bfd_byte *) scnhdr_ext->s_nreloc); 265 scnhdr_int->s_nlnno = bfd_h_get_16 (abfd, 266 (bfd_byte *) scnhdr_ext->s_nlnno); 248 scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); 249 scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); 267 250 #endif 268 251 … … 274 257 275 258 #ifndef COFF_NO_HACK_SCNHDR_SIZE 276 /* If this section holds uninitialized data, use the virtual size 277 (stored in s_paddr) instead of the physical size. */ 278 if ((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0) 259 /* If this section holds uninitialized data and is from an object file 260 or from an executable image that has not initialized the field, 261 or if the physical size is padded, use the virtual size (stored in 262 s_paddr) instead. */ 263 if (scnhdr_int->s_paddr > 0 264 && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 265 && (! bfd_pe_executable_p (abfd) || scnhdr_int->s_size == 0)) 266 || scnhdr_int->s_size > scnhdr_int->s_paddr)) 279 267 { 280 268 scnhdr_int->s_size = scnhdr_int->s_paddr; 269 281 270 /* This code used to set scnhdr_int->s_paddr to 0. However, 282 271 coff_set_alignment_hook stores s_paddr in virt_size, which … … 287 276 } 288 277 289 static b oolean278 static bfd_boolean 290 279 pe_mkobject (abfd) 291 280 bfd * abfd; 292 281 { 293 282 pe_data_type *pe; 294 abfd->tdata.pe_obj_data = 295 (struct pe_tdata *) bfd_zalloc (abfd, sizeof (pe_data_type)); 283 bfd_size_type amt = sizeof (pe_data_type); 284 285 abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); 296 286 297 287 if (abfd->tdata.pe_obj_data == 0) 298 return false;288 return FALSE; 299 289 300 290 pe = pe_data (abfd); … … 312 302 #endif 313 303 314 return true;304 return TRUE; 315 305 } 316 306 … … 325 315 pe_data_type *pe; 326 316 327 if ( pe_mkobject (abfd) == false)317 if (! pe_mkobject (abfd)) 328 318 return NULL; 329 319 … … 368 358 } 369 359 370 static b oolean360 static bfd_boolean 371 361 pe_print_private_bfd_data (abfd, vfile) 372 362 bfd *abfd; … … 376 366 377 367 if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) 378 return false;368 return FALSE; 379 369 380 370 if (pe_saved_coff_bfd_print_private_bfd_data != NULL) … … 385 375 } 386 376 387 return true;377 return TRUE; 388 378 } 389 379 … … 391 381 to the output bfd. */ 392 382 393 static b oolean383 static bfd_boolean 394 384 pe_bfd_copy_private_bfd_data (ibfd, obfd) 395 385 bfd *ibfd, *obfd; 396 386 { 397 387 if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) 398 return false;388 return FALSE; 399 389 400 390 if (pe_saved_coff_bfd_copy_private_bfd_data) 401 391 return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); 402 392 403 return true;393 return TRUE; 404 394 } 405 395 … … 532 522 533 523 coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; 534 coff_section_data (vars->abfd, sec)->keep_relocs = true;524 coff_section_data (vars->abfd, sec)->keep_relocs = TRUE; 535 525 536 526 sec->relocation = vars->reltab; … … 542 532 vars->relcount = 0; 543 533 544 BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *)vars->string_table);534 BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); 545 535 } 546 536 … … 588 578 589 579 /* Initialise the external symbol. */ 590 bfd_h_put_32 (vars->abfd, vars->string_ptr - vars->string_table, (bfd_byte *) esym->e.e.e_offset); 591 bfd_h_put_16 (vars->abfd, section->target_index, (bfd_byte *) esym->e_scnum); 580 H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, 581 esym->e.e.e_offset); 582 H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); 592 583 esym->e_sclass[0] = sclass; 593 584 … … 623 614 sym->symbol.value = 0; 624 615 sym->symbol.udata.i = 0; 625 sym->done_lineno = false;616 sym->done_lineno = FALSE; 626 617 sym->lineno = NULL; 627 618 #endif … … 667 658 /* Set the section size and contents. The actual 668 659 contents are filled in by our parent. */ 669 bfd_set_section_size (vars->abfd, sec, size);660 bfd_set_section_size (vars->abfd, sec, (bfd_size_type) size); 670 661 sec->contents = vars->data; 671 662 sec->target_index = vars->sec_index ++; … … 766 757 767 758 /* Build a full BFD from the information supplied in a ILF object. */ 768 static b oolean759 static bfd_boolean 769 760 pe_ILF_build_a_bfd (bfd * abfd, 770 unsigned shortmagic,761 unsigned int magic, 771 762 bfd_byte * symbol_name, 772 763 bfd_byte * source_dll, … … 796 787 /* XXX code yet to be written. */ 797 788 _bfd_error_handler (_("%s: Unhandled import type; %x"), 798 bfd_ get_filename (abfd), import_type);799 return false;789 bfd_archive_filename (abfd), import_type); 790 return FALSE; 800 791 801 792 default: 802 793 _bfd_error_handler (_("%s: Unrecognised import type; %x"), 803 bfd_ get_filename (abfd), import_type);804 return false;794 bfd_archive_filename (abfd), import_type); 795 return FALSE; 805 796 } 806 797 … … 815 806 default: 816 807 _bfd_error_handler (_("%s: Unrecognised import name type; %x"), 817 bfd_ get_filename (abfd), import_name_type);818 return false;808 bfd_archive_filename (abfd), import_name_type); 809 return FALSE; 819 810 } 820 811 … … 826 817 We are going to construct the contents of the BFD in memory, 827 818 so allocate all the space that we will need right now. */ 828 ptr = bfd_zalloc (abfd, ILF_DATA_SIZE);819 ptr = bfd_zalloc (abfd, (bfd_size_type) ILF_DATA_SIZE); 829 820 if (ptr == NULL) 830 return false;821 return FALSE; 831 822 832 823 /* Create a bfd_in_memory structure. */ … … 888 879 id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); 889 880 if (id4 == NULL || id5 == NULL) 890 return false;881 return FALSE; 891 882 892 883 /* Fill in the contents of these sections. */ … … 907 898 id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); 908 899 if (id6 == NULL) 909 return false;900 return FALSE; 910 901 911 902 /* If necessary, trim the import symbol name. */ … … 934 925 if (import_name_type != IMPORT_ORDINAL) 935 926 { 936 pe_ILF_make_a_reloc (& vars,0, BFD_RELOC_RVA, id6);937 pe_ILF_save_relocs (& 938 939 pe_ILF_make_a_reloc (& vars,0, BFD_RELOC_RVA, id6);940 pe_ILF_save_relocs (& 927 pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); 928 pe_ILF_save_relocs (&vars, id4); 929 930 pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); 931 pe_ILF_save_relocs (&vars, id5); 941 932 } 942 933 … … 963 954 text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); 964 955 if (text == NULL) 965 return false;956 return FALSE; 966 957 967 958 /* Copy in the jump code. */ … … 977 968 if (magic == MIPS_ARCH_MAGIC_WINCE) 978 969 { 979 pe_ILF_make_a_symbol_reloc (& vars, 0, BFD_RELOC_HI16_S, 980 (struct symbol_cache_entry **) imp_sym, imp_index); 981 pe_ILF_make_a_reloc (& vars, 0, BFD_RELOC_LO16, text); 982 pe_ILF_make_a_symbol_reloc (& vars, 4, BFD_RELOC_LO16, 983 (struct symbol_cache_entry **) imp_sym, imp_index); 970 pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, 971 (struct symbol_cache_entry **) imp_sym, 972 imp_index); 973 pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); 974 pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, 975 (struct symbol_cache_entry **) imp_sym, 976 imp_index); 984 977 } 985 978 else 986 979 #endif 987 pe_ILF_make_a_symbol_reloc (& vars, jtab[i].offset, BFD_RELOC_32, 988 (asymbol **) imp_sym, imp_index); 980 pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, 981 BFD_RELOC_32, (asymbol **) imp_sym, 982 imp_index); 989 983 990 984 pe_ILF_save_relocs (& vars, text); … … 1007 1001 internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ 1008 1002 1009 if ( ! bfd_set_start_address (abfd, 0)1003 if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) 1010 1004 || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) 1011 return false;1005 return FALSE; 1012 1006 1013 1007 if (bfd_coff_mkobject_hook (abfd, (PTR) & internal_f, NULL) == NULL) 1014 return false;1008 return FALSE; 1015 1009 1016 1010 coff_data (abfd)->pe = 1; … … 1032 1026 switch (import_type) 1033 1027 { 1034 bfd_byte * ptr;1035 1036 1028 case IMPORT_CODE: 1037 1029 pe_ILF_make_a_symbol (& vars, "", symbol_name, text, … … 1065 1057 1066 1058 obj_coff_external_syms (abfd) = (PTR) vars.esym_table; 1067 obj_coff_keep_syms (abfd) = true;1059 obj_coff_keep_syms (abfd) = TRUE; 1068 1060 1069 1061 obj_convert (abfd) = vars.sym_table; … … 1071 1063 1072 1064 obj_coff_strings (abfd) = vars.string_table; 1073 obj_coff_keep_strings (abfd) = true;1065 obj_coff_keep_strings (abfd) = TRUE; 1074 1066 1075 1067 abfd->flags |= HAS_SYMS; 1076 1068 1077 return true;1069 return TRUE; 1078 1070 } 1079 1071 … … 1088 1080 bfd_byte * source_dll; 1089 1081 unsigned int machine; 1090 unsigned longsize;1082 bfd_size_type size; 1091 1083 unsigned int ordinal; 1092 1084 unsigned int types; 1093 unsigned shortmagic;1085 unsigned int magic; 1094 1086 1095 1087 /* Upon entry the first four buyes of the ILF header have 1096 1088 already been read. Now read the rest of the header. */ 1097 if (bfd_ read (buffer, 1,16, abfd) != 16)1089 if (bfd_bread (buffer, (bfd_size_type) 16, abfd) != 16) 1098 1090 return NULL; 1099 1091 … … 1101 1093 1102 1094 /* We do not bother to check the version number. 1103 version = bfd_h_get_16 (abfd, ptr); */1095 version = H_GET_16 (abfd, ptr); */ 1104 1096 ptr += 2; 1105 1097 1106 machine = bfd_h_get_16 (abfd, ptr);1098 machine = H_GET_16 (abfd, ptr); 1107 1099 ptr += 2; 1108 1100 … … 1172 1164 ( 1173 1165 _("%s: Unrecognised machine type (0x%x) in Import Library Format archive"), 1174 bfd_ get_filename (abfd), machine);1166 bfd_archive_filename (abfd), machine); 1175 1167 bfd_set_error (bfd_error_malformed_archive); 1176 1168 … … 1184 1176 ( 1185 1177 _("%s: Recognised but unhandled machine type (0x%x) in Import Library Format archive"), 1186 bfd_ get_filename (abfd), machine);1178 bfd_archive_filename (abfd), machine); 1187 1179 bfd_set_error (bfd_error_wrong_format); 1188 1180 … … 1191 1183 1192 1184 /* We do not bother to check the date. 1193 date = bfd_h_get_32 (abfd, ptr); */1185 date = H_GET_32 (abfd, ptr); */ 1194 1186 ptr += 4; 1195 1187 1196 size = bfd_h_get_32 (abfd, ptr);1188 size = H_GET_32 (abfd, ptr); 1197 1189 ptr += 4; 1198 1190 … … 1201 1193 _bfd_error_handler 1202 1194 (_("%s: size field is zero in Import Library Format header"), 1203 bfd_ get_filename (abfd));1195 bfd_archive_filename (abfd)); 1204 1196 bfd_set_error (bfd_error_malformed_archive); 1205 1197 … … 1207 1199 } 1208 1200 1209 ordinal = bfd_h_get_16 (abfd, ptr);1201 ordinal = H_GET_16 (abfd, ptr); 1210 1202 ptr += 2; 1211 1203 1212 types = bfd_h_get_16 (abfd, ptr);1204 types = H_GET_16 (abfd, ptr); 1213 1205 /* ptr += 2; */ 1214 1206 … … 1218 1210 return NULL; 1219 1211 1220 if (bfd_read (ptr, 1, size, abfd) != size) 1221 return NULL; 1212 if (bfd_bread (ptr, size, abfd) != size) 1213 { 1214 bfd_release (abfd, ptr); 1215 return NULL; 1216 } 1222 1217 1223 1218 symbol_name = ptr; … … 1229 1224 _bfd_error_handler 1230 1225 (_("%s: string not null terminated in ILF object file."), 1231 bfd_ get_filename (abfd));1226 bfd_archive_filename (abfd)); 1232 1227 bfd_set_error (bfd_error_malformed_archive); 1233 1228 bfd_release (abfd, ptr); 1234 1229 return NULL; 1235 1230 } … … 1238 1233 if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, 1239 1234 source_dll, ordinal, types)) 1240 return NULL; 1235 { 1236 bfd_release (abfd, ptr); 1237 return NULL; 1238 } 1241 1239 1242 1240 return abfd->xvec; … … 1252 1250 1253 1251 /* Detect if this a Microsoft Import Library Format element. */ 1254 if (bfd_seek (abfd, 0x00, SEEK_SET) != 01255 || bfd_ read (buffer, 1,4, abfd) != 4)1252 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 1253 || bfd_bread (buffer, (bfd_size_type) 4, abfd) != 4) 1256 1254 { 1257 1255 if (bfd_get_error () != bfd_error_system_call) … … 1260 1258 } 1261 1259 1262 if ( bfd_h_get_32 (abfd, buffer) == 0xffff0000)1260 if (H_GET_32 (abfd, buffer) == 0xffff0000) 1263 1261 return pe_ILF_object_p (abfd); 1264 1262 1265 if (bfd_seek (abfd, 0x00, SEEK_SET) != 01266 || bfd_ read (&dos_hdr, 1,sizeof (dos_hdr), abfd)1263 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 1264 || bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd) 1267 1265 != sizeof (dos_hdr)) 1268 1266 { … … 1282 1280 it doesn't match, clobber the f_magic number so that we don't get 1283 1281 a false match. */ 1284 if ( bfd_h_get_16 (abfd, (bfd_byte *)dos_hdr.e_magic) != DOSMAGIC)1282 if (H_GET_16 (abfd, dos_hdr.e_magic) != DOSMAGIC) 1285 1283 { 1286 1284 bfd_set_error (bfd_error_wrong_format); … … 1288 1286 } 1289 1287 1290 offset = bfd_h_get_32 (abfd, (bfd_byte *)dos_hdr.e_lfanew);1291 if (bfd_seek (abfd, (file_ptr)offset, SEEK_SET) != 01292 || bfd_read (&image_hdr, 1,sizeof (image_hdr), abfd)1293 != sizeof (image_hdr))1288 offset = H_GET_32 (abfd, dos_hdr.e_lfanew); 1289 if (bfd_seek (abfd, offset, SEEK_SET) != 0 1290 || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd) 1291 != sizeof (image_hdr))) 1294 1292 { 1295 1293 if (bfd_get_error () != bfd_error_system_call) … … 1298 1296 } 1299 1297 1300 if (bfd_h_get_32 (abfd, (bfd_byte *) image_hdr.nt_signature) 1301 != 0x4550) 1298 if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) 1302 1299 { 1303 1300 bfd_set_error (bfd_error_wrong_format); … … 1308 1305 pick up the COFF header for PE, see "struct external_PEI_filehdr" 1309 1306 in include/coff/pe.h. We adjust so that that will work. */ 1310 if (bfd_seek (abfd, 1311 (file_ptr) (offset - sizeof (dos_hdr)), 1312 SEEK_SET) 1313 != 0) 1307 if (bfd_seek (abfd, (file_ptr) (offset - sizeof (dos_hdr)), SEEK_SET) != 0) 1314 1308 { 1315 1309 if (bfd_get_error () != bfd_error_system_call) -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.