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/nlmcode.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* NLM (NetWare Loadable Module) executable support for BFD.
    2    Copyright 1993, 1994, 1995, 1998, 2000 Free Software Foundation, Inc.
     2   Copyright 1993, 1994, 1995, 1998, 2000, 2001, 2002
     3   Free Software Foundation, Inc.
    34
    45   Written by Fred Fish @ Cygnus Support, using ELF support as the
    56   template.
    67
    7 This file is part of BFD, the Binary File Descriptor library.
    8 
    9 This program is free software; you can redistribute it and/or modify
    10 it under the terms of the GNU General Public License as published by
    11 the Free Software Foundation; either version 2 of the License, or
    12 (at your option) any later version.
    13 
    14 This program is distributed in the hope that it will be useful,
    15 but WITHOUT ANY WARRANTY; without even the implied warranty of
    16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17 GNU General Public License for more details.
    18 
    19 You should have received a copy of the GNU General Public License
    20 along with this program; if not, write to the Free Software
    21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
     8   This file is part of BFD, the Binary File Descriptor library.
     9
     10   This program is free software; you can redistribute it and/or modify
     11   it under the terms of the GNU General Public License as published by
     12   the Free Software Foundation; either version 2 of the License, or
     13   (at your option) any later version.
     14
     15   This program is distributed in the hope that it will be useful,
     16   but WITHOUT ANY WARRANTY; without even the implied warranty of
     17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     18   GNU General Public License for more details.
     19
     20   You should have received a copy of the GNU General Public License
     21   along with this program; if not, write to the Free Software
     22   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
    2223
    2324#include "bfd.h"
     
    5758  (nlm_swap_fixed_header_out_func(abfd)) (abfd,src,dst)
    5859
    59 /* Forward declarations of static functions */
    60 
    61 static boolean add_bfd_section
     60/* Forward declarations of static functions. */
     61
     62static bfd_boolean add_bfd_section
    6263  PARAMS ((bfd *, char *, file_ptr, bfd_size_type, flagword));
    63 static boolean nlm_swap_variable_header_in
     64static bfd_boolean nlm_swap_variable_header_in
    6465  PARAMS ((bfd *));
    65 static boolean nlm_swap_variable_header_out
     66static bfd_boolean nlm_swap_variable_header_out
    6667  PARAMS ((bfd *));
    67 static boolean find_nonzero
     68static bfd_boolean find_nonzero
    6869  PARAMS ((PTR, size_t));
    69 static boolean nlm_swap_auxiliary_headers_in
     70static bfd_boolean nlm_swap_auxiliary_headers_in
    7071  PARAMS ((bfd *));
    71 static boolean nlm_swap_auxiliary_headers_out
     72static bfd_boolean nlm_swap_auxiliary_headers_out
    7273  PARAMS ((bfd *));
    73 static boolean nlm_slurp_symbol_table
     74static bfd_boolean nlm_slurp_symbol_table
    7475  PARAMS ((bfd *));
    75 static boolean nlm_slurp_reloc_fixups
     76static bfd_boolean nlm_slurp_reloc_fixups
    7677  PARAMS ((bfd *));
    77 static boolean nlm_compute_section_file_positions
     78static bfd_boolean nlm_compute_section_file_positions
    7879  PARAMS ((bfd *));
    7980static int nlm_external_reloc_compare
     
    8384   can be handled by explicitly specifying 32 bits or "the long type".  */
    8485#if ARCH_SIZE == 64
    85 #define put_word        bfd_h_put_64
    86 #define get_word        bfd_h_get_64
     86#define put_word        H_PUT_64
     87#define get_word        H_GET_64
    8788#endif
    8889#if ARCH_SIZE == 32
    89 #define put_word        bfd_h_put_32
    90 #define get_word        bfd_h_get_32
     90#define put_word        H_PUT_32
     91#define get_word        H_GET_32
    9192#endif
    9293
     
    9697{
    9798  struct nlm_obj_tdata *preserved_tdata = nlm_tdata (abfd);
    98   boolean (*backend_object_p) PARAMS ((bfd *));
     99  bfd_boolean (*backend_object_p) PARAMS ((bfd *));
    99100  PTR x_fxdhdr = NULL;
    100101  Nlm_Internal_Fixed_Header *i_fxdhdrp;
     
    102103  const char *signature;
    103104  enum bfd_architecture arch;
     105  bfd_size_type amt;
    104106
    105107  /* Some NLM formats have a prefix before the standard NLM fixed
     
    113115
    114116  /* Read in the fixed length portion of the NLM header in external format.  */
    115 
    116   x_fxdhdr = (PTR) bfd_malloc ((size_t) nlm_fixed_header_size (abfd));
     117  amt = nlm_fixed_header_size (abfd);
     118  x_fxdhdr = (PTR) bfd_malloc (amt);
    117119  if (x_fxdhdr == NULL)
    118120    goto got_no_match;
    119121
    120   if (bfd_read ((PTR) x_fxdhdr, nlm_fixed_header_size (abfd), 1, abfd) !=
    121       nlm_fixed_header_size (abfd))
     122  if (bfd_bread ((PTR) x_fxdhdr, amt, abfd) != amt)
    122123    {
    123124      if (bfd_get_error () != bfd_error_system_call)
     
    129130  /* Allocate an instance of the nlm_obj_tdata structure and hook it up to
    130131     the tdata pointer in the bfd.  */
    131 
    132   new_tdata = ((struct nlm_obj_tdata *)
    133                bfd_zalloc (abfd, sizeof (struct nlm_obj_tdata)));
     132  amt = sizeof (struct nlm_obj_tdata);
     133  new_tdata = (struct nlm_obj_tdata *) bfd_zalloc (abfd, amt);
    134134  if (new_tdata == NULL)
    135135    goto got_no_match;
     
    144144  /* Check to see if we have an NLM file for this backend by matching
    145145     the NLM signature.  */
    146 
    147146  signature = nlm_signature (abfd);
    148147  if (signature != NULL
     
    154153  /* There's no supported way to discover the endianess of an NLM, so test for
    155154     a sane version number after doing byte swapping appropriate for this
    156      XVEC.  (Hack alert!) */
    157 
     155     XVEC.  (Hack alert!)  */
    158156  if (i_fxdhdrp->version > 0xFFFF)
    159157    goto got_wrong_format_error;
     
    161159  /* There's no supported way to check for 32 bit versus 64 bit addresses,
    162160     so ignore this distinction for now.  (FIXME) */
    163 
    164161  /* Swap in the rest of the required header.  */
    165162  if (!nlm_swap_variable_header_in (abfd))
     
    176173     From this point on we assume that we have an NLM, and do not
    177174     treat errors as indicating the wrong format.  */
    178 
    179175  if (!add_bfd_section (abfd, NLM_CODE_NAME,
    180176                        i_fxdhdrp->codeImageOffset,
     
    226222/* Add a section to the bfd.  */
    227223
    228 static boolean
     224static bfd_boolean
    229225add_bfd_section (abfd, name, offset, size, flags)
    230226     bfd *abfd;
     
    238234  newsect = bfd_make_section (abfd, name);
    239235  if (newsect == NULL)
    240     {
    241       return (false);
    242     }
     236    return FALSE;
     237
    243238  newsect->vma = 0;             /* NLM's are relocatable.  */
    244239  newsect->_raw_size = size;
    245240  newsect->filepos = offset;
    246241  newsect->flags = flags;
    247   newsect->alignment_power = bfd_log2 (0);      /* FIXME */
    248   return (true);
     242  newsect->alignment_power = bfd_log2 ((bfd_vma) 0);    /* FIXME */
     243
     244  return TRUE;
    249245}
    250246
     
    252248   exist in the NLM, and must exist in the order they are read here.  */
    253249
    254 static boolean
     250static bfd_boolean
    255251nlm_swap_variable_header_in (abfd)
    256252     bfd *abfd;
    257253{
    258254  unsigned char temp[NLM_TARGET_LONG_SIZE];
     255  bfd_size_type amt;
    259256
    260257  /* Read the description length and text members.  */
    261258
    262   if (bfd_read ((PTR) & nlm_variable_header (abfd)->descriptionLength,
    263                 sizeof (nlm_variable_header (abfd)->descriptionLength),
    264                 1, abfd) !=
    265       sizeof (nlm_variable_header (abfd)->descriptionLength))
    266     return (false);
    267   if (bfd_read ((PTR) nlm_variable_header (abfd)->descriptionText,
    268                 nlm_variable_header (abfd)->descriptionLength + 1,
    269                 1, abfd) !=
    270       (bfd_size_type) nlm_variable_header (abfd)->descriptionLength + 1)
    271     return (false);
     259  amt = sizeof (nlm_variable_header (abfd)->descriptionLength);
     260  if (bfd_bread ((PTR) &nlm_variable_header (abfd)->descriptionLength,
     261                amt, abfd) != amt)
     262    return FALSE;
     263  amt = nlm_variable_header (abfd)->descriptionLength + 1;
     264  if (bfd_bread ((PTR) nlm_variable_header (abfd)->descriptionText,
     265                amt, abfd) != amt)
     266    return FALSE;
    272267
    273268  /* Read and convert the stackSize field.  */
    274269
    275   if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
    276     return (false);
     270  amt = sizeof (temp);
     271  if (bfd_bread ((PTR) temp, amt, abfd) != amt)
     272    return FALSE;
    277273  nlm_variable_header (abfd)->stackSize = get_word (abfd, (bfd_byte *) temp);
    278274
    279275  /* Read and convert the reserved field.  */
    280276
    281   if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
    282     return (false);
     277  amt = sizeof (temp);
     278  if (bfd_bread ((PTR) temp, amt, abfd) != amt)
     279    return FALSE;
    283280  nlm_variable_header (abfd)->reserved = get_word (abfd, (bfd_byte *) temp);
    284281
    285282  /* Read the oldThreadName field.  This field is a fixed length string.  */
    286283
    287   if (bfd_read ((PTR) nlm_variable_header (abfd)->oldThreadName,
    288                 sizeof (nlm_variable_header (abfd)->oldThreadName),
    289                 1, abfd) !=
    290       sizeof (nlm_variable_header (abfd)->oldThreadName))
    291     return (false);
     284  amt = sizeof (nlm_variable_header (abfd)->oldThreadName);
     285  if (bfd_bread ((PTR) nlm_variable_header (abfd)->oldThreadName,
     286                amt, abfd) != amt)
     287    return FALSE;
    292288
    293289  /* Read the screen name length and text members.  */
    294290
    295   if (bfd_read ((PTR) & nlm_variable_header (abfd)->screenNameLength,
    296                 sizeof (nlm_variable_header (abfd)->screenNameLength),
    297                 1, abfd) !=
    298       sizeof (nlm_variable_header (abfd)->screenNameLength))
    299     return (false);
    300   if (bfd_read ((PTR) nlm_variable_header (abfd)->screenName,
    301                 nlm_variable_header (abfd)->screenNameLength + 1,
    302                 1, abfd) !=
    303       (bfd_size_type) nlm_variable_header (abfd)->screenNameLength + 1)
    304     return (false);
     291  amt = sizeof (nlm_variable_header (abfd)->screenNameLength);
     292  if (bfd_bread ((PTR) & nlm_variable_header (abfd)->screenNameLength,
     293                amt, abfd) != amt)
     294    return FALSE;
     295  amt = nlm_variable_header (abfd)->screenNameLength + 1;
     296  if (bfd_bread ((PTR) nlm_variable_header (abfd)->screenName,
     297                amt, abfd) != amt)
     298    return FALSE;
    305299
    306300  /* Read the thread name length and text members.  */
    307301
    308   if (bfd_read ((PTR) & nlm_variable_header (abfd)->threadNameLength,
    309                 sizeof (nlm_variable_header (abfd)->threadNameLength),
    310                 1, abfd) !=
    311       sizeof (nlm_variable_header (abfd)->threadNameLength))
    312     return (false);
    313   if (bfd_read ((PTR) nlm_variable_header (abfd)->threadName,
    314                 nlm_variable_header (abfd)->threadNameLength + 1,
    315                 1, abfd) !=
    316       (bfd_size_type) nlm_variable_header (abfd)->threadNameLength + 1)
    317     return (false);
    318   return (true);
     302  amt = sizeof (nlm_variable_header (abfd)->threadNameLength);
     303  if (bfd_bread ((PTR) & nlm_variable_header (abfd)->threadNameLength,
     304                amt, abfd) != amt)
     305    return FALSE;
     306  amt = nlm_variable_header (abfd)->threadNameLength + 1;
     307  if (bfd_bread ((PTR) nlm_variable_header (abfd)->threadName,
     308                amt, abfd) != amt)
     309    return FALSE;
     310  return TRUE;
    319311}
    320312
     
    322314   exist in the NLM, and must exist in this order.  */
    323315
    324 static boolean
     316static bfd_boolean
    325317nlm_swap_variable_header_out (abfd)
    326318     bfd *abfd;
    327319{
    328320  unsigned char temp[NLM_TARGET_LONG_SIZE];
     321  bfd_size_type amt;
    329322
    330323  /* Write the description length and text members.  */
    331 
    332   if (bfd_write ((PTR) & nlm_variable_header (abfd)->descriptionLength,
    333                  sizeof (nlm_variable_header (abfd)->descriptionLength),
    334                  1, abfd) !=
    335       sizeof (nlm_variable_header (abfd)->descriptionLength))
    336     return (false);
    337   if (bfd_write ((PTR) nlm_variable_header (abfd)->descriptionText,
    338                  nlm_variable_header (abfd)->descriptionLength + 1,
    339                  1, abfd) !=
    340       (bfd_size_type) nlm_variable_header (abfd)->descriptionLength + 1)
    341     return (false);
     324  amt = sizeof (nlm_variable_header (abfd)->descriptionLength);
     325  if (bfd_bwrite ((PTR) & nlm_variable_header (abfd)->descriptionLength, amt,
     326                 abfd) != amt)
     327    return FALSE;
     328  amt = nlm_variable_header (abfd)->descriptionLength + 1;
     329  if (bfd_bwrite ((PTR) nlm_variable_header (abfd)->descriptionText, amt,
     330                 abfd) != amt)
     331    return FALSE;
    342332
    343333  /* Convert and write the stackSize field.  */
    344 
    345334  put_word (abfd, (bfd_vma) nlm_variable_header (abfd)->stackSize,
    346335            (bfd_byte *) temp);
    347   if (bfd_write ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
    348     return (false);
     336  amt = sizeof (temp);
     337  if (bfd_bwrite ((PTR) temp, amt, abfd) != amt)
     338    return FALSE;
    349339
    350340  /* Convert and write the reserved field.  */
    351 
    352341  put_word (abfd, (bfd_vma) nlm_variable_header (abfd)->reserved,
    353342            (bfd_byte *) temp);
    354   if (bfd_write ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
    355     return (false);
     343  amt = sizeof (temp);
     344  if (bfd_bwrite ((PTR) temp, amt, abfd) != amt)
     345    return FALSE;
    356346
    357347  /* Write the oldThreadName field.  This field is a fixed length string.  */
    358 
    359   if (bfd_write ((PTR) nlm_variable_header (abfd)->oldThreadName,
    360                  sizeof (nlm_variable_header (abfd)->oldThreadName),
    361                  1, abfd) !=
    362       sizeof (nlm_variable_header (abfd)->oldThreadName))
    363     return (false);
     348  amt = sizeof (nlm_variable_header (abfd)->oldThreadName);
     349  if (bfd_bwrite ((PTR) nlm_variable_header (abfd)->oldThreadName, amt,
     350                 abfd) != amt)
     351    return FALSE;
    364352
    365353  /* Write the screen name length and text members.  */
    366 
    367   if (bfd_write ((PTR) & nlm_variable_header (abfd)->screenNameLength,
    368                  sizeof (nlm_variable_header (abfd)->screenNameLength),
    369                  1, abfd) !=
    370       sizeof (nlm_variable_header (abfd)->screenNameLength))
    371     return (false);
    372   if (bfd_write ((PTR) nlm_variable_header (abfd)->screenName,
    373                  nlm_variable_header (abfd)->screenNameLength + 1,
    374                  1, abfd) !=
    375       (bfd_size_type) nlm_variable_header (abfd)->screenNameLength + 1)
    376     return (false);
     354  amt = sizeof (nlm_variable_header (abfd)->screenNameLength);
     355  if (bfd_bwrite ((PTR) & nlm_variable_header (abfd)->screenNameLength, amt,
     356                 abfd) != amt)
     357    return FALSE;
     358  amt = nlm_variable_header (abfd)->screenNameLength + 1;
     359  if (bfd_bwrite ((PTR) nlm_variable_header (abfd)->screenName, amt,
     360                 abfd) != amt)
     361    return FALSE;
    377362
    378363  /* Write the thread name length and text members.  */
    379 
    380   if (bfd_write ((PTR) & nlm_variable_header (abfd)->threadNameLength,
    381                  sizeof (nlm_variable_header (abfd)->threadNameLength),
    382                  1, abfd) !=
    383       sizeof (nlm_variable_header (abfd)->threadNameLength))
    384     return (false);
    385   if (bfd_write ((PTR) nlm_variable_header (abfd)->threadName,
    386                  nlm_variable_header (abfd)->threadNameLength + 1,
    387                  1, abfd) !=
    388       (bfd_size_type) nlm_variable_header (abfd)->threadNameLength + 1)
    389     return (false);
    390   return (true);
     364  amt = sizeof (nlm_variable_header (abfd)->threadNameLength);
     365  if (bfd_bwrite ((PTR) & nlm_variable_header (abfd)->threadNameLength, amt,
     366                 abfd) != amt)
     367    return FALSE;
     368  amt = nlm_variable_header (abfd)->threadNameLength + 1;
     369  if (bfd_bwrite ((PTR) nlm_variable_header (abfd)->threadName, amt,
     370                 abfd) != amt)
     371    return FALSE;
     372  return TRUE;
    391373}
    392374
     
    400382   recognize it.  */
    401383
    402 static boolean
     384static bfd_boolean
    403385nlm_swap_auxiliary_headers_in (abfd)
    404386     bfd *abfd;
    405387{
    406388  char tempstr[16];
    407   long position;
     389  file_ptr position;
     390  bfd_size_type amt;
    408391
    409392  for (;;)
    410393    {
    411394      position = bfd_tell (abfd);
    412       if (bfd_read ((PTR) tempstr, sizeof (tempstr), 1, abfd) !=
    413           sizeof (tempstr))
    414         return (false);
    415       if (bfd_seek (abfd, position, SEEK_SET) == -1)
    416         return (false);
     395      amt = sizeof (tempstr);
     396      if (bfd_bread ((PTR) tempstr, amt, abfd) != amt)
     397        return FALSE;
     398      if (bfd_seek (abfd, position, SEEK_SET) != 0)
     399        return FALSE;
    417400      if (strncmp (tempstr, "VeRsIoN#", 8) == 0)
    418401        {
    419402          Nlm_External_Version_Header thdr;
    420           if (bfd_read ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
    421             return (false);
     403
     404          amt = sizeof (thdr);
     405          if (bfd_bread ((PTR) &thdr, amt, abfd) != amt)
     406            return FALSE;
    422407          memcpy (nlm_version_header (abfd)->stamp, thdr.stamp,
    423408                  sizeof (thdr.stamp));
     
    438423        {
    439424          Nlm_External_Extended_Header thdr;
    440           if (bfd_read ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
    441             return (false);
     425
     426          amt = sizeof (thdr);
     427          if (bfd_bread ((PTR) &thdr, amt, abfd) != amt)
     428            return FALSE;
    442429          memcpy (nlm_extended_header (abfd)->stamp, thdr.stamp,
    443430                  sizeof (thdr.stamp));
     
    503490      else if (strncmp (tempstr, "CoPyRiGhT=", 10) == 0)
    504491        {
    505           if (bfd_read ((PTR) nlm_copyright_header (abfd)->stamp,
    506                         sizeof (nlm_copyright_header (abfd)->stamp),
    507                         1, abfd)
    508               != sizeof (nlm_copyright_header (abfd)->stamp))
    509             return (false);
    510           if (bfd_read ((PTR) & (nlm_copyright_header (abfd)
    511                                  ->copyrightMessageLength),
    512                         1, 1, abfd) != 1)
    513             return (false);
     492          amt = sizeof (nlm_copyright_header (abfd)->stamp);
     493          if (bfd_bread ((PTR) nlm_copyright_header (abfd)->stamp,
     494                        amt, abfd) != amt)
     495            return FALSE;
     496          if (bfd_bread ((PTR) &(nlm_copyright_header (abfd)
     497                                ->copyrightMessageLength),
     498                        (bfd_size_type) 1, abfd) != 1)
     499            return FALSE;
    514500          /* The copyright message is a variable length string.  */
    515           if (bfd_read ((PTR) nlm_copyright_header (abfd)->copyrightMessage,
    516                     nlm_copyright_header (abfd)->copyrightMessageLength + 1,
    517                         1, abfd) !=
    518               ((bfd_size_type)
    519                nlm_copyright_header (abfd)->copyrightMessageLength + 1))
    520             return (false);
     501          amt = nlm_copyright_header (abfd)->copyrightMessageLength + 1;
     502          if (bfd_bread ((PTR) nlm_copyright_header (abfd)->copyrightMessage,
     503                        amt, abfd) != amt)
     504            return FALSE;
    521505        }
    522506      else if (strncmp (tempstr, "CuStHeAd", 8) == 0)
     
    530514
    531515          /* Read the stamp ("CuStHeAd").  */
    532           if (bfd_read ((PTR) thdr.stamp, 1, sizeof (thdr.stamp), abfd)
    533               != sizeof (thdr.stamp))
    534             return false;
     516          amt = sizeof (thdr.stamp);
     517          if (bfd_bread ((PTR) thdr.stamp, amt, abfd) != amt)
     518            return FALSE;
    535519          /* Read the length of this custom header.  */
    536           if (bfd_read ((PTR) thdr.length, 1, sizeof (thdr.length), abfd)
    537               != sizeof (thdr.length))
    538             return false;
     520          amt = sizeof (thdr.length);
     521          if (bfd_bread ((PTR) thdr.length, amt, abfd) != amt)
     522            return FALSE;
    539523          hdrLength = get_word (abfd, (bfd_byte *) thdr.length);
    540524          /* Read further fields if we have them.  */
     
    543527          else
    544528            {
    545               if (bfd_read ((PTR) thdr.dataOffset, 1,
    546                             sizeof (thdr.dataOffset), abfd)
    547                   != sizeof (thdr.dataOffset))
    548                 return false;
     529              amt = sizeof (thdr.dataOffset);
     530              if (bfd_bread ((PTR) thdr.dataOffset, amt, abfd) != amt)
     531                return FALSE;
    549532              dataOffset = get_word (abfd, (bfd_byte *) thdr.dataOffset);
    550533            }
     
    553536          else
    554537            {
    555               if (bfd_read ((PTR) thdr.dataLength, 1,
    556                             sizeof (thdr.dataLength), abfd)
    557                   != sizeof (thdr.dataLength))
    558                 return false;
     538              amt = sizeof (thdr.dataLength);
     539              if (bfd_bread ((PTR) thdr.dataLength, amt, abfd) != amt)
     540                return FALSE;
    559541              dataLength = get_word (abfd, (bfd_byte *) thdr.dataLength);
    560542            }
     
    563545          else
    564546            {
    565               if (bfd_read ((PTR) dataStamp, 1, sizeof (dataStamp), abfd)
    566                   != sizeof (dataStamp))
    567                 return false;
     547              amt = sizeof (dataStamp);
     548              if (bfd_bread ((PTR) dataStamp, amt, abfd) != amt)
     549                return FALSE;
    568550            }
    569551
     
    579561              hdr = bfd_alloc (abfd, hdrLength);
    580562              if (hdr == NULL)
    581                 return false;
    582               if (bfd_read (hdr, 1, hdrLength, abfd) != hdrLength)
    583                 return false;
     563                return FALSE;
     564              if (bfd_bread (hdr, hdrLength, abfd) != hdrLength)
     565                return FALSE;
    584566            }
    585567
     
    597579              pos = bfd_tell (abfd);
    598580              if (bfd_seek (abfd, dataOffset, SEEK_SET) != 0)
    599                 return false;
     581                return FALSE;
    600582              contents = (bfd_byte *) bfd_alloc (abfd, dataLength);
    601583              if (contents == NULL)
    602                 return false;
    603               if (bfd_read (contents, 1, dataLength, abfd) != dataLength)
    604                 return false;
     584                return FALSE;
     585              if (bfd_bread (contents, dataLength, abfd) != dataLength)
     586                return FALSE;
    605587              if (bfd_seek (abfd, pos, SEEK_SET) != 0)
    606                 return false;
     588                return FALSE;
    607589
    608590              memcpy (nlm_cygnus_ext_header (abfd), "CyGnUsEx", 8);
     
    639621                  name = (char *) p;
    640622                  l = strlen (name) + 1;
    641                   l = (l + 3) &~ 3;
     623                  l = (l + 3) &~ (size_t) 3;
    642624                  p += l;
    643                   filepos = bfd_h_get_32 (abfd, p);
     625                  filepos = H_GET_32 (abfd, p);
    644626                  p += 4;
    645                   size = bfd_h_get_32 (abfd, p);
     627                  size = H_GET_32 (abfd, p);
    646628                  p += 4;
    647629
    648630                  newsec = bfd_make_section_anyway (abfd, name);
    649631                  if (newsec == (asection *) NULL)
    650                     return false;
     632                    return FALSE;
    651633                  newsec->_raw_size = size;
    652634                  if (filepos != 0)
     
    670652        }
    671653      else
    672         {
    673           break;
    674         }
    675     }
    676   return (true);
     654        break;
     655    }
     656  return TRUE;
    677657}
    678658
    679659/* Return whether there is a non-zero byte in a memory block.  */
    680660
    681 static boolean
     661static bfd_boolean
    682662find_nonzero (buf, size)
    683663     PTR buf;
     
    688668  while (size-- != 0)
    689669    if (*p++ != 0)
    690       return true;
    691   return false;
     670      return TRUE;
     671  return FALSE;
    692672}
    693673
     
    696676   the caller to set up the stamp fields.  */
    697677
    698 static boolean
     678static bfd_boolean
    699679nlm_swap_auxiliary_headers_out (abfd)
    700680     bfd *abfd;
    701681{
     682  bfd_size_type amt;
     683
    702684  /* Write out the version header if there is one.  */
    703685  if (find_nonzero ((PTR) nlm_version_header (abfd),
     
    719701      put_word (abfd, (bfd_vma) nlm_version_header (abfd)->day,
    720702                (bfd_byte *) thdr.day);
    721       if (bfd_write ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
    722         return false;
     703      if (bfd_bwrite ((PTR) &thdr, (bfd_size_type) sizeof (thdr), abfd)
     704          != sizeof (thdr))
     705        return FALSE;
     706    }
     707
     708  /* Note - the CoPyRiGhT tag is emitted before the MeSsAgEs
     709     tag in order to make the NW4.x and NW5.x loaders happy.  */
     710
     711  /* Write out the copyright header if there is one.  */
     712  if (find_nonzero ((PTR) nlm_copyright_header (abfd),
     713                    sizeof (Nlm_Internal_Copyright_Header)))
     714    {
     715      Nlm_External_Copyright_Header thdr;
     716
     717      memcpy (thdr.stamp, "CoPyRiGhT=", 10);
     718      amt = sizeof (thdr.stamp);
     719      if (bfd_bwrite ((PTR) thdr.stamp, amt, abfd) != amt)
     720        return FALSE;
     721      thdr.copyrightMessageLength[0] =
     722        nlm_copyright_header (abfd)->copyrightMessageLength;
     723      amt = 1;
     724      if (bfd_bwrite ((PTR) thdr.copyrightMessageLength, amt, abfd) != amt)
     725        return FALSE;
     726      /* The copyright message is a variable length string.  */
     727      amt = nlm_copyright_header (abfd)->copyrightMessageLength + 1;
     728      if (bfd_bwrite ((PTR) nlm_copyright_header (abfd)->copyrightMessage,
     729                     amt, abfd) != amt)
     730        return FALSE;
    723731    }
    724732
     
    817825                (bfd_vma) nlm_extended_header (abfd)->reserved5,
    818826                (bfd_byte *) thdr.reserved5);
    819       if (bfd_write ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
    820         return false;
    821     }
    822 
    823   /* Write out the copyright header if there is one.  */
    824   if (find_nonzero ((PTR) nlm_copyright_header (abfd),
    825                     sizeof (Nlm_Internal_Copyright_Header)))
    826     {
    827       Nlm_External_Copyright_Header thdr;
    828 
    829       memcpy (thdr.stamp, "CoPyRiGhT=", 10);
    830       if (bfd_write ((PTR) thdr.stamp, sizeof (thdr.stamp), 1, abfd)
    831           != sizeof (thdr.stamp))
    832         return false;
    833       thdr.copyrightMessageLength[0] =
    834         nlm_copyright_header (abfd)->copyrightMessageLength;
    835       if (bfd_write ((PTR) thdr.copyrightMessageLength, 1, 1, abfd) != 1)
    836         return false;
    837       /* The copyright message is a variable length string.  */
    838       if (bfd_write ((PTR) nlm_copyright_header (abfd)->copyrightMessage,
    839                      nlm_copyright_header (abfd)->copyrightMessageLength + 1,
    840                      1, abfd) !=
    841           ((bfd_size_type)
    842            nlm_copyright_header (abfd)->copyrightMessageLength + 1))
    843         return false;
     827      if (bfd_bwrite ((PTR) &thdr, (bfd_size_type) sizeof (thdr), abfd)
     828          != sizeof (thdr))
     829        return FALSE;
    844830    }
    845831
     
    849835    {
    850836      Nlm_External_Custom_Header thdr;
    851       boolean ds;
     837      bfd_boolean ds;
    852838      bfd_size_type hdrLength;
    853839
     
    865851        {
    866852          BFD_ASSERT (nlm_custom_header (abfd)->hdrLength == 0);
    867           if (bfd_write ((PTR) &thdr, 1,
    868                          sizeof (thdr) - sizeof (thdr.dataStamp), abfd)
    869               != sizeof (thdr) - sizeof (thdr.dataStamp))
    870             return false;
     853          amt = sizeof (thdr) - sizeof (thdr.dataStamp);
     854          if (bfd_bwrite ((PTR) &thdr, amt, abfd) != amt)
     855            return FALSE;
    871856        }
    872857      else
     
    874859          memcpy (thdr.dataStamp, nlm_custom_header (abfd)->dataStamp,
    875860                  sizeof (thdr.dataStamp));
    876           if (bfd_write ((PTR) &thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
    877             return false;
    878           if (bfd_write (nlm_custom_header (abfd)->hdr, 1,
    879                          nlm_custom_header (abfd)->hdrLength, abfd)
    880               != nlm_custom_header (abfd)->hdrLength)
    881             return false;
     861          amt = sizeof (thdr);
     862          if (bfd_bwrite ((PTR) &thdr, amt, abfd) != amt)
     863            return FALSE;
     864          amt = nlm_custom_header (abfd)->hdrLength;
     865          if (bfd_bwrite (nlm_custom_header (abfd)->hdr, amt, abfd) != amt)
     866            return FALSE;
    882867        }
    883868    }
     
    897882                (bfd_byte *) thdr.dataLength);
    898883      memcpy (thdr.dataStamp, "CyGnUsEx", 8);
    899       if (bfd_write ((PTR) &thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
    900         return false;
    901     }
    902 
    903   return true;
     884      amt = sizeof (thdr);
     885      if (bfd_bwrite ((PTR) &thdr, amt, abfd) != amt)
     886        return FALSE;
     887    }
     888
     889  return TRUE;
    904890}
    905891
     
    917903     bfd *abfd;
    918904{
    919   Nlm_Internal_Fixed_Header *i_fxdhdrp; /* Nlm file header, internal form */
     905  Nlm_Internal_Fixed_Header *i_fxdhdrp; /* Nlm file header, internal form. */
    920906  long symcount;
    921907  long symtab_size = 0;
     
    940926  bfd_size_type counter = 0;
    941927
    942   if (nlm_slurp_symbol_table (abfd) == false)
     928  if (! nlm_slurp_symbol_table (abfd))
    943929    return -1;
    944930  symbase = nlm_get_symbols (abfd);
     
    959945     bfd *abfd;
    960946{
    961   nlm_symbol_type *new;
    962 
    963   new = (nlm_symbol_type *) bfd_zalloc (abfd, sizeof (nlm_symbol_type));
     947  bfd_size_type amt = sizeof (nlm_symbol_type);
     948  nlm_symbol_type *new = (nlm_symbol_type *) bfd_zalloc (abfd, amt);
     949
    964950  if (new)
    965951    new->symbol.the_bfd = abfd;
     
    982968void
    983969nlm_print_symbol (abfd, afile, symbol, how)
    984      bfd *abfd ATTRIBUTE_UNUSED;
     970     bfd *abfd;
    985971     PTR afile;
    986972     asymbol *symbol;
     
    997983      break;
    998984    case bfd_print_symbol_all:
    999       bfd_print_symbol_vandf ((PTR) file, symbol);
     985      bfd_print_symbol_vandf (abfd, (PTR) file, symbol);
    1000986      fprintf (file, " %-5s", symbol->section->name);
    1001987      if (symbol->name)
     
    10221008
    10231009   When we return, the bfd symcount is either zero or contains the correct
    1024    number of symbols.
    1025 */
    1026 
    1027 static boolean
     1010   number of symbols.  */
     1011
     1012static bfd_boolean
    10281013nlm_slurp_symbol_table (abfd)
    10291014     bfd *abfd;
    10301015{
    1031   Nlm_Internal_Fixed_Header *i_fxdhdrp; /* Nlm file header, internal form */
    1032   bfd_size_type totsymcount;    /* Number of NLM symbols */
    1033   bfd_size_type symcount;       /* Counter of NLM symbols */
    1034   nlm_symbol_type *sym;         /* Pointer to current bfd symbol */
    1035   unsigned char symlength;      /* Symbol length read into here */
    1036   unsigned char symtype;        /* Type of debugging symbol */
    1037   bfd_byte temp[NLM_TARGET_LONG_SIZE];  /* Symbol offsets read into here */
    1038   boolean (*read_import_func) PARAMS ((bfd *, nlm_symbol_type *));
    1039   boolean (*set_public_section_func) PARAMS ((bfd *, nlm_symbol_type *));
     1016  Nlm_Internal_Fixed_Header *i_fxdhdrp; /* Nlm file header, internal form.  */
     1017  bfd_size_type totsymcount;    /* Number of NLM symbols.  */
     1018  bfd_size_type symcount;       /* Counter of NLM symbols.  */
     1019  nlm_symbol_type *sym;         /* Pointer to current bfd symbol.  */
     1020  unsigned char symlength;      /* Symbol length read into here.  */
     1021  unsigned char symtype;        /* Type of debugging symbol.  */
     1022  bfd_byte temp[NLM_TARGET_LONG_SIZE];  /* Symbol offsets read into here.  */
     1023  bfd_boolean (*read_import_func) PARAMS ((bfd *, nlm_symbol_type *));
     1024  bfd_boolean (*set_public_section_func) PARAMS ((bfd *, nlm_symbol_type *));
     1025  bfd_size_type amt;
    10401026
    10411027  if (nlm_get_symbols (abfd) != NULL)
    1042     return (true);
     1028    return TRUE;
    10431029
    10441030  /* Read each raw NLM symbol, using the information to create a canonical bfd
     
    10561042                 + i_fxdhdrp->numberOfExternalReferences);
    10571043  if (totsymcount == 0)
    1058     {
    1059       return (true);
    1060     }
    1061 
    1062   if (bfd_seek (abfd, i_fxdhdrp->publicsOffset, SEEK_SET) == -1)
    1063     return (false);
    1064 
    1065   sym = ((nlm_symbol_type *)
    1066          bfd_zalloc (abfd, totsymcount * sizeof (nlm_symbol_type)));
     1044    return TRUE;
     1045
     1046  if (bfd_seek (abfd, i_fxdhdrp->publicsOffset, SEEK_SET) != 0)
     1047    return FALSE;
     1048
     1049  amt = totsymcount * sizeof (nlm_symbol_type);
     1050  sym = ((nlm_symbol_type *) bfd_zalloc (abfd, amt));
    10671051  if (!sym)
    1068     return false;
     1052    return FALSE;
    10691053  nlm_set_symbols (abfd, sym);
    10701054
     
    10771061  while (abfd->symcount < symcount)
    10781062    {
    1079       if (bfd_read ((PTR) & symlength, sizeof (symlength), 1, abfd)
    1080           != sizeof (symlength))
    1081         return (false);
     1063      amt = sizeof (symlength);
     1064      if (bfd_bread ((PTR) &symlength, amt, abfd) != amt)
     1065        return FALSE;
     1066      amt = symlength;
    10821067      sym->symbol.the_bfd = abfd;
    1083       sym->symbol.name = bfd_alloc (abfd, symlength + 1);
     1068      sym->symbol.name = bfd_alloc (abfd, amt + 1);
    10841069      if (!sym->symbol.name)
    1085         return false;
    1086       if (bfd_read ((PTR) sym->symbol.name, symlength, 1, abfd)
    1087           != symlength)
    1088         return (false);
     1070        return FALSE;
     1071      if (bfd_bread ((PTR) sym->symbol.name, amt, abfd) != amt)
     1072        return FALSE;
    10891073      /* Cast away const.  */
    10901074      ((char *) (sym->symbol.name))[symlength] = '\0';
    1091       if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
    1092         return (false);
     1075      amt = sizeof (temp);
     1076      if (bfd_bread ((PTR) temp, amt, abfd) != amt)
     1077        return FALSE;
    10931078      sym->symbol.flags = BSF_GLOBAL | BSF_EXPORT;
    10941079      sym->symbol.value = get_word (abfd, temp);
     
    10971082          /* Most backends can use the code below, but unfortunately
    10981083             some use a different scheme.  */
    1099           if ((*set_public_section_func) (abfd, sym) == false)
    1100             return false;
     1084          if (! (*set_public_section_func) (abfd, sym))
     1085            return FALSE;
    11011086        }
    11021087      else
     
    11241109  if (i_fxdhdrp->numberOfDebugRecords > 0)
    11251110    {
    1126       if (bfd_seek (abfd, i_fxdhdrp->debugInfoOffset, SEEK_SET) == -1)
    1127         return (false);
     1111      if (bfd_seek (abfd, i_fxdhdrp->debugInfoOffset, SEEK_SET) != 0)
     1112        return FALSE;
    11281113
    11291114      symcount += i_fxdhdrp->numberOfDebugRecords;
    11301115      while (abfd->symcount < symcount)
    11311116        {
    1132           if ((bfd_read ((PTR) & symtype, sizeof (symtype), 1, abfd)
    1133                != sizeof (symtype))
    1134            || bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp)
    1135               || (bfd_read ((PTR) & symlength, sizeof (symlength), 1, abfd)
    1136                   != sizeof (symlength)))
    1137             return false;
     1117          amt = sizeof (symtype);
     1118          if (bfd_bread ((PTR) &symtype, amt, abfd) != amt)
     1119            return FALSE;
     1120          amt = sizeof (temp);
     1121          if (bfd_bread ((PTR) temp, amt, abfd) != amt)
     1122            return FALSE;
     1123          amt = sizeof (symlength);
     1124          if (bfd_bread ((PTR) &symlength, amt, abfd) != amt)
     1125            return FALSE;
     1126          amt = symlength;
    11381127          sym->symbol.the_bfd = abfd;
    1139           sym->symbol.name = bfd_alloc (abfd, symlength + 1);
     1128          sym->symbol.name = bfd_alloc (abfd, amt + 1);
    11401129          if (!sym->symbol.name)
    1141             return false;
    1142           if (bfd_read ((PTR) sym->symbol.name, symlength, 1, abfd)
    1143               != symlength)
    1144             return (false);
     1130            return FALSE;
     1131          if (bfd_bread ((PTR) sym->symbol.name, amt, abfd) != amt)
     1132            return FALSE;
    11451133          /* Cast away const.  */
    11461134          ((char *) (sym->symbol.name))[symlength] = '\0';
     
    11701158  /* Read in the import records.  We can only do this if we know how
    11711159     to read relocs for this target.  */
    1172 
    11731160  read_import_func = nlm_read_import_func (abfd);
    11741161  if (read_import_func != NULL)
    11751162    {
    1176       if (bfd_seek (abfd, i_fxdhdrp->externalReferencesOffset, SEEK_SET)
    1177           == -1)
    1178         return (false);
     1163      if (bfd_seek (abfd, i_fxdhdrp->externalReferencesOffset, SEEK_SET) != 0)
     1164        return FALSE;
    11791165
    11801166      symcount += i_fxdhdrp->numberOfExternalReferences;
    11811167      while (abfd->symcount < symcount)
    11821168        {
    1183           if ((*read_import_func) (abfd, sym) == false)
    1184             return false;
     1169          if (! (*read_import_func) (abfd, sym))
     1170            return FALSE;
    11851171          sym++;
    11861172          abfd->symcount++;
     
    11881174    }
    11891175
    1190   return (true);
     1176  return TRUE;
    11911177}
    11921178
     
    12051191   section.  */
    12061192
    1207 static boolean
     1193static bfd_boolean
    12081194nlm_slurp_reloc_fixups (abfd)
    12091195     bfd *abfd;
    12101196{
    1211   boolean (*read_func) PARAMS ((bfd *, nlm_symbol_type *, asection **,
    1212                                 arelent *));
    1213   bfd_size_type count;
     1197  bfd_boolean (*read_func)
     1198    PARAMS ((bfd *, nlm_symbol_type *, asection **, arelent *));
     1199  bfd_size_type count, amt;
    12141200  arelent *rels;
    12151201  asection **secs;
    12161202
    12171203  if (nlm_relocation_fixups (abfd) != NULL)
    1218     return true;
     1204    return TRUE;
    12191205  read_func = nlm_read_reloc_func (abfd);
    12201206  if (read_func == NULL)
    1221     return true;
     1207    return TRUE;
    12221208
    12231209  if (bfd_seek (abfd, nlm_fixed_header (abfd)->relocationFixupOffset,
    12241210                SEEK_SET) != 0)
    1225     return false;
     1211    return FALSE;
    12261212
    12271213  count = nlm_fixed_header (abfd)->numberOfRelocationFixups;
    1228   rels = (arelent *) bfd_alloc (abfd, count * sizeof (arelent));
    1229   secs = (asection **) bfd_alloc (abfd, count * sizeof (asection *));
     1214  amt = count * sizeof (arelent);
     1215  rels = (arelent *) bfd_alloc (abfd, amt);
     1216  amt = count * sizeof (asection *);
     1217  secs = (asection **) bfd_alloc (abfd, amt);
    12301218  if ((rels == NULL || secs == NULL) && count != 0)
    1231     return false;
     1219    return FALSE;
    12321220  nlm_relocation_fixups (abfd) = rels;
    12331221  nlm_relocation_fixup_secs (abfd) = secs;
     
    12371225  while (count-- != 0)
    12381226    {
    1239       if ((*read_func) (abfd, (nlm_symbol_type *) NULL, secs, rels) == false)
     1227      if (! (*read_func) (abfd, (nlm_symbol_type *) NULL, secs, rels))
    12401228        {
    12411229          nlm_relocation_fixups (abfd) = NULL;
    12421230          nlm_relocation_fixup_secs (abfd) = NULL;
    1243           return false;
     1231          return FALSE;
    12441232        }
    12451233      ++secs;
     
    12471235    }
    12481236
    1249   return true;
     1237  return TRUE;
    12501238}
    12511239
     
    12731261  if (syms == NULL)
    12741262    {
    1275       if (nlm_slurp_symbol_table (abfd) == false)
     1263      if (! nlm_slurp_symbol_table (abfd))
    12761264        return -1;
    12771265      syms = nlm_get_symbols (abfd);
     
    13081296  if (rels == NULL)
    13091297    {
    1310       if (nlm_slurp_reloc_fixups (abfd) == false)
     1298      if (! nlm_slurp_reloc_fixups (abfd))
    13111299        return -1;
    13121300      rels = nlm_relocation_fixups (abfd);
     
    13731361   final values.  */
    13741362
    1375 static boolean
     1363static bfd_boolean
    13761364nlm_compute_section_file_positions (abfd)
    13771365     bfd *abfd;
     
    13861374  asymbol **sym_ptr_ptr;
    13871375
    1388   if (abfd->output_has_begun == true)
    1389     return true;
     1376  if (abfd->output_has_begun)
     1377    return TRUE;
    13901378
    13911379  /* Make sure we have a section to hold uninitialized data.  */
     
    13961384                            (file_ptr) 0, (bfd_size_type) 0,
    13971385                            SEC_ALLOC))
    1398         return false;
     1386        return FALSE;
    13991387      bss_sec = bfd_get_section_by_name (abfd, NLM_UNINITIALIZED_DATA_NAME);
    14001388    }
    14011389
    1402   abfd->output_has_begun = true;
     1390  abfd->output_has_begun = TRUE;
    14031391
    14041392  /* The fixed header.  */
     
    15711559    }
    15721560
    1573   return true;
     1561  return TRUE;
    15741562}
    15751563
     
    15791567   variable size header information must be known.  */
    15801568
    1581 boolean
     1569bfd_boolean
    15821570nlm_set_section_contents (abfd, section, location, offset, count)
    15831571     bfd *abfd;
     
    15871575     bfd_size_type count;
    15881576{
    1589   if (abfd->output_has_begun == false
    1590       && nlm_compute_section_file_positions (abfd) == false)
    1591     return false;
     1577  if (! abfd->output_has_begun
     1578      && ! nlm_compute_section_file_positions (abfd))
     1579    return FALSE;
    15921580
    15931581  if (count == 0)
    1594     return true;
     1582    return TRUE;
    15951583
    15961584  /* i386 NetWare has a very restricted set of relocs.  In order for
     
    16001588  if (section->reloc_count != 0)
    16011589    {
    1602       boolean (*mangle_relocs_func) PARAMS ((bfd *, asection *, PTR,
    1603                                             bfd_vma, bfd_size_type));
     1590      bfd_boolean (*mangle_relocs_func)
     1591        PARAMS ((bfd *, asection *, PTR, bfd_vma, bfd_size_type));
    16041592
    16051593      mangle_relocs_func = nlm_mangle_relocs_func (abfd);
     
    16081596          if (!(*mangle_relocs_func) (abfd, section, location,
    16091597                                      (bfd_vma) offset, count))
    1610             return false;
    1611         }
    1612     }
    1613 
    1614   if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0
    1615       || bfd_write (location, 1, count, abfd) != count)
    1616     return false;
    1617 
    1618   return true;
     1598            return FALSE;
     1599        }
     1600    }
     1601
     1602  if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0
     1603      || bfd_bwrite (location, count, abfd) != count)
     1604    return FALSE;
     1605
     1606  return TRUE;
    16191607}
    16201608
     
    16701658   list of outsymbols.  */
    16711659
    1672 boolean
     1660bfd_boolean
    16731661nlm_write_object_contents (abfd)
    16741662     bfd *abfd;
    16751663{
    16761664  asection *sec;
    1677   boolean (*write_import_func) PARAMS ((bfd *, asection *, arelent *));
     1665  bfd_boolean (*write_import_func) PARAMS ((bfd *, asection *, arelent *));
    16781666  bfd_size_type external_reloc_count, internal_reloc_count, i, c;
    16791667  struct reloc_and_sec *external_relocs;
    16801668  asymbol **sym_ptr_ptr;
    16811669  file_ptr last;
    1682   boolean (*write_prefix_func) PARAMS ((bfd *));
     1670  bfd_boolean (*write_prefix_func) PARAMS ((bfd *));
    16831671  unsigned char *fixed_header = NULL;
     1672  file_ptr pos;
     1673  bfd_size_type amt;
    16841674
    16851675  fixed_header = ((unsigned char *)
    1686                   bfd_malloc ((size_t) nlm_fixed_header_size (abfd)));
     1676                  bfd_malloc (nlm_fixed_header_size (abfd)));
    16871677  if (fixed_header == NULL)
    16881678    goto error_return;
    16891679
    1690   if (abfd->output_has_begun == false
    1691       && nlm_compute_section_file_positions (abfd) == false)
     1680  if (! abfd->output_has_begun
     1681      && ! nlm_compute_section_file_positions (abfd))
    16921682    goto error_return;
    16931683
    16941684  /* Write out the variable length headers.  */
    1695   if (bfd_seek (abfd,
    1696              nlm_optional_prefix_size (abfd) + nlm_fixed_header_size (abfd),
    1697                 SEEK_SET) != 0)
     1685  pos = nlm_optional_prefix_size (abfd) + nlm_fixed_header_size (abfd);
     1686  if (bfd_seek (abfd, pos, SEEK_SET) != 0)
    16981687    goto error_return;
    1699   if (nlm_swap_variable_header_out (abfd) == false
    1700       || nlm_swap_auxiliary_headers_out (abfd) == false)
     1688  if (! nlm_swap_variable_header_out (abfd)
     1689      || ! nlm_swap_auxiliary_headers_out (abfd))
    17011690    {
    17021691      bfd_set_error (bfd_error_system_call);
     
    17061695  /* A weak check on whether the section file positions were
    17071696     reasonable.  */
    1708   if (bfd_tell (abfd) > nlm_fixed_header (abfd)->codeImageOffset)
     1697  if (bfd_tell (abfd) > (ufile_ptr) nlm_fixed_header (abfd)->codeImageOffset)
    17091698    {
    17101699      bfd_set_error (bfd_error_invalid_operation);
     
    17591748            {
    17601749              ++internal_reloc_count;
    1761               if ((*write_import_func) (abfd, sec, rel) == false)
     1750              if (! (*write_import_func) (abfd, sec, rel))
    17621751                goto error_return;
    17631752            }
     
    17721761     symbol, so we must first gather together all the relocs against
    17731762     external symbols and sort them.  */
    1774   external_relocs =
    1775     (struct reloc_and_sec *) bfd_alloc (abfd,
    1776                                         (external_reloc_count
    1777                                          * sizeof (struct reloc_and_sec)));
     1763  amt = external_reloc_count * sizeof (struct reloc_and_sec);
     1764  external_relocs = (struct reloc_and_sec *) bfd_alloc (abfd, amt);
    17781765  if (external_relocs == (struct reloc_and_sec *) NULL)
    17791766    goto error_return;
     
    18331820        ++cnt;
    18341821
    1835       if ((*nlm_write_external_func (abfd)) (abfd, cnt, sym,
    1836                                              &external_relocs[i])
    1837           == false)
     1822      if (! (*nlm_write_external_func (abfd)) (abfd, cnt, sym,
     1823                                               &external_relocs[i]))
    18381824        goto error_return;
    18391825
     
    18481834    {
    18491835      bfd_vma (*get_public_offset_func) PARAMS ((bfd *, asymbol *));
    1850       boolean (*write_export_func) PARAMS ((bfd *, asymbol *, bfd_vma));
     1836      bfd_boolean (*write_export_func) PARAMS ((bfd *, asymbol *, bfd_vma));
    18511837
    18521838      asymbol **sym_end;
     
    19031889          if (write_export_func)
    19041890            {
    1905               if ((*write_export_func) (abfd, sym, offset) == false)
     1891              if (! (*write_export_func) (abfd, sym, offset))
    19061892                goto error_return;
    19071893            }
     
    19091895            {
    19101896              len = strlen (sym->name);
    1911               if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd)
     1897              if ((bfd_bwrite (&len, (bfd_size_type) sizeof (bfd_byte), abfd)
    19121898                   != sizeof (bfd_byte))
    1913                   || bfd_write (sym->name, len, 1, abfd) != len)
     1899                  || bfd_bwrite (sym->name, (bfd_size_type) len, abfd) != len)
    19141900                goto error_return;
    19151901
    19161902              put_word (abfd, offset, temp);
    1917               if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
     1903              if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd)
     1904                  != sizeof (temp))
    19181905                goto error_return;
    19191906            }
     
    19741961
    19751962              /* The type is 0 for data, 1 for code, 2 for absolute.  */
    1976               if (bfd_write (&type, sizeof (bfd_byte), 1, abfd)
     1963              if (bfd_bwrite (&type, (bfd_size_type) sizeof (bfd_byte), abfd)
    19771964                  != sizeof (bfd_byte))
    19781965                goto error_return;
    19791966
    19801967              put_word (abfd, offset, temp);
    1981               if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
     1968              if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd)
     1969                  != sizeof (temp))
    19821970                goto error_return;
    19831971
    19841972              len = strlen (sym->name);
    1985               if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd)
     1973              if ((bfd_bwrite (&len, (bfd_size_type) sizeof (bfd_byte), abfd)
    19861974                   != sizeof (bfd_byte))
    1987                   || bfd_write (sym->name, len, 1, abfd) != len)
     1975                  || bfd_bwrite (sym->name, (bfd_size_type) len, abfd) != len)
    19881976                goto error_return;
    19891977            }
     
    20292017      nlm_get_text_low (abfd);
    20302018
    2031   if (bfd_seek (abfd, 0, SEEK_SET) != 0)
     2019  if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
    20322020    goto error_return;
    20332021
     
    20352023  if (write_prefix_func)
    20362024    {
    2037       if ((*write_prefix_func) (abfd) == false)
     2025      if (! (*write_prefix_func) (abfd))
    20382026        goto error_return;
    20392027    }
     
    20432031
    20442032  nlm_swap_fixed_header_out (abfd, nlm_fixed_header (abfd), fixed_header);
    2045   if (bfd_write (fixed_header, nlm_fixed_header_size (abfd), 1, abfd)
     2033  if (bfd_bwrite (fixed_header, nlm_fixed_header_size (abfd), abfd)
    20462034      != nlm_fixed_header_size (abfd))
    20472035    goto error_return;
     
    20492037  if (fixed_header != NULL)
    20502038    free (fixed_header);
    2051   return true;
     2039  return TRUE;
    20522040
    20532041error_return:
    20542042  if (fixed_header != NULL)
    20552043    free (fixed_header);
    2056   return false;
     2044  return FALSE;
    20572045}
Note: See TracChangeset for help on using the changeset viewer.