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/peXXigen.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* Support for the generic parts of PE/PEI; the common executable parts.
    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.  */
     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.  */
    2121
    2222/* Most of this hacked by Steve Chamberlain <sac@cygnus.com>.
    2323
    2424   PE/PEI rearrangement (and code added): Donn Terry
    25                                           Softway Systems, Inc.
    26 */
     25                                          Softway Systems, Inc.  */
    2726
    2827/* Hey look, some documentation [and in a place you expect to find it]!
     
    5251   FIXME: Please add more docs here so the next poor fool that has to hack
    5352   on this code has a chance of getting something accomplished without
    54    wasting too much time.
    55 */
     53   wasting too much time.  */
    5654
    5755/* This expands into COFF_WITH_pe or COFF_WITH_pep depending on whether
     
    9492static void add_data_entry
    9593  PARAMS ((bfd *, struct internal_extra_pe_aouthdr *, int, char *, bfd_vma));
    96 static boolean pe_print_pdata PARAMS ((bfd *, PTR));
    97 static boolean pe_print_reloc PARAMS ((bfd *, PTR));
    98 
    99 /**********************************************************************/
     94static bfd_boolean pe_print_pdata PARAMS ((bfd *, PTR));
     95static bfd_boolean pe_print_reloc PARAMS ((bfd *, PTR));
     96static bfd_boolean pe_print_idata PARAMS ((bfd *, PTR));
     97static bfd_boolean pe_print_edata PARAMS ((bfd *, PTR));
     98
     99
    100100
    101101void
     
    111111    {
    112112      in->_n._n_n._n_zeroes = 0;
    113       in->_n._n_n._n_offset =
    114         bfd_h_get_32 (abfd, (bfd_byte *) ext->e.e.e_offset);
     113      in->_n._n_n._n_offset = H_GET_32 (abfd, ext->e.e.e_offset);
    115114    }
    116115  else
    117     {
    118       memcpy (in->_n._n_name, ext->e.e_name, SYMNMLEN);
    119     }
    120 
    121   in->n_value = bfd_h_get_32 (abfd, (bfd_byte *) ext->e_value);
    122   in->n_scnum = bfd_h_get_16 (abfd, (bfd_byte *) ext->e_scnum);
     116    memcpy (in->_n._n_name, ext->e.e_name, SYMNMLEN);
     117
     118  in->n_value = H_GET_32 (abfd, ext->e_value);
     119  in->n_scnum = H_GET_16 (abfd, ext->e_scnum);
     120
    123121  if (sizeof (ext->e_type) == 2)
    124     {
    125       in->n_type = bfd_h_get_16 (abfd, (bfd_byte *) ext->e_type);
    126     }
     122    in->n_type = H_GET_16 (abfd, ext->e_type);
    127123  else
    128     {
    129       in->n_type = bfd_h_get_32 (abfd, (bfd_byte *) ext->e_type);
    130     }
    131   in->n_sclass = bfd_h_get_8 (abfd, ext->e_sclass);
    132   in->n_numaux = bfd_h_get_8 (abfd, ext->e_numaux);
     124    in->n_type = H_GET_32 (abfd, ext->e_type);
     125
     126  in->n_sclass = H_GET_8 (abfd, ext->e_sclass);
     127  in->n_numaux = H_GET_8 (abfd, ext->e_numaux);
    133128
    134129#ifndef STRICT_PE_FORMAT
     
    167162        {
    168163          asection *sec;
     164
    169165          for (sec = abfd->sections; sec; sec = sec->next)
    170166            {
     
    176172            }
    177173        }
     174
    178175      if (in->n_scnum == 0)
    179176        {
     
    181178          asection *sec;
    182179          char *name;
     180
    183181          for (sec = abfd->sections; sec; sec = sec->next)
    184182            if (unused_section_number <= sec->target_index)
    185183              unused_section_number = sec->target_index + 1;
    186184
    187           name = bfd_alloc (abfd, strlen (in->n_name) + 10);
     185          name = bfd_alloc (abfd, (bfd_size_type) strlen (in->n_name) + 10);
    188186          if (name == NULL)
    189187            return;
     
    230228  struct internal_syment *in = (struct internal_syment *) inp;
    231229  SYMENT *ext = (SYMENT *) extp;
     230
    232231  if (in->_n._n_name[0] == 0)
    233232    {
    234       bfd_h_put_32 (abfd, 0, (bfd_byte *) ext->e.e.e_zeroes);
    235       bfd_h_put_32 (abfd, in->_n._n_n._n_offset, (bfd_byte *) ext->e.e.e_offset);
     233      H_PUT_32 (abfd, 0, ext->e.e.e_zeroes);
     234      H_PUT_32 (abfd, in->_n._n_n._n_offset, ext->e.e.e_offset);
    236235    }
    237236  else
    238     {
    239       memcpy (ext->e.e_name, in->_n._n_name, SYMNMLEN);
    240     }
    241 
    242   bfd_h_put_32 (abfd, in->n_value, (bfd_byte *) ext->e_value);
    243   bfd_h_put_16 (abfd, in->n_scnum, (bfd_byte *) ext->e_scnum);
     237    memcpy (ext->e.e_name, in->_n._n_name, SYMNMLEN);
     238
     239  H_PUT_32 (abfd, in->n_value, ext->e_value);
     240  H_PUT_16 (abfd, in->n_scnum, ext->e_scnum);
     241
    244242  if (sizeof (ext->e_type) == 2)
    245     {
    246       bfd_h_put_16 (abfd, in->n_type, (bfd_byte *) ext->e_type);
    247     }
     243    H_PUT_16 (abfd, in->n_type, ext->e_type);
    248244  else
    249     {
    250       bfd_h_put_32 (abfd, in->n_type, (bfd_byte *) ext->e_type);
    251     }
    252   bfd_h_put_8 (abfd, in->n_sclass, ext->e_sclass);
    253   bfd_h_put_8 (abfd, in->n_numaux, ext->e_numaux);
     245    H_PUT_32 (abfd, in->n_type, ext->e_type);
     246
     247  H_PUT_8 (abfd, in->n_sclass, ext->e_sclass);
     248  H_PUT_8 (abfd, in->n_numaux, ext->e_numaux);
    254249
    255250  return SYMESZ;
     
    275270        {
    276271          in->x_file.x_n.x_zeroes = 0;
    277           in->x_file.x_n.x_offset =
    278             bfd_h_get_32 (abfd, (bfd_byte *) ext->x_file.x_n.x_offset);
     272          in->x_file.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
    279273        }
    280274      else
    281         {
    282           memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
    283         }
     275        memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
    284276      return;
    285277
     
    292284          in->x_scn.x_nreloc = GET_SCN_NRELOC (abfd, ext);
    293285          in->x_scn.x_nlinno = GET_SCN_NLINNO (abfd, ext);
    294           in->x_scn.x_checksum =
    295             bfd_h_get_32 (abfd, (bfd_byte *) ext->x_scn.x_checksum);
    296           in->x_scn.x_associated =
    297             bfd_h_get_16 (abfd, (bfd_byte *) ext->x_scn.x_associated);
    298           in->x_scn.x_comdat =
    299             bfd_h_get_8 (abfd, (bfd_byte *) ext->x_scn.x_comdat);
     286          in->x_scn.x_checksum = H_GET_32 (abfd, ext->x_scn.x_checksum);
     287          in->x_scn.x_associated = H_GET_16 (abfd, ext->x_scn.x_associated);
     288          in->x_scn.x_comdat = H_GET_8 (abfd, ext->x_scn.x_comdat);
    300289          return;
    301290        }
     
    303292    }
    304293
    305   in->x_sym.x_tagndx.l = bfd_h_get_32 (abfd, (bfd_byte *) ext->x_sym.x_tagndx);
    306   in->x_sym.x_tvndx = bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_tvndx);
     294  in->x_sym.x_tagndx.l = H_GET_32 (abfd, ext->x_sym.x_tagndx);
     295  in->x_sym.x_tvndx = H_GET_16 (abfd, ext->x_sym.x_tvndx);
    307296
    308297  if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
     
    314303    {
    315304      in->x_sym.x_fcnary.x_ary.x_dimen[0] =
    316         bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
     305        H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
    317306      in->x_sym.x_fcnary.x_ary.x_dimen[1] =
    318         bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
     307        H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
    319308      in->x_sym.x_fcnary.x_ary.x_dimen[2] =
    320         bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
     309        H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
    321310      in->x_sym.x_fcnary.x_ary.x_dimen[3] =
    322         bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
     311        H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
    323312    }
    324313
    325314  if (ISFCN (type))
    326315    {
    327       in->x_sym.x_misc.x_fsize =
    328         bfd_h_get_32 (abfd, (bfd_byte *) ext->x_sym.x_misc.x_fsize);
     316      in->x_sym.x_misc.x_fsize = H_GET_32 (abfd, ext->x_sym.x_misc.x_fsize);
    329317    }
    330318  else
     
    354342      if (in->x_file.x_fname[0] == 0)
    355343        {
    356           bfd_h_put_32 (abfd, 0, (bfd_byte *) ext->x_file.x_n.x_zeroes);
    357           bfd_h_put_32 (abfd,
    358                         in->x_file.x_n.x_offset,
    359                         (bfd_byte *) ext->x_file.x_n.x_offset);
     344          H_PUT_32 (abfd, 0, ext->x_file.x_n.x_zeroes);
     345          H_PUT_32 (abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset);
    360346        }
    361347      else
    362         {
    363           memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
    364         }
     348        memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
     349
    365350      return AUXESZ;
    366351
     
    373358          PUT_SCN_NRELOC (abfd, in->x_scn.x_nreloc, ext);
    374359          PUT_SCN_NLINNO (abfd, in->x_scn.x_nlinno, ext);
    375           bfd_h_put_32 (abfd, in->x_scn.x_checksum,
    376                         (bfd_byte *) ext->x_scn.x_checksum);
    377           bfd_h_put_16 (abfd, in->x_scn.x_associated,
    378                         (bfd_byte *) ext->x_scn.x_associated);
    379           bfd_h_put_8 (abfd, in->x_scn.x_comdat,
    380                        (bfd_byte *) ext->x_scn.x_comdat);
     360          H_PUT_32 (abfd, in->x_scn.x_checksum, ext->x_scn.x_checksum);
     361          H_PUT_16 (abfd, in->x_scn.x_associated, ext->x_scn.x_associated);
     362          H_PUT_8 (abfd, in->x_scn.x_comdat, ext->x_scn.x_comdat);
    381363          return AUXESZ;
    382364        }
     
    384366    }
    385367
    386   bfd_h_put_32 (abfd, in->x_sym.x_tagndx.l, (bfd_byte *) ext->x_sym.x_tagndx);
    387   bfd_h_put_16 (abfd, in->x_sym.x_tvndx, (bfd_byte *) ext->x_sym.x_tvndx);
     368  H_PUT_32 (abfd, in->x_sym.x_tagndx.l, ext->x_sym.x_tagndx);
     369  H_PUT_16 (abfd, in->x_sym.x_tvndx, ext->x_sym.x_tvndx);
    388370
    389371  if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
     
    394376  else
    395377    {
    396       bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],
    397                     (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
    398       bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],
    399                     (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
    400       bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],
    401                     (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
    402       bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],
    403                     (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
     378      H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],
     379                ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
     380      H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],
     381                ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
     382      H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],
     383                ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
     384      H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],
     385                ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
    404386    }
    405387
    406388  if (ISFCN (type))
    407     bfd_h_put_32 (abfd, in->x_sym.x_misc.x_fsize,
    408                   (bfd_byte *) ext->x_sym.x_misc.x_fsize);
     389    H_PUT_32 (abfd, in->x_sym.x_misc.x_fsize, ext->x_sym.x_misc.x_fsize);
    409390  else
    410391    {
     
    425406  struct internal_lineno *in = (struct internal_lineno *) in1;
    426407
    427   in->l_addr.l_symndx = bfd_h_get_32 (abfd, (bfd_byte *) ext->l_addr.l_symndx);
     408  in->l_addr.l_symndx = H_GET_32 (abfd, ext->l_addr.l_symndx);
    428409  in->l_lnno = GET_LINENO_LNNO (abfd, ext);
    429410}
     
    437418  struct internal_lineno *in = (struct internal_lineno *) inp;
    438419  struct external_lineno *ext = (struct external_lineno *) outp;
    439   bfd_h_put_32 (abfd, in->l_addr.l_symndx, (bfd_byte *)
    440           ext->l_addr.l_symndx);
     420  H_PUT_32 (abfd, in->l_addr.l_symndx, ext->l_addr.l_symndx);
    441421
    442422  PUT_LINENO_LNNO (abfd, in->l_lnno, ext);
     
    455435  struct internal_aouthdr *aouthdr_int = (struct internal_aouthdr *)aouthdr_int1;
    456436
    457   aouthdr_int->magic = bfd_h_get_16 (abfd, (bfd_byte *) aouthdr_ext->magic);
    458   aouthdr_int->vstamp = bfd_h_get_16 (abfd, (bfd_byte *) aouthdr_ext->vstamp);
    459   aouthdr_int->tsize =
    460     GET_AOUTHDR_TSIZE (abfd, (bfd_byte *) aouthdr_ext->tsize);
    461   aouthdr_int->dsize =
    462     GET_AOUTHDR_DSIZE (abfd, (bfd_byte *) aouthdr_ext->dsize);
    463   aouthdr_int->bsize =
    464     GET_AOUTHDR_BSIZE (abfd, (bfd_byte *) aouthdr_ext->bsize);
    465   aouthdr_int->entry =
    466     GET_AOUTHDR_ENTRY (abfd, (bfd_byte *) aouthdr_ext->entry);
     437  aouthdr_int->magic = H_GET_16 (abfd, aouthdr_ext->magic);
     438  aouthdr_int->vstamp = H_GET_16 (abfd, aouthdr_ext->vstamp);
     439  aouthdr_int->tsize = GET_AOUTHDR_TSIZE (abfd, aouthdr_ext->tsize);
     440  aouthdr_int->dsize = GET_AOUTHDR_DSIZE (abfd, aouthdr_ext->dsize);
     441  aouthdr_int->bsize = GET_AOUTHDR_BSIZE (abfd, aouthdr_ext->bsize);
     442  aouthdr_int->entry = GET_AOUTHDR_ENTRY (abfd, aouthdr_ext->entry);
    467443  aouthdr_int->text_start =
    468     GET_AOUTHDR_TEXT_START (abfd, (bfd_byte *) aouthdr_ext->text_start);
     444    GET_AOUTHDR_TEXT_START (abfd, aouthdr_ext->text_start);
    469445#ifndef COFF_WITH_pep
    470446  /* PE32+ does not have data_start member! */
    471447  aouthdr_int->data_start =
    472     GET_AOUTHDR_DATA_START (abfd, (bfd_byte *) aouthdr_ext->data_start);
     448    GET_AOUTHDR_DATA_START (abfd, aouthdr_ext->data_start);
    473449#endif
    474450
    475451  a = &aouthdr_int->pe;
    476   a->ImageBase = GET_OPTHDR_IMAGE_BASE (abfd, (bfd_byte *) src->ImageBase);
    477   a->SectionAlignment = bfd_h_get_32 (abfd, (bfd_byte *) src->SectionAlignment);
    478   a->FileAlignment = bfd_h_get_32 (abfd, (bfd_byte *) src->FileAlignment);
     452  a->ImageBase = GET_OPTHDR_IMAGE_BASE (abfd, src->ImageBase);
     453  a->SectionAlignment = H_GET_32 (abfd, src->SectionAlignment);
     454  a->FileAlignment = H_GET_32 (abfd, src->FileAlignment);
    479455  a->MajorOperatingSystemVersion =
    480     bfd_h_get_16 (abfd, (bfd_byte *) src->MajorOperatingSystemVersion);
     456    H_GET_16 (abfd, src->MajorOperatingSystemVersion);
    481457  a->MinorOperatingSystemVersion =
    482     bfd_h_get_16 (abfd, (bfd_byte *) src->MinorOperatingSystemVersion);
    483   a->MajorImageVersion = bfd_h_get_16 (abfd, (bfd_byte *) src->MajorImageVersion);
    484   a->MinorImageVersion = bfd_h_get_16 (abfd, (bfd_byte *) src->MinorImageVersion);
    485   a->MajorSubsystemVersion = bfd_h_get_16 (abfd, (bfd_byte *) src->MajorSubsystemVersion);
    486   a->MinorSubsystemVersion = bfd_h_get_16 (abfd, (bfd_byte *) src->MinorSubsystemVersion);
    487   a->Reserved1 = bfd_h_get_32 (abfd, (bfd_byte *) src->Reserved1);
    488   a->SizeOfImage = bfd_h_get_32 (abfd, (bfd_byte *) src->SizeOfImage);
    489   a->SizeOfHeaders = bfd_h_get_32 (abfd, (bfd_byte *) src->SizeOfHeaders);
    490   a->CheckSum = bfd_h_get_32 (abfd, (bfd_byte *) src->CheckSum);
    491   a->Subsystem = bfd_h_get_16 (abfd, (bfd_byte *) src->Subsystem);
    492   a->DllCharacteristics = bfd_h_get_16 (abfd, (bfd_byte *) src->DllCharacteristics);
    493   a->SizeOfStackReserve = GET_OPTHDR_SIZE_OF_STACK_RESERVE (abfd, (bfd_byte *) src->SizeOfStackReserve);
    494   a->SizeOfStackCommit = GET_OPTHDR_SIZE_OF_STACK_COMMIT (abfd, (bfd_byte *) src->SizeOfStackCommit);
    495   a->SizeOfHeapReserve = GET_OPTHDR_SIZE_OF_HEAP_RESERVE (abfd, (bfd_byte *) src->SizeOfHeapReserve);
    496   a->SizeOfHeapCommit = GET_OPTHDR_SIZE_OF_HEAP_COMMIT (abfd, (bfd_byte *) src->SizeOfHeapCommit);
    497   a->LoaderFlags = bfd_h_get_32 (abfd, (bfd_byte *) src->LoaderFlags);
    498   a->NumberOfRvaAndSizes = bfd_h_get_32 (abfd, (bfd_byte *) src->NumberOfRvaAndSizes);
     458    H_GET_16 (abfd, src->MinorOperatingSystemVersion);
     459  a->MajorImageVersion = H_GET_16 (abfd, src->MajorImageVersion);
     460  a->MinorImageVersion = H_GET_16 (abfd, src->MinorImageVersion);
     461  a->MajorSubsystemVersion = H_GET_16 (abfd, src->MajorSubsystemVersion);
     462  a->MinorSubsystemVersion = H_GET_16 (abfd, src->MinorSubsystemVersion);
     463  a->Reserved1 = H_GET_32 (abfd, src->Reserved1);
     464  a->SizeOfImage = H_GET_32 (abfd, src->SizeOfImage);
     465  a->SizeOfHeaders = H_GET_32 (abfd, src->SizeOfHeaders);
     466  a->CheckSum = H_GET_32 (abfd, src->CheckSum);
     467  a->Subsystem = H_GET_16 (abfd, src->Subsystem);
     468  a->DllCharacteristics = H_GET_16 (abfd, src->DllCharacteristics);
     469  a->SizeOfStackReserve =
     470    GET_OPTHDR_SIZE_OF_STACK_RESERVE (abfd, src->SizeOfStackReserve);
     471  a->SizeOfStackCommit =
     472    GET_OPTHDR_SIZE_OF_STACK_COMMIT (abfd, src->SizeOfStackCommit);
     473  a->SizeOfHeapReserve =
     474    GET_OPTHDR_SIZE_OF_HEAP_RESERVE (abfd, src->SizeOfHeapReserve);
     475  a->SizeOfHeapCommit =
     476    GET_OPTHDR_SIZE_OF_HEAP_COMMIT (abfd, src->SizeOfHeapCommit);
     477  a->LoaderFlags = H_GET_32 (abfd, src->LoaderFlags);
     478  a->NumberOfRvaAndSizes = H_GET_32 (abfd, src->NumberOfRvaAndSizes);
    499479
    500480  {
    501481    int idx;
     482
    502483    for (idx = 0; idx < 16; idx++)
    503484      {
    504485        /* If data directory is empty, rva also should be 0.  */
    505486        int size =
    506           bfd_h_get_32 (abfd, (bfd_byte *) src->DataDirectory[idx][1]);
     487          H_GET_32 (abfd, src->DataDirectory[idx][1]);
    507488        a->DataDirectory[idx].Size = size;
    508489
    509490        if (size)
    510           {
    511             a->DataDirectory[idx].VirtualAddress =
    512               bfd_h_get_32 (abfd, (bfd_byte *) src->DataDirectory[idx][0]);
    513           }
     491          a->DataDirectory[idx].VirtualAddress =
     492            H_GET_32 (abfd, src->DataDirectory[idx][0]);
    514493        else
    515494          a->DataDirectory[idx].VirtualAddress = 0;
     
    524503#endif
    525504    }
     505
    526506  if (aouthdr_int->tsize)
    527507    {
     
    531511#endif
    532512    }
     513
    533514#ifndef COFF_WITH_pep
    534515  /* PE32+ does not have data_start member! */
     
    548529  import_table_size = a->DataDirectory[1].Size;
    549530#endif
    550 
    551531}
    552532
     
    563543  asection *sec = bfd_get_section_by_name (abfd, name);
    564544
    565   /* add import directory information if it exists */
     545  /* Add import directory information if it exists. */
    566546  if ((sec != NULL)
    567547      && (coff_section_data (abfd, sec) != NULL)
    568548      && (pei_section_data (abfd, sec) != NULL))
    569549    {
    570       /* If data directory is empty, rva also should be 0 */
     550      /* If data directory is empty, rva also should be 0. */
    571551      int size = pei_section_data (abfd, sec)->virt_size;
    572552      aout->DataDirectory[idx].Size = size;
     
    592572  PEAOUTHDR *aouthdr_out = (PEAOUTHDR *) out;
    593573  bfd_vma sa, fa, ib;
    594 
     574  IMAGE_DATA_DIRECTORY idata2, idata5;
     575
     576 
    595577  if (pe->force_minimum_alignment)
    596578    {
     
    608590  ib = extra->ImageBase;
    609591
     592  idata2 = pe->pe_opthdr.DataDirectory[1];
     593  idata5 = pe->pe_opthdr.DataDirectory[12];
     594 
    610595  if (aouthdr_in->tsize)
    611596    {
     
    615600#endif
    616601    }
     602
    617603  if (aouthdr_in->dsize)
    618604    {
     
    622608#endif
    623609    }
     610
    624611  if (aouthdr_in->entry)
    625612    {
     
    634621
    635622  /* We like to have the sizes aligned.  */
    636 
    637623  aouthdr_in->bsize = FA (aouthdr_in->bsize);
    638624
    639625  extra->NumberOfRvaAndSizes = IMAGE_NUMBEROF_DIRECTORY_ENTRIES;
    640626
    641   /* first null out all data directory entries ..  */
    642   memset (extra->DataDirectory, sizeof (extra->DataDirectory), 0);
     627  /* First null out all data directory entries.  */
     628  memset (extra->DataDirectory, 0, sizeof (extra->DataDirectory));
    643629
    644630  add_data_entry (abfd, extra, 0, ".edata", ib);
    645 
    646   /* Don't call add_data_entry for .idata$2 or .idata$5.  It's done in
    647      bfd_coff_final_link where all the required information is
    648      available.  */
    649 
    650   /* However, until other .idata fixes are made (pending patch), the
    651      entry for .idata is needed for backwards compatability.  FIXME.  */
    652   add_data_entry (abfd, extra, 1, ".idata", ib);
    653 
    654631  add_data_entry (abfd, extra, 2, ".rsrc", ib);
    655 
    656632  add_data_entry (abfd, extra, 3, ".pdata", ib);
    657633
     634  /* In theory we do not need to call add_data_entry for .idata$2 or
     635     .idata$5.  It will be done in bfd_coff_final_link where all the
     636     required information is available.  If however, we are not going
     637     to perform a final link, eg because we have been invoked by objcopy
     638     or strip, then we need to make sure that these Data Directory
     639     entries are initialised properly.
     640
     641     So - we copy the input values into the output values, and then, if
     642     a final link is going to be performed, it can overwrite them.  */
     643  extra->DataDirectory[1]  = idata2;
     644  extra->DataDirectory[12] = idata5;
     645
     646  if (extra->DataDirectory[1].VirtualAddress == 0)
     647    /* Until other .idata fixes are made (pending patch), the entry for
     648       .idata is needed for backwards compatability.  FIXME.  */
     649    add_data_entry (abfd, extra, 1, ".idata", ib);
     650   
    658651  /* For some reason, the virtual size (which is what's set by
    659652     add_data_entry) for .reloc is not the same as the size recorded
     
    692685
    693686  extra->SizeOfHeaders = abfd->sections->filepos;
    694   bfd_h_put_16 (abfd, aouthdr_in->magic, (bfd_byte *) aouthdr_out->standard.magic);
     687  H_PUT_16 (abfd, aouthdr_in->magic, aouthdr_out->standard.magic);
    695688
    696689#define LINKER_VERSION 256 /* That is, 2.56 */
     
    698691  /* This piece of magic sets the "linker version" field to
    699692     LINKER_VERSION.  */
    700   bfd_h_put_16 (abfd,
    701                 LINKER_VERSION / 100 + (LINKER_VERSION % 100) * 256,
    702                 (bfd_byte *) aouthdr_out->standard.vstamp);
    703 
    704   PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, (bfd_byte *) aouthdr_out->standard.tsize);
    705   PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, (bfd_byte *) aouthdr_out->standard.dsize);
    706   PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, (bfd_byte *) aouthdr_out->standard.bsize);
    707   PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, (bfd_byte *) aouthdr_out->standard.entry);
     693  H_PUT_16 (abfd, (LINKER_VERSION / 100 + (LINKER_VERSION % 100) * 256),
     694            aouthdr_out->standard.vstamp);
     695
     696  PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, aouthdr_out->standard.tsize);
     697  PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, aouthdr_out->standard.dsize);
     698  PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, aouthdr_out->standard.bsize);
     699  PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, aouthdr_out->standard.entry);
    708700  PUT_AOUTHDR_TEXT_START (abfd, aouthdr_in->text_start,
    709                           (bfd_byte *) aouthdr_out->standard.text_start);
     701                          aouthdr_out->standard.text_start);
    710702
    711703#ifndef COFF_WITH_pep
    712   /* PE32+ does not have data_start member! */
     704  /* PE32+ does not have data_start member!  */
    713705  PUT_AOUTHDR_DATA_START (abfd, aouthdr_in->data_start,
    714                           (bfd_byte *) aouthdr_out->standard.data_start);
    715 #endif
    716 
    717   PUT_OPTHDR_IMAGE_BASE (abfd, extra->ImageBase,
    718                          (bfd_byte *) aouthdr_out->ImageBase);
    719   bfd_h_put_32 (abfd, extra->SectionAlignment,
    720                 (bfd_byte *) aouthdr_out->SectionAlignment);
    721   bfd_h_put_32 (abfd, extra->FileAlignment,
    722                 (bfd_byte *) aouthdr_out->FileAlignment);
    723   bfd_h_put_16 (abfd, extra->MajorOperatingSystemVersion,
    724                 (bfd_byte *) aouthdr_out->MajorOperatingSystemVersion);
    725   bfd_h_put_16 (abfd, extra->MinorOperatingSystemVersion,
    726                 (bfd_byte *) aouthdr_out->MinorOperatingSystemVersion);
    727   bfd_h_put_16 (abfd, extra->MajorImageVersion,
    728                 (bfd_byte *) aouthdr_out->MajorImageVersion);
    729   bfd_h_put_16 (abfd, extra->MinorImageVersion,
    730                 (bfd_byte *) aouthdr_out->MinorImageVersion);
    731   bfd_h_put_16 (abfd, extra->MajorSubsystemVersion,
    732                 (bfd_byte *) aouthdr_out->MajorSubsystemVersion);
    733   bfd_h_put_16 (abfd, extra->MinorSubsystemVersion,
    734                 (bfd_byte *) aouthdr_out->MinorSubsystemVersion);
    735   bfd_h_put_32 (abfd, extra->Reserved1,
    736                 (bfd_byte *) aouthdr_out->Reserved1);
    737   bfd_h_put_32 (abfd, extra->SizeOfImage,
    738                 (bfd_byte *) aouthdr_out->SizeOfImage);
    739   bfd_h_put_32 (abfd, extra->SizeOfHeaders,
    740                 (bfd_byte *) aouthdr_out->SizeOfHeaders);
    741   bfd_h_put_32 (abfd, extra->CheckSum,
    742                 (bfd_byte *) aouthdr_out->CheckSum);
    743   bfd_h_put_16 (abfd, extra->Subsystem,
    744                 (bfd_byte *) aouthdr_out->Subsystem);
    745   bfd_h_put_16 (abfd, extra->DllCharacteristics,
    746                 (bfd_byte *) aouthdr_out->DllCharacteristics);
     706                          aouthdr_out->standard.data_start);
     707#endif
     708
     709  PUT_OPTHDR_IMAGE_BASE (abfd, extra->ImageBase, aouthdr_out->ImageBase);
     710  H_PUT_32 (abfd, extra->SectionAlignment, aouthdr_out->SectionAlignment);
     711  H_PUT_32 (abfd, extra->FileAlignment, aouthdr_out->FileAlignment);
     712  H_PUT_16 (abfd, extra->MajorOperatingSystemVersion,
     713            aouthdr_out->MajorOperatingSystemVersion);
     714  H_PUT_16 (abfd, extra->MinorOperatingSystemVersion,
     715            aouthdr_out->MinorOperatingSystemVersion);
     716  H_PUT_16 (abfd, extra->MajorImageVersion, aouthdr_out->MajorImageVersion);
     717  H_PUT_16 (abfd, extra->MinorImageVersion, aouthdr_out->MinorImageVersion);
     718  H_PUT_16 (abfd, extra->MajorSubsystemVersion,
     719            aouthdr_out->MajorSubsystemVersion);
     720  H_PUT_16 (abfd, extra->MinorSubsystemVersion,
     721            aouthdr_out->MinorSubsystemVersion);
     722  H_PUT_32 (abfd, extra->Reserved1, aouthdr_out->Reserved1);
     723  H_PUT_32 (abfd, extra->SizeOfImage, aouthdr_out->SizeOfImage);
     724  H_PUT_32 (abfd, extra->SizeOfHeaders, aouthdr_out->SizeOfHeaders);
     725  H_PUT_32 (abfd, extra->CheckSum, aouthdr_out->CheckSum);
     726  H_PUT_16 (abfd, extra->Subsystem, aouthdr_out->Subsystem);
     727  H_PUT_16 (abfd, extra->DllCharacteristics, aouthdr_out->DllCharacteristics);
    747728  PUT_OPTHDR_SIZE_OF_STACK_RESERVE (abfd, extra->SizeOfStackReserve,
    748                                     (bfd_byte *) aouthdr_out->SizeOfStackReserve);
     729                                    aouthdr_out->SizeOfStackReserve);
    749730  PUT_OPTHDR_SIZE_OF_STACK_COMMIT (abfd, extra->SizeOfStackCommit,
    750                                    (bfd_byte *) aouthdr_out->SizeOfStackCommit);
     731                                   aouthdr_out->SizeOfStackCommit);
    751732  PUT_OPTHDR_SIZE_OF_HEAP_RESERVE (abfd, extra->SizeOfHeapReserve,
    752                                    (bfd_byte *) aouthdr_out->SizeOfHeapReserve);
     733                                   aouthdr_out->SizeOfHeapReserve);
    753734  PUT_OPTHDR_SIZE_OF_HEAP_COMMIT (abfd, extra->SizeOfHeapCommit,
    754                                   (bfd_byte *) aouthdr_out->SizeOfHeapCommit);
    755   bfd_h_put_32 (abfd, extra->LoaderFlags,
    756                 (bfd_byte *) aouthdr_out->LoaderFlags);
    757   bfd_h_put_32 (abfd, extra->NumberOfRvaAndSizes,
    758                 (bfd_byte *) aouthdr_out->NumberOfRvaAndSizes);
     735                                  aouthdr_out->SizeOfHeapCommit);
     736  H_PUT_32 (abfd, extra->LoaderFlags, aouthdr_out->LoaderFlags);
     737  H_PUT_32 (abfd, extra->NumberOfRvaAndSizes,
     738            aouthdr_out->NumberOfRvaAndSizes);
    759739  {
    760740    int idx;
     741
    761742    for (idx = 0; idx < 16; idx++)
    762743      {
    763         bfd_h_put_32 (abfd, extra->DataDirectory[idx].VirtualAddress,
    764                       (bfd_byte *) aouthdr_out->DataDirectory[idx][0]);
    765         bfd_h_put_32 (abfd, extra->DataDirectory[idx].Size,
    766                       (bfd_byte *) aouthdr_out->DataDirectory[idx][1]);
     744        H_PUT_32 (abfd, extra->DataDirectory[idx].VirtualAddress,
     745                  aouthdr_out->DataDirectory[idx][0]);
     746        H_PUT_32 (abfd, extra->DataDirectory[idx].Size,
     747                  aouthdr_out->DataDirectory[idx][1]);
    767748      }
    768749  }
     
    833814  filehdr_in->pe.nt_signature = NT_SIGNATURE;
    834815
    835   bfd_h_put_16 (abfd, filehdr_in->f_magic, (bfd_byte *) filehdr_out->f_magic);
    836   bfd_h_put_16 (abfd, filehdr_in->f_nscns, (bfd_byte *) filehdr_out->f_nscns);
    837 
    838   bfd_h_put_32 (abfd, time (0), (bfd_byte *) filehdr_out->f_timdat);
    839   PUT_FILEHDR_SYMPTR (abfd, (bfd_vma) filehdr_in->f_symptr,
    840                       (bfd_byte *) filehdr_out->f_symptr);
    841   bfd_h_put_32 (abfd, filehdr_in->f_nsyms, (bfd_byte *) filehdr_out->f_nsyms);
    842   bfd_h_put_16 (abfd, filehdr_in->f_opthdr, (bfd_byte *) filehdr_out->f_opthdr);
    843   bfd_h_put_16 (abfd, filehdr_in->f_flags, (bfd_byte *) filehdr_out->f_flags);
    844 
    845   /* put in extra dos header stuff.  This data remains essentially
     816  H_PUT_16 (abfd, filehdr_in->f_magic, filehdr_out->f_magic);
     817  H_PUT_16 (abfd, filehdr_in->f_nscns, filehdr_out->f_nscns);
     818
     819  H_PUT_32 (abfd, time (0), filehdr_out->f_timdat);
     820  PUT_FILEHDR_SYMPTR (abfd, filehdr_in->f_symptr,
     821                      filehdr_out->f_symptr);
     822  H_PUT_32 (abfd, filehdr_in->f_nsyms, filehdr_out->f_nsyms);
     823  H_PUT_16 (abfd, filehdr_in->f_opthdr, filehdr_out->f_opthdr);
     824  H_PUT_16 (abfd, filehdr_in->f_flags, filehdr_out->f_flags);
     825
     826  /* Put in extra dos header stuff.  This data remains essentially
    846827     constant, it just has to be tacked on to the beginning of all exes
    847      for NT */
    848   bfd_h_put_16 (abfd, filehdr_in->pe.e_magic, (bfd_byte *) filehdr_out->e_magic);
    849   bfd_h_put_16 (abfd, filehdr_in->pe.e_cblp, (bfd_byte *) filehdr_out->e_cblp);
    850   bfd_h_put_16 (abfd, filehdr_in->pe.e_cp, (bfd_byte *) filehdr_out->e_cp);
    851   bfd_h_put_16 (abfd, filehdr_in->pe.e_crlc, (bfd_byte *) filehdr_out->e_crlc);
    852   bfd_h_put_16 (abfd, filehdr_in->pe.e_cparhdr,
    853                (bfd_byte *) filehdr_out->e_cparhdr);
    854   bfd_h_put_16 (abfd, filehdr_in->pe.e_minalloc,
    855                (bfd_byte *) filehdr_out->e_minalloc);
    856   bfd_h_put_16 (abfd, filehdr_in->pe.e_maxalloc,
    857                (bfd_byte *) filehdr_out->e_maxalloc);
    858   bfd_h_put_16 (abfd, filehdr_in->pe.e_ss, (bfd_byte *) filehdr_out->e_ss);
    859   bfd_h_put_16 (abfd, filehdr_in->pe.e_sp, (bfd_byte *) filehdr_out->e_sp);
    860   bfd_h_put_16 (abfd, filehdr_in->pe.e_csum, (bfd_byte *) filehdr_out->e_csum);
    861   bfd_h_put_16 (abfd, filehdr_in->pe.e_ip, (bfd_byte *) filehdr_out->e_ip);
    862   bfd_h_put_16 (abfd, filehdr_in->pe.e_cs, (bfd_byte *) filehdr_out->e_cs);
    863   bfd_h_put_16 (abfd, filehdr_in->pe.e_lfarlc, (bfd_byte *) filehdr_out->e_lfarlc);
    864   bfd_h_put_16 (abfd, filehdr_in->pe.e_ovno, (bfd_byte *) filehdr_out->e_ovno);
    865   {
    866     int idx;
    867     for (idx = 0; idx < 4; idx++)
    868       bfd_h_put_16 (abfd, filehdr_in->pe.e_res[idx],
    869                     (bfd_byte *) filehdr_out->e_res[idx]);
    870   }
    871   bfd_h_put_16 (abfd, filehdr_in->pe.e_oemid, (bfd_byte *) filehdr_out->e_oemid);
    872   bfd_h_put_16 (abfd, filehdr_in->pe.e_oeminfo,
    873                 (bfd_byte *) filehdr_out->e_oeminfo);
    874   {
    875     int idx;
    876     for (idx = 0; idx < 10; idx++)
    877       bfd_h_put_16 (abfd, filehdr_in->pe.e_res2[idx],
    878                     (bfd_byte *) filehdr_out->e_res2[idx]);
    879   }
    880   bfd_h_put_32 (abfd, filehdr_in->pe.e_lfanew, (bfd_byte *) filehdr_out->e_lfanew);
    881 
    882   {
    883     int idx;
    884     for (idx = 0; idx < 16; idx++)
    885       bfd_h_put_32 (abfd, filehdr_in->pe.dos_message[idx],
    886                     (bfd_byte *) filehdr_out->dos_message[idx]);
    887   }
     828     for NT.  */
     829  H_PUT_16 (abfd, filehdr_in->pe.e_magic, filehdr_out->e_magic);
     830  H_PUT_16 (abfd, filehdr_in->pe.e_cblp, filehdr_out->e_cblp);
     831  H_PUT_16 (abfd, filehdr_in->pe.e_cp, filehdr_out->e_cp);
     832  H_PUT_16 (abfd, filehdr_in->pe.e_crlc, filehdr_out->e_crlc);
     833  H_PUT_16 (abfd, filehdr_in->pe.e_cparhdr, filehdr_out->e_cparhdr);
     834  H_PUT_16 (abfd, filehdr_in->pe.e_minalloc, filehdr_out->e_minalloc);
     835  H_PUT_16 (abfd, filehdr_in->pe.e_maxalloc, filehdr_out->e_maxalloc);
     836  H_PUT_16 (abfd, filehdr_in->pe.e_ss, filehdr_out->e_ss);
     837  H_PUT_16 (abfd, filehdr_in->pe.e_sp, filehdr_out->e_sp);
     838  H_PUT_16 (abfd, filehdr_in->pe.e_csum, filehdr_out->e_csum);
     839  H_PUT_16 (abfd, filehdr_in->pe.e_ip, filehdr_out->e_ip);
     840  H_PUT_16 (abfd, filehdr_in->pe.e_cs, filehdr_out->e_cs);
     841  H_PUT_16 (abfd, filehdr_in->pe.e_lfarlc, filehdr_out->e_lfarlc);
     842  H_PUT_16 (abfd, filehdr_in->pe.e_ovno, filehdr_out->e_ovno);
     843
     844  for (idx = 0; idx < 4; idx++)
     845    H_PUT_16 (abfd, filehdr_in->pe.e_res[idx], filehdr_out->e_res[idx]);
     846
     847  H_PUT_16 (abfd, filehdr_in->pe.e_oemid, filehdr_out->e_oemid);
     848  H_PUT_16 (abfd, filehdr_in->pe.e_oeminfo, filehdr_out->e_oeminfo);
     849
     850  for (idx = 0; idx < 10; idx++)
     851    H_PUT_16 (abfd, filehdr_in->pe.e_res2[idx], filehdr_out->e_res2[idx]);
     852
     853  H_PUT_32 (abfd, filehdr_in->pe.e_lfanew, filehdr_out->e_lfanew);
     854
     855  for (idx = 0; idx < 16; idx++)
     856    H_PUT_32 (abfd, filehdr_in->pe.dos_message[idx],
     857              filehdr_out->dos_message[idx]);
    888858
    889859  /* Also put in the NT signature.  */
    890   bfd_h_put_32 (abfd, filehdr_in->pe.nt_signature,
    891                 (bfd_byte *) filehdr_out->nt_signature);
     860  H_PUT_32 (abfd, filehdr_in->pe.nt_signature, filehdr_out->nt_signature);
    892861
    893862  return FILHSZ;
     
    903872  FILHDR *filehdr_out = (FILHDR *) out;
    904873
    905   bfd_h_put_16 (abfd, filehdr_in->f_magic, (bfd_byte *) filehdr_out->f_magic);
    906   bfd_h_put_16 (abfd, filehdr_in->f_nscns, (bfd_byte *) filehdr_out->f_nscns);
    907   bfd_h_put_32 (abfd, filehdr_in->f_timdat, (bfd_byte *) filehdr_out->f_timdat);
    908   PUT_FILEHDR_SYMPTR (abfd, (bfd_vma) filehdr_in->f_symptr,
    909                       (bfd_byte *) filehdr_out->f_symptr);
    910   bfd_h_put_32 (abfd, filehdr_in->f_nsyms, (bfd_byte *) filehdr_out->f_nsyms);
    911   bfd_h_put_16 (abfd, filehdr_in->f_opthdr, (bfd_byte *) filehdr_out->f_opthdr);
    912   bfd_h_put_16 (abfd, filehdr_in->f_flags, (bfd_byte *) filehdr_out->f_flags);
     874  H_PUT_16 (abfd, filehdr_in->f_magic, filehdr_out->f_magic);
     875  H_PUT_16 (abfd, filehdr_in->f_nscns, filehdr_out->f_nscns);
     876  H_PUT_32 (abfd, filehdr_in->f_timdat, filehdr_out->f_timdat);
     877  PUT_FILEHDR_SYMPTR (abfd, filehdr_in->f_symptr, filehdr_out->f_symptr);
     878  H_PUT_32 (abfd, filehdr_in->f_nsyms, filehdr_out->f_nsyms);
     879  H_PUT_16 (abfd, filehdr_in->f_opthdr, filehdr_out->f_opthdr);
     880  H_PUT_16 (abfd, filehdr_in->f_flags, filehdr_out->f_flags);
    913881
    914882  return FILHSZ;
     
    933901                      - pe_data (abfd)->pe_opthdr.ImageBase)
    934902                     & 0xffffffff),
    935                     (bfd_byte *) scnhdr_ext->s_vaddr);
     903                    scnhdr_ext->s_vaddr);
    936904
    937905  /* NT wants the size data to be rounded up to the next
    938906     NT_FILE_ALIGNMENT, but zero if it has no content (as in .bss,
    939907     sometimes).  */
    940 
    941908  if ((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0)
    942909    {
    943       ps = scnhdr_int->s_size;
    944       ss = 0;
     910      if (bfd_pe_executable_p (abfd))
     911        {
     912          ps = scnhdr_int->s_size;
     913          ss = 0;
     914        }
     915      else
     916       {
     917         ps = 0;
     918         ss = scnhdr_int->s_size;
     919       }
    945920    }
    946921  else
    947922    {
    948       ps = scnhdr_int->s_paddr;
     923      if (bfd_pe_executable_p (abfd))
     924        ps = scnhdr_int->s_paddr;
     925      else
     926        ps = 0;
     927
    949928      ss = scnhdr_int->s_size;
    950929    }
    951930
    952931  PUT_SCNHDR_SIZE (abfd, ss,
    953                    (bfd_byte *) scnhdr_ext->s_size);
     932                   scnhdr_ext->s_size);
    954933
    955934  /* s_paddr in PE is really the virtual size.  */
    956   PUT_SCNHDR_PADDR (abfd, ps, (bfd_byte *) scnhdr_ext->s_paddr);
     935  PUT_SCNHDR_PADDR (abfd, ps, scnhdr_ext->s_paddr);
    957936
    958937  PUT_SCNHDR_SCNPTR (abfd, scnhdr_int->s_scnptr,
    959                      (bfd_byte *) scnhdr_ext->s_scnptr);
     938                     scnhdr_ext->s_scnptr);
    960939  PUT_SCNHDR_RELPTR (abfd, scnhdr_int->s_relptr,
    961                      (bfd_byte *) scnhdr_ext->s_relptr);
     940                     scnhdr_ext->s_relptr);
    962941  PUT_SCNHDR_LNNOPTR (abfd, scnhdr_int->s_lnnoptr,
    963                       (bfd_byte *) scnhdr_ext->s_lnnoptr);
     942                      scnhdr_ext->s_lnnoptr);
    964943
    965944  /* Extra flags must be set when dealing with NT.  All sections should also
     
    979958  {
    980959    int flags = scnhdr_int->s_flags;
    981     bfd_h_put_32 (abfd, flags, (bfd_byte *) scnhdr_ext->s_flags);
     960
     961    H_PUT_32 (abfd, flags, scnhdr_ext->s_flags);
    982962  }
    983963
     
    995975         Overflow is not an issue: a 4G-line program will overflow a
    996976         bunch of other fields long before this!  */
    997       bfd_h_put_16 (abfd, scnhdr_int->s_nlnno & 0xffff,
    998                     (bfd_byte *) scnhdr_ext->s_nlnno);
    999       bfd_h_put_16 (abfd, scnhdr_int->s_nlnno >> 16,
    1000                     (bfd_byte *) scnhdr_ext->s_nreloc);
     977      H_PUT_16 (abfd, (scnhdr_int->s_nlnno & 0xffff), scnhdr_ext->s_nlnno);
     978      H_PUT_16 (abfd, (scnhdr_int->s_nlnno >> 16), scnhdr_ext->s_nreloc);
    1001979    }
    1002980  else
    1003981    {
    1004982      if (scnhdr_int->s_nlnno <= 0xffff)
    1005         bfd_h_put_16 (abfd, scnhdr_int->s_nlnno,
    1006                       (bfd_byte *) scnhdr_ext->s_nlnno);
     983        H_PUT_16 (abfd, scnhdr_int->s_nlnno, scnhdr_ext->s_nlnno);
    1007984      else
    1008985        {
     
    1011988                                 scnhdr_int->s_nlnno);
    1012989          bfd_set_error (bfd_error_file_truncated);
    1013           bfd_h_put_16 (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nlnno);
     990          H_PUT_16 (abfd, 0xffff, scnhdr_ext->s_nlnno);
    1014991          ret = 0;
    1015992        }
     993
    1016994      if (scnhdr_int->s_nreloc <= 0xffff)
    1017         bfd_h_put_16 (abfd, scnhdr_int->s_nreloc,
    1018                       (bfd_byte *) scnhdr_ext->s_nreloc);
     995        H_PUT_16 (abfd, scnhdr_int->s_nreloc, scnhdr_ext->s_nreloc);
    1019996      else
    1020997        {
    1021           /* PE can deal with large #s of relocs, but not here */
    1022           bfd_h_put_16 (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nreloc);
     998          /* PE can deal with large #s of relocs, but not here. */
     999          H_PUT_16 (abfd, 0xffff, scnhdr_ext->s_nreloc);
    10231000          scnhdr_int->s_flags |= IMAGE_SCN_LNK_NRELOC_OVFL;
    1024           bfd_h_put_32 (abfd, scnhdr_int->s_flags,
    1025                         (bfd_byte *) scnhdr_ext->s_flags);
     1001          H_PUT_32 (abfd, scnhdr_int->s_flags, scnhdr_ext->s_flags);
    10261002#if 0
    10271003          (*_bfd_error_handler) (_("%s: reloc overflow 1: 0x%lx > 0xffff"),
     
    10291005                                 scnhdr_int->s_nreloc);
    10301006          bfd_set_error (bfd_error_file_truncated);
    1031           bfd_h_put_16 (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nreloc);
     1007          H_PUT_16 (abfd, 0xffff, scnhdr_ext->s_nreloc);
    10321008          ret = 0;
    10331009#endif
     
    10371013}
    10381014
    1039 static char * dir_names[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] = {
    1040   N_("Export Directory [.edata (or where ever we found it)]"),
    1041   N_("Import Directory [parts of .idata]"),
    1042   N_("Resource Directory [.rsrc]"),
    1043   N_("Exception Directory [.pdata]"),
    1044   N_("Security Directory"),
    1045   N_("Base Relocation Directory [.reloc]"),
    1046   N_("Debug Directory"),
    1047   N_("Description Directory"),
    1048   N_("Special Directory"),
    1049   N_("Thread Storage Directory [.tls]"),
    1050   N_("Load Configuration Directory"),
    1051   N_("Bound Import Directory"),
    1052   N_("Import Address Table Directory"),
    1053   N_("Delay Import Directory"),
    1054   N_("Reserved"),
    1055   N_("Reserved")
    1056 };
    1057 
    1058 /**********************************************************************/
     1015static char * dir_names[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] =
     1016  {
     1017    N_("Export Directory [.edata (or where ever we found it)]"),
     1018    N_("Import Directory [parts of .idata]"),
     1019    N_("Resource Directory [.rsrc]"),
     1020    N_("Exception Directory [.pdata]"),
     1021    N_("Security Directory"),
     1022    N_("Base Relocation Directory [.reloc]"),
     1023    N_("Debug Directory"),
     1024    N_("Description Directory"),
     1025    N_("Special Directory"),
     1026    N_("Thread Storage Directory [.tls]"),
     1027    N_("Load Configuration Directory"),
     1028    N_("Bound Import Directory"),
     1029    N_("Import Address Table Directory"),
     1030    N_("Delay Import Directory"),
     1031    N_("Reserved"),
     1032    N_("Reserved")
     1033  };
     1034
    10591035#ifdef POWERPC_LE_PE
    10601036/* The code for the PPC really falls in the "architecture dependent"
     
    10651041#endif
    10661042
    1067 /**********************************************************************/
    1068 static boolean
     1043static bfd_boolean
    10691044pe_print_idata (abfd, vfile)
    10701045     bfd *abfd;
     
    10831058  bfd_size_type dataoff;
    10841059  bfd_size_type i;
     1060  bfd_size_type amt;
    10851061  int onaline = 20;
    10861062
     
    10971073      section = bfd_get_section_by_name (abfd, ".idata");
    10981074      if (section == NULL)
    1099         return true;
     1075        return TRUE;
    11001076
    11011077      addr = section->vma;
    11021078      datasize = bfd_section_size (abfd, section);
    11031079      if (datasize == 0)
    1104         return true;
     1080        return TRUE;
    11051081    }
    11061082  else
     
    11181094          fprintf (file,
    11191095                   _("\nThere is an import table, but the section containing it could not be found\n"));
    1120           return true;
     1096          return TRUE;
    11211097        }
    11221098    }
     
    11441120      int offset;
    11451121
    1146       data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd,
    1147                                                                  rel_section));
    1148       if (data == NULL && bfd_section_size (abfd, rel_section) != 0)
    1149         return false;
    1150 
    1151       bfd_get_section_contents (abfd,
    1152                                 rel_section,
    1153                                 (PTR) data, 0,
    1154                                 bfd_section_size (abfd, rel_section));
     1122      amt = bfd_section_size (abfd, rel_section);
     1123      data = (bfd_byte *) bfd_malloc (amt);
     1124      if (data == NULL && amt != 0)
     1125        return FALSE;
     1126
     1127      bfd_get_section_contents (abfd, rel_section, (PTR) data, (bfd_vma) 0,
     1128                                amt);
    11551129
    11561130      offset = abfd->start_address - rel_section->vma;
     
    11781152           section->name);
    11791153  fprintf (file,
    1180            _(" vma:            Hint    Time      Forward  DLL       First\n"));
    1181   fprintf (file,
    1182            _("                 Table   Stamp     Chain    Name      Thunk\n"));
    1183 
    1184   data = (bfd_byte *) bfd_malloc (dataoff + datasize);
     1154           _("\
     1155 vma:            Hint    Time      Forward  DLL       First\n\
     1156                 Table   Stamp     Chain    Name      Thunk\n"));
     1157
     1158  amt = dataoff + datasize;
     1159  data = (bfd_byte *) bfd_malloc (amt);
    11851160  if (data == NULL)
    1186     return false;
     1161    return FALSE;
    11871162
    11881163  /* Read the whole section.  Some of the fields might be before dataoff.  */
    1189   if (! bfd_get_section_contents (abfd, section, (PTR) data,
    1190                                   0, dataoff + datasize))
    1191     return false;
     1164  if (! bfd_get_section_contents (abfd, section, (PTR) data, (bfd_vma) 0, amt))
     1165    return FALSE;
    11921166
    11931167  adj = section->vma - extra->ImageBase;
    11941168
     1169  /* Print all image import descriptors.  */
    11951170  for (i = 0; i < datasize; i += onaline)
    11961171    {
     
    12041179      char *dll;
    12051180
    1206       /* print (i + extra->DataDirectory[1].VirtualAddress)  */
     1181      /* Print (i + extra->DataDirectory[1].VirtualAddress).  */
    12071182      fprintf (file, " %08lx\t", (unsigned long) (i + adj + dataoff));
    1208 
     1183#if 0
    12091184      if (i + 20 > datasize)
    1210         {
    1211           /* Check stuff.  */
    1212           ;
    1213         }
    1214 
     1185        /* Check stuff.  */
     1186        ;
     1187#endif
    12151188      hint_addr = bfd_get_32 (abfd, data + i + dataoff);
    12161189      time_stamp = bfd_get_32 (abfd, data + i + 4 + dataoff);
     
    12341207      if (hint_addr != 0)
    12351208        {
    1236           fprintf (file, _("\tvma:  Hint/Ord Member-Name\n"));
     1209          bfd_byte *ft_data;
     1210          asection *ft_section;
     1211          bfd_vma ft_addr;
     1212          bfd_size_type ft_datasize;
     1213          int ft_idx;
     1214          int ft_allocated = 0;
     1215
     1216          fprintf (file, _("\tvma:  Hint/Ord Member-Name Bound-To\n"));
    12371217
    12381218          idx = hint_addr - adj;
    1239 
     1219         
     1220          ft_addr = first_thunk + extra->ImageBase;
     1221          ft_data = data;
     1222          ft_idx = first_thunk - adj;
     1223          ft_allocated = 0;
     1224     
     1225          if (first_thunk != hint_addr)
     1226            {
     1227              /* Find the section which contains the first thunk.  */
     1228              for (ft_section = abfd->sections;
     1229                   ft_section != NULL;
     1230                   ft_section = ft_section->next)
     1231                {
     1232                  ft_datasize = bfd_section_size (abfd, ft_section);
     1233                  if (ft_addr >= ft_section->vma
     1234                      && ft_addr < ft_section->vma + ft_datasize)
     1235                    break;
     1236                }
     1237
     1238              if (ft_section == NULL)
     1239                {
     1240                  fprintf (file,
     1241                       _("\nThere is a first thunk, but the section containing it could not be found\n"));
     1242                  continue;
     1243                }
     1244
     1245              /* Now check to see if this section is the same as our current
     1246                 section.  If it is not then we will have to load its data in.  */
     1247              if (ft_section == section)
     1248                {
     1249                  ft_data = data;
     1250                  ft_idx = first_thunk - adj;
     1251                }
     1252              else
     1253                {
     1254                  ft_idx = first_thunk - (ft_section->vma - extra->ImageBase);
     1255                  ft_data = (bfd_byte *) bfd_malloc (datasize);
     1256                  if (ft_data == NULL)
     1257                    continue;
     1258
     1259                  /* Read datasize bfd_bytes starting at offset ft_idx.  */
     1260                  if (! bfd_get_section_contents (abfd, ft_section,
     1261                                                  (PTR) ft_data,
     1262                                                  (bfd_vma) ft_idx,
     1263                                                  datasize))
     1264                    {
     1265                      free (ft_data);
     1266                      continue;
     1267                    }
     1268
     1269                  ft_idx = 0;
     1270                  ft_allocated = 1;
     1271                }
     1272            }
     1273
     1274          /* Print HintName vector entries.  */
    12401275          for (j = 0; j < datasize; j += 4)
    12411276            {
    12421277              unsigned long member = bfd_get_32 (abfd, data + idx + j);
    12431278
     1279              /* Print single IMAGE_IMPORT_BY_NAME vector.  */
    12441280              if (member == 0)
    12451281                break;
     1282
    12461283              if (member & 0x80000000)
    1247                 fprintf (file, "\t%04lx\t %4lu", member,
    1248                          member & 0x7fffffff);
     1284                fprintf (file, "\t%04lx\t %4lu  <none>",
     1285                         member, member & 0x7fffffff);
    12491286              else
    12501287                {
     
    12591296
    12601297              /* If the time stamp is not zero, the import address
    1261                 table holds actual addresses.  */
     1298                table holds actual addresses.  */
    12621299              if (time_stamp != 0
    12631300                  && first_thunk != 0
    12641301                  && first_thunk != hint_addr)
    12651302                fprintf (file, "\t%04lx",
    1266                          (long) bfd_get_32 (abfd, data + first_thunk - adj + j));
     1303                         (long) bfd_get_32 (abfd, ft_data + ft_idx + j));
    12671304
    12681305              fprintf (file, "\n");
    12691306            }
     1307
     1308          if (ft_allocated)
     1309            free (ft_data);
    12701310        }
    12711311
    1272       if (hint_addr != first_thunk && time_stamp == 0)
    1273         {
    1274           int differ = 0;
    1275           int idx2;
    1276 
    1277           idx2 = first_thunk - adj;
    1278 
    1279           for (j = 0; j < datasize; j += 4)
    1280             {
    1281               int ordinal;
    1282               char *member_name;
    1283               bfd_vma hint_member = 0;
    1284               bfd_vma iat_member;
    1285 
    1286               if (hint_addr != 0)
    1287                 hint_member = bfd_get_32 (abfd, data + idx + j);
    1288               iat_member = bfd_get_32 (abfd, data + idx2 + j);
    1289 
    1290               if (hint_addr == 0 && iat_member == 0)
    1291                 break;
    1292 
    1293               if (hint_addr == 0 || hint_member != iat_member)
    1294                 {
    1295                   if (differ == 0)
    1296                     {
    1297                       fprintf (file,
    1298                                _("\tThe Import Address Table (difference found)\n"));
    1299                       fprintf (file, _("\tvma:  Hint/Ord Member-Name\n"));
    1300                       differ = 1;
    1301                     }
    1302                   if (iat_member == 0)
    1303                     {
    1304                       fprintf (file,
    1305                               _("\t>>> Ran out of IAT members!\n"));
    1306                     }
    1307                   else
    1308                     {
    1309                       ordinal = bfd_get_16 (abfd, data + iat_member - adj);
    1310                       member_name = (char *) data + iat_member - adj + 2;
    1311                       fprintf (file, "\t%04lx\t %4d  %s\n",
    1312                               (unsigned long) iat_member,
    1313                               ordinal,
    1314                               member_name);
    1315                     }
    1316                 }
    1317 
    1318               if (hint_addr != 0 && hint_member == 0)
    1319                 break;
    1320             }
    1321           if (differ == 0)
    1322             {
    1323               fprintf (file,
    1324                       _("\tThe Import Address Table is identical\n"));
    1325             }
    1326         }
    1327 
    13281312      fprintf (file, "\n");
    1329 
    13301313    }
    13311314
    13321315  free (data);
    13331316
    1334   return true;
     1317  return TRUE;
    13351318}
    13361319
    1337 static boolean
     1320static bfd_boolean
    13381321pe_print_edata (abfd, vfile)
    13391322     bfd *abfd;
     
    13431326  bfd_byte *data;
    13441327  asection *section;
    1345 
    13461328  bfd_size_type datasize = 0;
    13471329  bfd_size_type dataoff;
    13481330  bfd_size_type i;
    1349 
    13501331  bfd_signed_vma adj;
    1351   struct EDT_type {
    1352     long export_flags;             /* reserved - should be zero */
     1332  struct EDT_type
     1333  {
     1334    long export_flags;          /* reserved - should be zero */
    13531335    long time_stamp;
    13541336    short major_ver;
    13551337    short minor_ver;
    1356     bfd_vma name;                  /* rva - relative to image base */
    1357     long base;                     /* ordinal base */
    1358     unsigned long num_functions;   /* Number in the export address table */
    1359     unsigned long num_names;       /* Number in the name pointer table */
    1360     bfd_vma eat_addr;    /* rva to the export address table */
    1361     bfd_vma npt_addr;        /* rva to the Export Name Pointer Table */
    1362     bfd_vma ot_addr; /* rva to the Ordinal Table */
     1338    bfd_vma name;               /* rva - relative to image base */
     1339    long base;                  /* ordinal base */
     1340    unsigned long num_functions;/* Number in the export address table */
     1341    unsigned long num_names;    /* Number in the name pointer table */
     1342    bfd_vma eat_addr;           /* rva to the export address table */
     1343    bfd_vma npt_addr;           /* rva to the Export Name Pointer Table */
     1344    bfd_vma ot_addr;            /* rva to the Ordinal Table */
    13631345  } edt;
    13641346
     
    13751357      section = bfd_get_section_by_name (abfd, ".edata");
    13761358      if (section == NULL)
    1377         return true;
     1359        return TRUE;
    13781360
    13791361      addr = section->vma;
    13801362      datasize = bfd_section_size (abfd, section);
    13811363      if (datasize == 0)
    1382         return true;
     1364        return TRUE;
    13831365    }
    13841366  else
    13851367    {
    13861368      addr += extra->ImageBase;
     1369
    13871370      for (section = abfd->sections; section != NULL; section = section->next)
    13881371        {
    13891372          datasize = bfd_section_size (abfd, section);
     1373
    13901374          if (addr >= section->vma && addr < section->vma + datasize)
    13911375            break;
     
    13961380          fprintf (file,
    13971381                   _("\nThere is an export table, but the section containing it could not be found\n"));
    1398           return true;
     1382          return TRUE;
    13991383        }
    14001384    }
     
    14081392  data = (bfd_byte *) bfd_malloc (datasize);
    14091393  if (data == NULL)
    1410     return false;
    1411 
    1412   if (! bfd_get_section_contents (abfd, section, (PTR) data, dataoff,
    1413                                   datasize))
    1414     return false;
     1394    return FALSE;
     1395
     1396  if (! bfd_get_section_contents (abfd, section, (PTR) data,
     1397                                  (file_ptr) dataoff, datasize))
     1398    return FALSE;
    14151399
    14161400  /* Go get Export Directory Table.  */
     
    14291413  adj = section->vma - extra->ImageBase + dataoff;
    14301414
    1431   /* Dump the EDT first first */
     1415  /* Dump the EDT first. */
    14321416  fprintf (file,
    14331417           _("\nThe Export Tables (interpreted %s section contents)\n\n"),
     
    14831467     a list of pointers that either locate a function in this dll, or
    14841468     forward the call to another dll. Something like:
    1485       typedef union {
     1469      typedef union
     1470      {
    14861471        long export_rva;
    14871472        long forwarder_rva;
     
    15481533  free (data);
    15491534
    1550   return true;
     1535  return TRUE;
    15511536}
    15521537
     
    15561541   covers and the address of the corresponding unwind info data.  */
    15571542
    1558 static boolean
     1543static bfd_boolean
    15591544pe_print_pdata (abfd, vfile)
    15601545     bfd *abfd;
     
    15771562      || coff_section_data (abfd, section) == NULL
    15781563      || pei_section_data (abfd, section) == NULL)
    1579     return true;
     1564    return TRUE;
    15801565
    15811566  stop = pei_section_data (abfd, section)->virt_size;
     
    15911576           _(" vma:\t\t\tBegin Address    End Address      Unwind Info\n"));
    15921577#else
    1593   fprintf (file,
    1594            _(" vma:\t\tBegin    End      EH       EH       PrologEnd  Exception\n"));
    1595   fprintf (file,
    1596            _("     \t\tAddress  Address  Handler  Data     Address    Mask\n"));
    1597 #endif
    1598 
    1599   if (bfd_section_size (abfd, section) == 0)
    1600     return true;
    1601 
    1602   data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd, section));
     1578  fprintf (file, _("\
     1579 vma:\t\tBegin    End      EH       EH       PrologEnd  Exception\n\
     1580     \t\tAddress  Address  Handler  Data     Address    Mask\n"));
     1581#endif
     1582
    16031583  datasize = bfd_section_size (abfd, section);
     1584  if (datasize == 0)
     1585    return TRUE;
     1586
     1587  data = (bfd_byte *) bfd_malloc (datasize);
    16041588  if (data == NULL && datasize != 0)
    1605     return false;
    1606 
    1607   bfd_get_section_contents (abfd,
    1608                             section,
    1609                             (PTR) data, 0,
    1610                             bfd_section_size (abfd, section));
     1589    return FALSE;
     1590
     1591  bfd_get_section_contents (abfd, section, (PTR) data, (bfd_vma) 0,
     1592                            datasize);
    16111593
    16121594  start = 0;
     
    16321614      if (begin_addr == 0 && end_addr == 0 && eh_handler == 0
    16331615          && eh_data == 0 && prolog_end_addr == 0)
    1634         {
    1635           /* We are probably into the padding of the section now.  */
    1636           break;
    1637         }
     1616        /* We are probably into the padding of the section now.  */
     1617        break;
    16381618
    16391619      em_data = ((eh_handler & 0x1) << 2) | (prolog_end_addr & 0x3);
     
    16841664  free (data);
    16851665
    1686   return true;
     1666  return TRUE;
    16871667}
    16881668
    16891669#define IMAGE_REL_BASED_HIGHADJ 4
    1690 static const char * const tbl[] = {
    1691   "ABSOLUTE",
    1692   "HIGH",
    1693   "LOW",
    1694   "HIGHLOW",
    1695   "HIGHADJ",
    1696   "MIPS_JMPADDR",
    1697   "SECTION",
    1698   "REL32",
    1699   "RESERVED1",
    1700   "MIPS_JMPADDR16",
    1701   "DIR64",
    1702   "HIGH3ADJ"
    1703   "UNKNOWN",   /* MUST be last */
    1704 };
    1705 
    1706 static boolean
     1670static const char * const tbl[] =
     1671  {
     1672    "ABSOLUTE",
     1673    "HIGH",
     1674    "LOW",
     1675    "HIGHLOW",
     1676    "HIGHADJ",
     1677    "MIPS_JMPADDR",
     1678    "SECTION",
     1679    "REL32",
     1680    "RESERVED1",
     1681    "MIPS_JMPADDR16",
     1682    "DIR64",
     1683    "HIGH3ADJ"
     1684    "UNKNOWN",   /* MUST be last */
     1685  };
     1686
     1687static bfd_boolean
    17071688pe_print_reloc (abfd, vfile)
    17081689     bfd *abfd;
     
    17121693  bfd_byte *data = 0;
    17131694  asection *section = bfd_get_section_by_name (abfd, ".reloc");
    1714   bfd_size_type datasize = 0;
     1695  bfd_size_type datasize;
    17151696  bfd_size_type i;
    17161697  bfd_size_type start, stop;
    17171698
    17181699  if (section == NULL)
    1719     return true;
     1700    return TRUE;
    17201701
    17211702  if (bfd_section_size (abfd, section) == 0)
    1722     return true;
     1703    return TRUE;
    17231704
    17241705  fprintf (file,
    17251706           _("\n\nPE File Base Relocations (interpreted .reloc section contents)\n"));
    17261707
    1727   data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd, section));
    17281708  datasize = bfd_section_size (abfd, section);
     1709  data = (bfd_byte *) bfd_malloc (datasize);
    17291710  if (data == NULL && datasize != 0)
    1730     return false;
    1731 
    1732   bfd_get_section_contents (abfd,
    1733                             section,
    1734                             (PTR) data, 0,
    1735                             bfd_section_size (abfd, section));
     1711    return FALSE;
     1712
     1713  bfd_get_section_contents (abfd, section, (PTR) data, (bfd_vma) 0,
     1714                            datasize);
    17361715
    17371716  start = 0;
     
    17461725
    17471726      /* The .reloc section is a sequence of blocks, with a header consisting
    1748          of two 32 bit quantities, followed by a number of 16 bit entries */
    1749 
     1727         of two 32 bit quantities, followed by a number of 16 bit entries.  */
    17501728      virtual_address = bfd_get_32 (abfd, data+i);
    17511729      size = bfd_get_32 (abfd, data+i+4);
     
    17531731
    17541732      if (size == 0)
    1755         {
    1756           break;
    1757         }
     1733        break;
    17581734
    17591735      fprintf (file,
     
    17861762          fprintf (file, "\n");
    17871763        }
     1764
    17881765      i += size;
    17891766    }
     
    17911768  free (data);
    17921769
    1793   return true;
     1770  return TRUE;
    17941771}
    17951772
    17961773/* Print out the program headers.  */
    17971774
    1798 boolean
     1775bfd_boolean
    17991776_bfd_XX_print_private_bfd_data_common (abfd, vfile)
    18001777     bfd *abfd;
     
    18261803
    18271804  /* ctime implies '\n'.  */
    1828   fprintf (file, "\nTime/Date\t\t%s", ctime (&pe->coff.timestamp));
     1805  {
     1806    time_t t = pe->coff.timestamp;
     1807    fprintf (file, "\nTime/Date\t\t%s", ctime (&t));
     1808  }
    18291809  fprintf (file, "\nImageBase\t\t");
    18301810  fprintf_vma (file, i->ImageBase);
     
    18431823  fprintf (file, "SizeOfHeaders\t\t%08lx\n", i->SizeOfHeaders);
    18441824  fprintf (file, "CheckSum\t\t%08lx\n", i->CheckSum);
     1825
    18451826  switch (i->Subsystem)
    18461827    {
     
    18731854      break;
    18741855    }
     1856
    18751857  fprintf (file, "Subsystem\t\t%08x", i->Subsystem);
    18761858  if (subsystem_name)
     
    19021884  pe_print_reloc (abfd, vfile);
    19031885
    1904   return true;
     1886  return TRUE;
    19051887}
    19061888
     
    19081890   to the output bfd.  */
    19091891
    1910 boolean
     1892bfd_boolean
    19111893_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)
    19121894     bfd *ibfd, *obfd;
     
    19151897  if (ibfd->xvec->flavour != bfd_target_coff_flavour
    19161898      || obfd->xvec->flavour != bfd_target_coff_flavour)
    1917     return true;
     1899    return TRUE;
    19181900
    19191901  pe_data (obfd)->pe_opthdr = pe_data (ibfd)->pe_opthdr;
    19201902  pe_data (obfd)->dll = pe_data (ibfd)->dll;
    19211903
    1922   /* for strip: if we removed .reloc, we'll make a real mess of things
     1904  /* For strip: if we removed .reloc, we'll make a real mess of things
    19231905     if we don't remove this entry as well.  */
    19241906  if (! pe_data (obfd)->has_reloc_section)
     
    19271909      pe_data (obfd)->pe_opthdr.DataDirectory[5].Size = 0;
    19281910    }
    1929   return true;
     1911  return TRUE;
    19301912}
    19311913
    19321914/* Copy private section data.  */
    1933 boolean
     1915
     1916bfd_boolean
    19341917_bfd_XX_bfd_copy_private_section_data (ibfd, isec, obfd, osec)
    19351918     bfd *ibfd;
     
    19401923  if (bfd_get_flavour (ibfd) != bfd_target_coff_flavour
    19411924      || bfd_get_flavour (obfd) != bfd_target_coff_flavour)
    1942     return true;
     1925    return TRUE;
    19431926
    19441927  if (coff_section_data (ibfd, isec) != NULL
     
    19471930      if (coff_section_data (obfd, osec) == NULL)
    19481931        {
    1949           osec->used_by_bfd =
    1950             (PTR) bfd_zalloc (obfd, sizeof (struct coff_section_tdata));
     1932          bfd_size_type amt = sizeof (struct coff_section_tdata);
     1933          osec->used_by_bfd = (PTR) bfd_zalloc (obfd, amt);
    19511934          if (osec->used_by_bfd == NULL)
    1952             return false;
     1935            return FALSE;
    19531936        }
     1937
    19541938      if (pei_section_data (obfd, osec) == NULL)
    19551939        {
    1956           coff_section_data (obfd, osec)->tdata =
    1957             (PTR) bfd_zalloc (obfd, sizeof (struct pei_section_tdata));
     1940          bfd_size_type amt = sizeof (struct pei_section_tdata);
     1941          coff_section_data (obfd, osec)->tdata = (PTR) bfd_zalloc (obfd, amt);
    19581942          if (coff_section_data (obfd, osec)->tdata == NULL)
    1959             return false;
     1943            return FALSE;
    19601944        }
     1945
    19611946      pei_section_data (obfd, osec)->virt_size =
    19621947        pei_section_data (ibfd, isec)->virt_size;
     
    19651950    }
    19661951
    1967   return true;
     1952  return TRUE;
    19681953}
    19691954
     
    19881973   access.  */
    19891974
    1990 boolean
     1975bfd_boolean
    19911976_bfd_XXi_final_link_postscript (abfd, pfinfo)
    19921977     bfd *abfd;
     
    20051990     of .idata$2 + .idata$3.  */
    20061991  h1 = coff_link_hash_lookup (coff_hash_table (info),
    2007                               ".idata$2", false, false, true);
     1992                              ".idata$2", FALSE, FALSE, TRUE);
    20081993  if (h1 != NULL)
    20091994    {
     
    20131998         + h1->root.u.def.section->output_offset);
    20141999      h1 = coff_link_hash_lookup (coff_hash_table (info),
    2015                                   ".idata$4", false, false, true);
     2000                                  ".idata$4", FALSE, FALSE, TRUE);
    20162001      pe_data (abfd)->pe_opthdr.DataDirectory[1].Size =
    20172002        ((h1->root.u.def.value
     
    20232008         .idata$5.  */
    20242009      h1 = coff_link_hash_lookup (coff_hash_table (info),
    2025                                   ".idata$5", false, false, true);
     2010                                  ".idata$5", FALSE, FALSE, TRUE);
    20262011      pe_data (abfd)->pe_opthdr.DataDirectory[12].VirtualAddress =
    20272012        (h1->root.u.def.value
     
    20292014         + h1->root.u.def.section->output_offset);
    20302015      h1 = coff_link_hash_lookup (coff_hash_table (info),
    2031                                   ".idata$6", false, false, true);
     2016                                  ".idata$6", FALSE, FALSE, TRUE);
    20322017      pe_data (abfd)->pe_opthdr.DataDirectory[12].Size =
    20332018        ((h1->root.u.def.value
    20342019          + h1->root.u.def.section->output_section->vma
    20352020          + h1->root.u.def.section->output_offset)
    2036          - pe_data (abfd)->pe_opthdr.DataDirectory[12].VirtualAddress);
    2037     }
    2038 
     2021         - pe_data (abfd)->pe_opthdr.DataDirectory[12].VirtualAddress);     
     2022    }
     2023 
    20392024  /* If we couldn't find idata$2, we either have an excessively
    20402025     trivial program or are in DEEP trouble; we have to assume trivial
    20412026     program....  */
    2042   return true;
     2027  return TRUE;
    20432028}
Note: See TracChangeset for help on using the changeset viewer.