Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/bfd/peicode.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* 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
    33   Free Software Foundation, Inc.
    44   Written by Cygnus Solutions.
    55
    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,
    2423                        sac@cygnus.com
    2524
    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.  */
    2927
    3028/* Hey look, some documentation [and in a place you expect to find it]!
     
    5452   FIXME: Please add more docs here so the next poor fool that has to hack
    5553   on this code has a chance of getting something accomplished without
    56    wasting too much time.
    57 */
     54   wasting too much time.  */
    5855
    5956#include "libpei.h"
    6057
    61 static boolean (*pe_saved_coff_bfd_print_private_bfd_data)
     58static bfd_boolean (*pe_saved_coff_bfd_print_private_bfd_data)
    6259    PARAMS ((bfd *, PTR)) =
    6360#ifndef coff_bfd_print_private_bfd_data
     
    6865#endif
    6966
    70 static boolean pe_print_private_bfd_data PARAMS ((bfd *, PTR));
     67static bfd_boolean pe_print_private_bfd_data PARAMS ((bfd *, PTR));
    7168#define coff_bfd_print_private_bfd_data pe_print_private_bfd_data
    7269
    73 static boolean (*pe_saved_coff_bfd_copy_private_bfd_data)
     70static bfd_boolean (*pe_saved_coff_bfd_copy_private_bfd_data)
    7471    PARAMS ((bfd *, bfd *)) =
    7572#ifndef coff_bfd_copy_private_bfd_data
     
    8077#endif
    8178
    82 static boolean pe_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *));
     79static bfd_boolean pe_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *));
    8380#define coff_bfd_copy_private_bfd_data pe_bfd_copy_private_bfd_data
    8481
     
    9289static void coff_swap_filehdr_in PARAMS ((bfd *, PTR, PTR));
    9390static void coff_swap_scnhdr_in PARAMS ((bfd *, PTR, PTR));
    94 static boolean pe_mkobject PARAMS ((bfd *));
     91static bfd_boolean pe_mkobject PARAMS ((bfd *));
    9592static PTR pe_mkobject_hook PARAMS ((bfd *, PTR, PTR));
    9693
     
    140137static void               pe_ILF_save_relocs      PARAMS ((pe_ILF_vars *, asection_ptr));
    141138static 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 boolean            pe_ILF_build_a_bfd      PARAMS ((bfd *, unsigned short, bfd_byte *, bfd_byte *, unsigned int, unsigned int));
     139static bfd_boolean        pe_ILF_build_a_bfd      PARAMS ((bfd *, unsigned int, bfd_byte *, bfd_byte *, unsigned int, unsigned int));
    143140static const bfd_target * pe_ILF_object_p         PARAMS ((bfd *));
    144141static const bfd_target * pe_bfd_object_p         PARAMS ((bfd *));
     
    157154  struct internal_reloc *reloc_dst = (struct internal_reloc *) dst;
    158155
    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);
    163160
    164161#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);
    167163#endif
    168164}
     
    176172  struct internal_reloc *reloc_src = (struct internal_reloc *)src;
    177173  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);
    183178
    184179#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);
    188181#endif
    189182#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);
    191184#endif
    192185  return RELSZ;
     
    202195  FILHDR *filehdr_src = (FILHDR *) src;
    203196  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);
    211204
    212205  /* Other people's tools sometimes generate headers with an nsyms but
     
    218211    }
    219212
    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);
    222214}
    223215
     
    238230
    239231  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);
    253239
    254240  /* MS handles overflow of line numbers by carrying into the reloc
     
    256242     *IMAGE* format, that's safe.  This is still a bit iffy.  */
    257243#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));
    261246  scnhdr_int->s_nreloc = 0;
    262247#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);
    267250#endif
    268251
     
    274257
    275258#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))
    279267    {
    280268      scnhdr_int->s_size = scnhdr_int->s_paddr;
     269
    281270      /* This code used to set scnhdr_int->s_paddr to 0.  However,
    282271         coff_set_alignment_hook stores s_paddr in virt_size, which
     
    287276}
    288277
    289 static boolean
     278static bfd_boolean
    290279pe_mkobject (abfd)
    291280     bfd * abfd;
    292281{
    293282  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);
    296286
    297287  if (abfd->tdata.pe_obj_data == 0)
    298     return false;
     288    return FALSE;
    299289
    300290  pe = pe_data (abfd);
     
    312302#endif
    313303
    314   return true;
     304  return TRUE;
    315305}
    316306
     
    325315  pe_data_type *pe;
    326316
    327   if (pe_mkobject (abfd) == false)
     317  if (! pe_mkobject (abfd))
    328318    return NULL;
    329319
     
    368358}
    369359
    370 static boolean
     360static bfd_boolean
    371361pe_print_private_bfd_data (abfd, vfile)
    372362     bfd *abfd;
     
    376366
    377367  if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile))
    378     return false;
     368    return FALSE;
    379369
    380370  if (pe_saved_coff_bfd_print_private_bfd_data != NULL)
     
    385375    }
    386376
    387   return true;
     377  return TRUE;
    388378}
    389379
     
    391381   to the output bfd.  */
    392382
    393 static boolean
     383static bfd_boolean
    394384pe_bfd_copy_private_bfd_data (ibfd, obfd)
    395385     bfd *ibfd, *obfd;
    396386{
    397387  if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd))
    398     return false;
     388    return FALSE;
    399389
    400390  if (pe_saved_coff_bfd_copy_private_bfd_data)
    401391    return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd);
    402392
    403   return true;
     393  return TRUE;
    404394}
    405395
     
    532522
    533523  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;
    535525
    536526  sec->relocation  = vars->reltab;
     
    542532  vars->relcount   = 0;
    543533
    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);
    545535}
    546536
     
    588578
    589579  /* 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);
    592583  esym->e_sclass[0] = sclass;
    593584
     
    623614  sym->symbol.value   = 0;
    624615  sym->symbol.udata.i = 0;
    625   sym->done_lineno    = false;
     616  sym->done_lineno    = FALSE;
    626617  sym->lineno         = NULL;
    627618#endif
     
    667658  /* Set the section size and contents.  The actual
    668659     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);
    670661  sec->contents = vars->data;
    671662  sec->target_index = vars->sec_index ++;
     
    766757
    767758/* Build a full BFD from the information supplied in a ILF object.  */
    768 static boolean
     759static bfd_boolean
    769760pe_ILF_build_a_bfd (bfd *           abfd,
    770                     unsigned short  magic,
     761                    unsigned int    magic,
    771762                    bfd_byte *      symbol_name,
    772763                    bfd_byte *      source_dll,
     
    796787      /* XXX code yet to be written.  */
    797788      _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;
    800791
    801792    default:
    802793      _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;
    805796    }
    806797
     
    815806    default:
    816807      _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;
    819810    }
    820811
     
    826817     We are going to construct the contents of the BFD in memory,
    827818     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);
    829820  if (ptr == NULL)
    830     return false;
     821    return FALSE;
    831822
    832823  /* Create a bfd_in_memory structure.  */
     
    888879  id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0);
    889880  if (id4 == NULL || id5 == NULL)
    890     return false;
     881    return FALSE;
    891882
    892883  /* Fill in the contents of these sections.  */
     
    907898      id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0);
    908899      if (id6 == NULL)
    909         return false;
     900        return FALSE;
    910901
    911902      /* If necessary, trim the import symbol name.  */
     
    934925  if (import_name_type != IMPORT_ORDINAL)
    935926    {
    936       pe_ILF_make_a_reloc (& vars, 0, BFD_RELOC_RVA, id6);
    937       pe_ILF_save_relocs (& vars, id4);
    938 
    939       pe_ILF_make_a_reloc (& vars, 0, BFD_RELOC_RVA, id6);
    940       pe_ILF_save_relocs (& vars, id5);
     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);
    941932    }
    942933
     
    963954      text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE);
    964955      if (text == NULL)
    965         return false;
     956        return FALSE;
    966957
    967958      /* Copy in the jump code.  */
     
    977968      if (magic == MIPS_ARCH_MAGIC_WINCE)
    978969        {
    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);
    984977        }
    985978      else
    986979#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);
    989983
    990984      pe_ILF_save_relocs (& vars, text);
     
    10071001  internal_f.f_flags  = F_AR32WR | F_LNNO; /* XXX is this correct ?  */
    10081002
    1009   if (   ! bfd_set_start_address (abfd, 0)
     1003  if (   ! bfd_set_start_address (abfd, (bfd_vma) 0)
    10101004      || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f))
    1011     return false;
     1005    return FALSE;
    10121006
    10131007  if (bfd_coff_mkobject_hook (abfd, (PTR) & internal_f, NULL) == NULL)
    1014     return false;
     1008    return FALSE;
    10151009
    10161010  coff_data (abfd)->pe = 1;
     
    10321026  switch (import_type)
    10331027    {
    1034       bfd_byte * ptr;
    1035 
    10361028    case IMPORT_CODE:
    10371029      pe_ILF_make_a_symbol (& vars, "", symbol_name, text,
     
    10651057
    10661058  obj_coff_external_syms (abfd) = (PTR) vars.esym_table;
    1067   obj_coff_keep_syms (abfd) = true;
     1059  obj_coff_keep_syms (abfd) = TRUE;
    10681060
    10691061  obj_convert (abfd) = vars.sym_table;
     
    10711063
    10721064  obj_coff_strings (abfd) = vars.string_table;
    1073   obj_coff_keep_strings (abfd) = true;
     1065  obj_coff_keep_strings (abfd) = TRUE;
    10741066
    10751067  abfd->flags |= HAS_SYMS;
    10761068
    1077   return true;
     1069  return TRUE;
    10781070}
    10791071
     
    10881080  bfd_byte *      source_dll;
    10891081  unsigned int    machine;
    1090   unsigned long   size;
     1082  bfd_size_type   size;
    10911083  unsigned int    ordinal;
    10921084  unsigned int    types;
    1093   unsigned short  magic;
     1085  unsigned int    magic;
    10941086
    10951087  /* Upon entry the first four buyes of the ILF header have
    10961088      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)
    10981090    return NULL;
    10991091
     
    11011093
    11021094  /*  We do not bother to check the version number.
    1103       version = bfd_h_get_16 (abfd, ptr);  */
     1095      version = H_GET_16 (abfd, ptr);  */
    11041096  ptr += 2;
    11051097
    1106   machine = bfd_h_get_16 (abfd, ptr);
     1098  machine = H_GET_16 (abfd, ptr);
    11071099  ptr += 2;
    11081100
     
    11721164        (
    11731165_("%s: Unrecognised machine type (0x%x) in Import Library Format archive"),
    1174          bfd_get_filename (abfd), machine);
     1166         bfd_archive_filename (abfd), machine);
    11751167      bfd_set_error (bfd_error_malformed_archive);
    11761168
     
    11841176        (
    11851177_("%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);
    11871179      bfd_set_error (bfd_error_wrong_format);
    11881180
     
    11911183
    11921184  /* We do not bother to check the date.
    1193      date = bfd_h_get_32 (abfd, ptr);  */
     1185     date = H_GET_32 (abfd, ptr);  */
    11941186  ptr += 4;
    11951187
    1196   size = bfd_h_get_32 (abfd, ptr);
     1188  size = H_GET_32 (abfd, ptr);
    11971189  ptr += 4;
    11981190
     
    12011193      _bfd_error_handler
    12021194        (_("%s: size field is zero in Import Library Format header"),
    1203          bfd_get_filename (abfd));
     1195         bfd_archive_filename (abfd));
    12041196      bfd_set_error (bfd_error_malformed_archive);
    12051197
     
    12071199    }
    12081200
    1209   ordinal = bfd_h_get_16 (abfd, ptr);
     1201  ordinal = H_GET_16 (abfd, ptr);
    12101202  ptr += 2;
    12111203
    1212   types = bfd_h_get_16 (abfd, ptr);
     1204  types = H_GET_16 (abfd, ptr);
    12131205  /* ptr += 2; */
    12141206
     
    12181210    return NULL;
    12191211
    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    }
    12221217
    12231218  symbol_name = ptr;
     
    12291224      _bfd_error_handler
    12301225        (_("%s: string not null terminated in ILF object file."),
    1231          bfd_get_filename (abfd));
     1226         bfd_archive_filename (abfd));
    12321227      bfd_set_error (bfd_error_malformed_archive);
    1233 
     1228      bfd_release (abfd, ptr);
    12341229      return NULL;
    12351230    }
     
    12381233  if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name,
    12391234                            source_dll, ordinal, types))
    1240     return NULL;
     1235    {
     1236      bfd_release (abfd, ptr);
     1237      return NULL;
     1238    }
    12411239
    12421240  return abfd->xvec;
     
    12521250
    12531251  /* Detect if this a Microsoft Import Library Format element.  */
    1254   if (bfd_seek (abfd, 0x00, SEEK_SET) != 0
    1255       || 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)
    12561254    {
    12571255      if (bfd_get_error () != bfd_error_system_call)
     
    12601258    }
    12611259
    1262   if (bfd_h_get_32 (abfd, buffer) == 0xffff0000)
     1260  if (H_GET_32 (abfd, buffer) == 0xffff0000)
    12631261    return pe_ILF_object_p (abfd);
    12641262
    1265   if (bfd_seek (abfd, 0x00, SEEK_SET) != 0
    1266       || 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)
    12671265         != sizeof (dos_hdr))
    12681266    {
     
    12821280     it doesn't match, clobber the f_magic number so that we don't get
    12831281     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)
    12851283    {
    12861284      bfd_set_error (bfd_error_wrong_format);
     
    12881286    }
    12891287
    1290   offset = bfd_h_get_32 (abfd, (bfd_byte *) dos_hdr.e_lfanew);
    1291   if (bfd_seek (abfd, (file_ptr) offset, SEEK_SET) != 0
    1292       || 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)))
    12941292    {
    12951293      if (bfd_get_error () != bfd_error_system_call)
     
    12981296    }
    12991297
    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)
    13021299    {
    13031300      bfd_set_error (bfd_error_wrong_format);
     
    13081305     pick up the COFF header for PE, see "struct external_PEI_filehdr"
    13091306     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)
    13141308    {
    13151309      if (bfd_get_error () != bfd_error_system_call)
Note: See TracChangeset for help on using the changeset viewer.