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

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* Generic BFD library interface and support routines.
    22   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
    3    2000, 2001
     3   2000, 2001, 2002, 2003
    44   Free Software Foundation, Inc.
    55   Written by Cygnus Support.
    66
    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.  */
     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.  */
    2222
    2323/*
     
    3535CODE_FRAGMENT
    3636.
    37 .struct _bfd
     37.struct bfd
    3838.{
    39 .    {* The filename the application opened the BFD with.  *}
    40 .    CONST char *filename;
    41 .
    42 .    {* A pointer to the target jump table.             *}
    43 .    const struct bfd_target *xvec;
    44 .
    45 .    {* To avoid dragging too many header files into every file that
    46 .       includes `<<bfd.h>>', IOSTREAM has been declared as a "char
    47 .       *", and MTIME as a "long".  Their correct types, to which they
    48 .       are cast when used, are "FILE *" and "time_t".    The iostream
    49 .       is the result of an fopen on the filename.  However, if the
    50 .       BFD_IN_MEMORY flag is set, then iostream is actually a pointer
    51 .       to a bfd_in_memory struct.  *}
    52 .    PTR iostream;
    53 .
    54 .    {* Is the file descriptor being cached?  That is, can it be closed as
    55 .       needed, and re-opened when accessed later?  *}
    56 .
    57 .    boolean cacheable;
    58 .
    59 .    {* Marks whether there was a default target specified when the
    60 .       BFD was opened. This is used to select which matching algorithm
    61 .       to use to choose the back end. *}
    62 .
    63 .    boolean target_defaulted;
    64 .
    65 .    {* The caching routines use these to maintain a
    66 .       least-recently-used list of BFDs *}
    67 .
    68 .    struct _bfd *lru_prev, *lru_next;
    69 .
    70 .    {* When a file is closed by the caching routines, BFD retains
    71 .       state information on the file here: *}
    72 .
    73 .    file_ptr where;
    74 .
    75 .    {* and here: (``once'' means at least once) *}
    76 .
    77 .    boolean opened_once;
    78 .
    79 .    {* Set if we have a locally maintained mtime value, rather than
    80 .       getting it from the file each time: *}
    81 .
    82 .    boolean mtime_set;
    83 .
    84 .    {* File modified time, if mtime_set is true: *}
    85 .
    86 .    long mtime;
    87 .
    88 .    {* Reserved for an unimplemented file locking extension.*}
    89 .
    90 .    int ifd;
    91 .
    92 .    {* The format which belongs to the BFD. (object, core, etc.) *}
    93 .
    94 .    bfd_format format;
    95 .
    96 .    {* The direction the BFD was opened with*}
    97 .
    98 .    enum bfd_direction {no_direction = 0,
    99 .                        read_direction = 1,
    100 .                        write_direction = 2,
    101 .                        both_direction = 3} direction;
    102 .
    103 .    {* Format_specific flags*}
    104 .
    105 .    flagword flags;
    106 .
    107 .    {* Currently my_archive is tested before adding origin to
    108 .       anything. I believe that this can become always an add of
    109 .       origin, with origin set to 0 for non archive files.   *}
    110 .
    111 .    file_ptr origin;
    112 .
    113 .    {* Remember when output has begun, to stop strange things
    114 .       from happening. *}
    115 .    boolean output_has_begun;
    116 .
    117 .    {* Pointer to linked list of sections*}
    118 .    struct sec  *sections;
    119 .
    120 .    {* The number of sections *}
    121 .    unsigned int section_count;
    122 .
    123 .    {* Stuff only useful for object files:
    124 .       The start address. *}
    125 .    bfd_vma start_address;
    126 .
    127 .    {* Used for input and output*}
    128 .    unsigned int symcount;
    129 .
    130 .    {* Symbol table for output BFD (with symcount entries) *}
    131 .    struct symbol_cache_entry  **outsymbols;
    132 .
    133 .    {* Pointer to structure which contains architecture information*}
    134 .    const struct bfd_arch_info *arch_info;
    135 .
    136 .    {* Stuff only useful for archives:*}
    137 .    PTR arelt_data;
    138 .    struct _bfd *my_archive;     {* The containing archive BFD.  *}
    139 .    struct _bfd *next;           {* The next BFD in the archive.  *}
    140 .    struct _bfd *archive_head;   {* The first BFD in the archive.  *}
    141 .    boolean has_armap;
    142 .
    143 .    {* A chain of BFD structures involved in a link.  *}
    144 .    struct _bfd *link_next;
    145 .
    146 .    {* A field used by _bfd_generic_link_add_archive_symbols.  This will
    147 .       be used only for archive elements.  *}
    148 .    int archive_pass;
    149 .
    150 .    {* Used by the back end to hold private data. *}
    151 .
    152 .    union
    153 .      {
     39.  {* A unique identifier of the BFD  *}
     40.  unsigned int id;
     41.
     42.  {* The filename the application opened the BFD with.  *}
     43.  const char *filename;
     44.
     45.  {* A pointer to the target jump table.  *}
     46.  const struct bfd_target *xvec;
     47.
     48.  {* To avoid dragging too many header files into every file that
     49.     includes `<<bfd.h>>', IOSTREAM has been declared as a "char *",
     50.     and MTIME as a "long".  Their correct types, to which they
     51.     are cast when used, are "FILE *" and "time_t".    The iostream
     52.     is the result of an fopen on the filename.  However, if the
     53.     BFD_IN_MEMORY flag is set, then iostream is actually a pointer
     54.     to a bfd_in_memory struct.  *}
     55.  PTR iostream;
     56.
     57.  {* Is the file descriptor being cached?  That is, can it be closed as
     58.     needed, and re-opened when accessed later?  *}
     59.  bfd_boolean cacheable;
     60.
     61.  {* Marks whether there was a default target specified when the
     62.     BFD was opened. This is used to select which matching algorithm
     63.     to use to choose the back end.  *}
     64.  bfd_boolean target_defaulted;
     65.
     66.  {* The caching routines use these to maintain a
     67.     least-recently-used list of BFDs.  *}
     68.  struct bfd *lru_prev, *lru_next;
     69.
     70.  {* When a file is closed by the caching routines, BFD retains
     71.     state information on the file here...  *}
     72.  ufile_ptr where;
     73.
     74.  {* ... and here: (``once'' means at least once).  *}
     75.  bfd_boolean opened_once;
     76.
     77.  {* Set if we have a locally maintained mtime value, rather than
     78.     getting it from the file each time.  *}
     79.  bfd_boolean mtime_set;
     80.
     81.  {* File modified time, if mtime_set is TRUE.  *}
     82.  long mtime;
     83.
     84.  {* Reserved for an unimplemented file locking extension.  *}
     85.  int ifd;
     86.
     87.  {* The format which belongs to the BFD. (object, core, etc.)  *}
     88.  bfd_format format;
     89.
     90.  {* The direction with which the BFD was opened.  *}
     91.  enum bfd_direction
     92.    {
     93.      no_direction = 0,
     94.      read_direction = 1,
     95.      write_direction = 2,
     96.      both_direction = 3
     97.    }
     98.  direction;
     99.
     100.  {* Format_specific flags.  *}
     101.  flagword flags;
     102.
     103.  {* Currently my_archive is tested before adding origin to
     104.     anything. I believe that this can become always an add of
     105.     origin, with origin set to 0 for non archive files.  *}
     106.  ufile_ptr origin;
     107.
     108.  {* Remember when output has begun, to stop strange things
     109.     from happening.  *}
     110.  bfd_boolean output_has_begun;
     111.
     112.  {* A hash table for section names.  *}
     113.  struct bfd_hash_table section_htab;
     114.
     115.  {* Pointer to linked list of sections.  *}
     116.  struct sec *sections;
     117.
     118.  {* The place where we add to the section list.  *}
     119.  struct sec **section_tail;
     120.
     121.  {* The number of sections.  *}
     122.  unsigned int section_count;
     123.
     124.  {* Stuff only useful for object files:
     125.     The start address.  *}
     126.  bfd_vma start_address;
     127.
     128.  {* Used for input and output.  *}
     129.  unsigned int symcount;
     130.
     131.  {* Symbol table for output BFD (with symcount entries).  *}
     132.  struct symbol_cache_entry  **outsymbols;
     133.
     134.  {* Used for slurped dynamic symbol tables.  *}
     135.  unsigned int dynsymcount;
     136.
     137.  {* Pointer to structure which contains architecture information.  *}
     138.  const struct bfd_arch_info *arch_info;
     139.
     140.  {* Stuff only useful for archives.  *}
     141.  PTR arelt_data;
     142.  struct bfd *my_archive;      {* The containing archive BFD.  *}
     143.  struct bfd *next;            {* The next BFD in the archive.  *}
     144.  struct bfd *archive_head;    {* The first BFD in the archive.  *}
     145.  bfd_boolean has_armap;
     146.
     147.  {* A chain of BFD structures involved in a link.  *}
     148.  struct bfd *link_next;
     149.
     150.  {* A field used by _bfd_generic_link_add_archive_symbols.  This will
     151.     be used only for archive elements.  *}
     152.  int archive_pass;
     153.
     154.  {* Used by the back end to hold private data.  *}
     155.  union
     156.    {
    154157.      struct aout_data_struct *aout_data;
    155158.      struct artdata *aout_ar_data;
     
    168171.      struct nlm_obj_tdata *nlm_obj_data;
    169172.      struct bout_data_struct *bout_data;
     173.      struct mmo_data_struct *mmo_data;
    170174.      struct sun_core_struct *sun_core_data;
    171175.      struct sco5_core_struct *sco5_core_data;
     
    180184.      struct versados_data_struct *versados_data;
    181185.      struct netbsd_core_struct *netbsd_core_data;
     186.      struct mach_o_data_struct *mach_o_data;
     187.      struct mach_o_fat_data_struct *mach_o_fat_data;
     188.      struct bfd_pef_data_struct *pef_data;
     189.      struct bfd_pef_xlib_data_struct *pef_xlib_data;
     190.      struct bfd_sym_data_struct *sym_data;
    182191.      PTR any;
    183 .      } tdata;
    184 .
    185 .    {* Used by the application to hold private data*}
    186 .    PTR usrdata;
     192.    }
     193.  tdata;
     194.
     195.  {* Used by the application to hold private data.  *}
     196.  PTR usrdata;
    187197.
    188198.  {* Where all the allocated stuff under this BFD goes.  This is a
    189199.     struct objalloc *, but we use PTR to avoid requiring the inclusion of
    190200.     objalloc.h.  *}
    191   PTR memory;
     201PTR memory;
    192202.};
    193203.
     
    195205
    196206#include "bfd.h"
     207#include "bfdver.h"
    197208#include "sysdep.h"
    198209
     
    204215
    205216#include "libiberty.h"
     217#include "safe-ctype.h"
    206218#include "bfdlink.h"
    207219#include "libbfd.h"
     
    213225#include "elf-bfd.h"
    214226
    215 #include <ctype.h>
    216 
    217227
    218228/* provide storage for subsystem, stack and heap data which may have been
     
    251261.  bfd_error_invalid_target,
    252262.  bfd_error_wrong_format,
     263.  bfd_error_wrong_object_format,
    253264.  bfd_error_invalid_operation,
    254265.  bfd_error_no_memory,
     
    266277.  bfd_error_file_too_big,
    267278.  bfd_error_invalid_error_code
    268 .} bfd_error_type;
     279.}
     280.bfd_error_type;
    269281.
    270282*/
     
    272284static bfd_error_type bfd_error = bfd_error_no_error;
    273285
    274 CONST char *CONST bfd_errmsgs[] = {
    275                         N_("No error"),
    276                         N_("System call error"),
    277                         N_("Invalid bfd target"),
    278                         N_("File in wrong format"),
    279                         N_("Invalid operation"),
    280                         N_("Memory exhausted"),
    281                         N_("No symbols"),
    282                         N_("Archive has no index; run ranlib to add one"),
    283                         N_("No more archived files"),
    284                         N_("Malformed archive"),
    285                         N_("File format not recognized"),
    286                         N_("File format is ambiguous"),
    287                         N_("Section has no contents"),
    288                         N_("Nonrepresentable section on output"),
    289                         N_("Symbol needs debug section which does not exist"),
    290                         N_("Bad value"),
    291                         N_("File truncated"),
    292                         N_("File too big"),
    293                         N_("#<Invalid error code>")
    294                        };
     286const char *const bfd_errmsgs[] =
     287{
     288  N_("No error"),
     289  N_("System call error"),
     290  N_("Invalid bfd target"),
     291  N_("File in wrong format"),
     292  N_("Archive object file in wrong format"),
     293  N_("Invalid operation"),
     294  N_("Memory exhausted"),
     295  N_("No symbols"),
     296  N_("Archive has no index; run ranlib to add one"),
     297  N_("No more archived files"),
     298  N_("Malformed archive"),
     299  N_("File format not recognized"),
     300  N_("File format is ambiguous"),
     301  N_("Section has no contents"),
     302  N_("Nonrepresentable section on output"),
     303  N_("Symbol needs debug section which does not exist"),
     304  N_("Bad value"),
     305  N_("File truncated"),
     306  N_("File too big"),
     307  N_("#<Invalid error code>")
     308};
    295309
    296310/*
     
    334348
    335349SYNOPSIS
    336         CONST char *bfd_errmsg (bfd_error_type error_tag);
     350        const char *bfd_errmsg (bfd_error_type error_tag);
    337351
    338352DESCRIPTION
     
    341355*/
    342356
    343 CONST char *
     357const char *
    344358bfd_errmsg (error_tag)
    345359     bfd_error_type error_tag;
     
    351365    return xstrerror (errno);
    352366
    353   if ((((int)error_tag <(int) bfd_error_no_error) ||
    354        ((int)error_tag > (int)bfd_error_invalid_error_code)))
     367  if ((((int) error_tag < (int) bfd_error_no_error) ||
     368       ((int) error_tag > (int) bfd_error_invalid_error_code)))
    355369    error_tag = bfd_error_invalid_error_code;/* sanity check */
    356370
     
    363377
    364378SYNOPSIS
    365         void bfd_perror (CONST char *message);
     379        void bfd_perror (const char *message);
    366380
    367381DESCRIPTION
     
    375389void
    376390bfd_perror (message)
    377      CONST char *message;
     391     const char *message;
    378392{
    379393  if (bfd_get_error () == bfd_error_system_call)
    380     perror((char *)message);            /* must be system error then...  */
    381   else {
    382     if (message == NULL || *message == '\0')
    383       fprintf (stderr, "%s\n", bfd_errmsg (bfd_get_error ()));
    384     else
    385       fprintf (stderr, "%s: %s\n", message, bfd_errmsg (bfd_get_error ()));
    386   }
     394    /* Must be a system error then.  */
     395    perror ((char *)message);
     396  else
     397    {
     398      if (message == NULL || *message == '\0')
     399        fprintf (stderr, "%s\n", bfd_errmsg (bfd_get_error ()));
     400      else
     401        fprintf (stderr, "%s: %s\n", message, bfd_errmsg (bfd_get_error ()));
     402    }
    387403}
    388404
     
    409425/* This is the default routine to handle BFD error messages.  */
    410426
    411 #ifdef ANSI_PROTOTYPES
    412 
    413427static void _bfd_default_error_handler PARAMS ((const char *s, ...));
    414428
    415429static void
    416 _bfd_default_error_handler (const char *s, ...)
    417 {
    418   va_list p;
    419 
     430_bfd_default_error_handler VPARAMS ((const char *s, ...))
     431{
    420432  if (_bfd_error_program_name != NULL)
    421433    fprintf (stderr, "%s: ", _bfd_error_program_name);
     
    423435    fprintf (stderr, "BFD: ");
    424436
    425   va_start (p, s);
    426 
     437  VA_OPEN (p, s);
     438  VA_FIXEDARG (p, const char *, s);
    427439  vfprintf (stderr, s, p);
    428 
    429   va_end (p);
     440  VA_CLOSE (p);
    430441
    431442  fprintf (stderr, "\n");
    432443}
    433 
    434 #else /* ! defined (ANSI_PROTOTYPES) */
    435 
    436 static void _bfd_default_error_handler ();
    437 
    438 static void
    439 _bfd_default_error_handler (va_alist)
    440      va_dcl
    441 {
    442   va_list p;
    443   const char *s;
    444 
    445   if (_bfd_error_program_name != NULL)
    446     fprintf (stderr, "%s: ", _bfd_error_program_name);
    447   else
    448     fprintf (stderr, "BFD: ");
    449 
    450   va_start (p);
    451 
    452   s = va_arg (p, const char *);
    453   vfprintf (stderr, s, p);
    454 
    455   va_end (p);
    456 
    457   fprintf (stderr, "\n");
    458 }
    459 
    460 #endif /* ! defined (ANSI_PROTOTYPES) */
    461444
    462445/* This is a function pointer to the routine which should handle BFD
     
    529512}
    530513
     514/*
     515FUNCTION
     516        bfd_archive_filename
     517
     518SYNOPSIS
     519        const char *bfd_archive_filename (bfd *);
     520
     521DESCRIPTION
     522        For a BFD that is a component of an archive, returns a string
     523        with both the archive name and file name.  For other BFDs, just
     524        returns the file name.
     525*/
     526
     527const char *
     528bfd_archive_filename (abfd)
     529     bfd *abfd;
     530{
     531  if (abfd->my_archive)
     532    {
     533      static size_t curr = 0;
     534      static char *buf;
     535      size_t needed;
     536
     537      needed = (strlen (bfd_get_filename (abfd->my_archive))
     538                + strlen (bfd_get_filename (abfd)) + 3);
     539      if (needed > curr)
     540        {
     541          if (curr)
     542            free (buf);
     543          curr = needed + (needed >> 1);
     544          buf = bfd_malloc ((bfd_size_type) curr);
     545          /* If we can't malloc, fail safe by returning just the file
     546             name. This function is only used when building error
     547             messages.  */
     548          if (!buf)
     549            {
     550              curr = 0;
     551              return bfd_get_filename (abfd);
     552            }
     553        }
     554      sprintf (buf, "%s(%s)", bfd_get_filename (abfd->my_archive),
     555               bfd_get_filename (abfd));
     556      return buf;
     557    }
     558  else
     559    return bfd_get_filename (abfd);
     560}
     561
    531562
    532563/*
     
    540571
    541572SYNOPSIS
    542         long bfd_get_reloc_upper_bound(bfd *abfd, asection *sect);
     573        long bfd_get_reloc_upper_bound (bfd *abfd, asection *sect);
    543574
    544575DESCRIPTION
     
    554585     sec_ptr asect;
    555586{
    556   if (abfd->format != bfd_object) {
    557     bfd_set_error (bfd_error_invalid_operation);
    558     return -1;
    559   }
     587  if (abfd->format != bfd_object)
     588    {
     589      bfd_set_error (bfd_error_invalid_operation);
     590      return -1;
     591    }
    560592
    561593  return BFD_SEND (abfd, _get_reloc_upper_bound, (abfd, asect));
     
    593625     asymbol **symbols;
    594626{
    595   if (abfd->format != bfd_object) {
    596     bfd_set_error (bfd_error_invalid_operation);
    597     return -1;
    598   }
     627  if (abfd->format != bfd_object)
     628    {
     629      bfd_set_error (bfd_error_invalid_operation);
     630      return -1;
     631    }
     632
    599633  return BFD_SEND (abfd, _bfd_canonicalize_reloc,
    600634                   (abfd, asect, location, symbols));
     
    607641SYNOPSIS
    608642        void bfd_set_reloc
    609           (bfd *abfd, asection *sec, arelent **rel, unsigned int count)
     643          (bfd *abfd, asection *sec, arelent **rel, unsigned int count);
    610644
    611645DESCRIPTION
     
    632666
    633667SYNOPSIS
    634         boolean bfd_set_file_flags(bfd *abfd, flagword flags);
     668        bfd_boolean bfd_set_file_flags (bfd *abfd, flagword flags);
    635669
    636670DESCRIPTION
     
    647681*/
    648682
    649 boolean
     683bfd_boolean
    650684bfd_set_file_flags (abfd, flags)
    651685     bfd *abfd;
    652686     flagword flags;
    653687{
    654   if (abfd->format != bfd_object) {
    655     bfd_set_error (bfd_error_wrong_format);
    656     return false;
    657   }
    658 
    659   if (bfd_read_p (abfd)) {
    660     bfd_set_error (bfd_error_invalid_operation);
    661     return false;
    662   }
     688  if (abfd->format != bfd_object)
     689    {
     690      bfd_set_error (bfd_error_wrong_format);
     691      return FALSE;
     692    }
     693
     694  if (bfd_read_p (abfd))
     695    {
     696      bfd_set_error (bfd_error_invalid_operation);
     697      return FALSE;
     698    }
    663699
    664700  bfd_get_file_flags (abfd) = flags;
    665   if ((flags & bfd_applicable_file_flags (abfd)) != flags) {
    666     bfd_set_error (bfd_error_invalid_operation);
    667     return false;
    668   }
    669 
    670 return true;
     701  if ((flags & bfd_applicable_file_flags (abfd)) != flags)
     702    {
     703      bfd_set_error (bfd_error_invalid_operation);
     704      return FALSE;
     705    }
     706
     707  return TRUE;
    671708}
    672709
     
    676713     int line;
    677714{
    678   (*_bfd_error_handler) (_("bfd assertion fail %s:%d"), file, line);
     715  (*_bfd_error_handler) (_("BFD %s assertion fail %s:%d"),
     716                         BFD_VERSION_STRING, file, line);
    679717}
    680718
     
    694732  if (fn != NULL)
    695733    (*_bfd_error_handler)
    696       (_("BFD internal error, aborting at %s line %d in %s\n"),
    697        file, line, fn);
     734      (_("BFD %s internal error, aborting at %s line %d in %s\n"),
     735       BFD_VERSION_STRING, file, line, fn);
    698736  else
    699737    (*_bfd_error_handler)
    700       (_("BFD internal error, aborting at %s line %d\n"),
    701        file, line);
     738      (_("BFD %s internal error, aborting at %s line %d\n"),
     739       BFD_VERSION_STRING, file, line);
    702740  (*_bfd_error_handler) (_("Please report this bug.\n"));
    703741  xexit (EXIT_FAILURE);
     
    727765    return (get_elf_backend_data (abfd))->s->arch_size;
    728766
    729   bfd_set_error (bfd_error_wrong_format);
    730767  return -1;
    731768}
     
    756793     bfd *abfd;
    757794{
     795  char *name;
     796
    758797  if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
    759798    return (get_elf_backend_data (abfd)->sign_extend_vma);
    760799
     800  name = bfd_get_target (abfd);
     801
     802  /* Return a proper value for DJGPP COFF (an x86 COFF variant).
     803     This function is required for DWARF2 support, but there is
     804     no place to store this information in the COFF back end.
     805     Should enough other COFF targets add support for DWARF2,
     806     a place will have to be found.  Until then, this hack will do.  */
     807  if (strncmp (name, "coff-go32", sizeof ("coff-go32") - 1) == 0)
     808    return 1;
     809
    761810  bfd_set_error (bfd_error_wrong_format);
    762811  return -1;
     
    768817
    769818SYNOPSIS
    770         boolean bfd_set_start_address(bfd *abfd, bfd_vma vma);
     819        bfd_boolean bfd_set_start_address (bfd *abfd, bfd_vma vma);
    771820
    772821DESCRIPTION
     
    774823
    775824RETURNS
    776         Returns <<true>> on success, <<false>> otherwise.
    777 */
    778 
    779 boolean
    780 bfd_set_start_address(abfd, vma)
    781 bfd *abfd;
    782 bfd_vma vma;
     825        Returns <<TRUE>> on success, <<FALSE>> otherwise.
     826*/
     827
     828bfd_boolean
     829bfd_set_start_address (abfd, vma)
     830     bfd *abfd;
     831     bfd_vma vma;
    783832{
    784833  abfd->start_address = vma;
    785   return true;
    786 }
    787 
    788 /*
    789 FUNCTION
    790         bfd_get_mtime
    791 
    792 SYNOPSIS
    793         long bfd_get_mtime(bfd *abfd);
    794 
    795 DESCRIPTION
    796         Return the file modification time (as read from the file system, or
    797         from the archive header for archive members).
    798 
    799 */
    800 
    801 long
    802 bfd_get_mtime (abfd)
    803      bfd *abfd;
    804 {
    805   FILE *fp;
    806   struct stat buf;
    807 
    808   if (abfd->mtime_set)
    809     return abfd->mtime;
    810 
    811   fp = bfd_cache_lookup (abfd);
    812   if (0 != fstat (fileno (fp), &buf))
    813     return 0;
    814 
    815   abfd->mtime = buf.st_mtime;           /* Save value in case anyone wants it */
    816   return buf.st_mtime;
    817 }
    818 
    819 /*
    820 FUNCTION
    821         bfd_get_size
    822 
    823 SYNOPSIS
    824         long bfd_get_size(bfd *abfd);
    825 
    826 DESCRIPTION
    827         Return the file size (as read from file system) for the file
    828         associated with BFD @var{abfd}.
    829 
    830         The initial motivation for, and use of, this routine is not
    831         so we can get the exact size of the object the BFD applies to, since
    832         that might not be generally possible (archive members for example).
    833         It would be ideal if someone could eventually modify
    834         it so that such results were guaranteed.
    835 
    836         Instead, we want to ask questions like "is this NNN byte sized
    837         object I'm about to try read from file offset YYY reasonable?"
    838         As as example of where we might do this, some object formats
    839         use string tables for which the first <<sizeof (long)>> bytes of the
    840         table contain the size of the table itself, including the size bytes.
    841         If an application tries to read what it thinks is one of these
    842         string tables, without some way to validate the size, and for
    843         some reason the size is wrong (byte swapping error, wrong location
    844         for the string table, etc.), the only clue is likely to be a read
    845         error when it tries to read the table, or a "virtual memory
    846         exhausted" error when it tries to allocate 15 bazillon bytes
    847         of space for the 15 bazillon byte table it is about to read.
    848         This function at least allows us to answer the quesion, "is the
    849         size reasonable?".
    850 */
    851 
    852 long
    853 bfd_get_size (abfd)
    854      bfd *abfd;
    855 {
    856   FILE *fp;
    857   struct stat buf;
    858 
    859   if ((abfd->flags & BFD_IN_MEMORY) != 0)
    860     return ((struct bfd_in_memory *) abfd->iostream)->size;
    861 
    862   fp = bfd_cache_lookup (abfd);
    863   if (0 != fstat (fileno (fp), &buf))
    864     return 0;
    865 
    866   return buf.st_size;
     834  return TRUE;
    867835}
    868836
     
    872840
    873841SYNOPSIS
    874         int bfd_get_gp_size(bfd *abfd);
     842        unsigned int bfd_get_gp_size (bfd *abfd);
    875843
    876844DESCRIPTION
     
    880848*/
    881849
    882 int
     850unsigned int
    883851bfd_get_gp_size (abfd)
    884852     bfd *abfd;
     
    899867
    900868SYNOPSIS
    901         void bfd_set_gp_size(bfd *abfd, int i);
     869        void bfd_set_gp_size (bfd *abfd, unsigned int i);
    902870
    903871DESCRIPTION
     
    910878bfd_set_gp_size (abfd, i)
    911879     bfd *abfd;
    912      int i;
    913 {
    914   /* Don't try to set GP size on an archive or core file! */
     880     unsigned int i;
     881{
     882  /* Don't try to set GP size on an archive or core file!  */
    915883  if (abfd->format != bfd_object)
    916884    return;
     885
    917886  if (abfd->xvec->flavour == bfd_target_ecoff_flavour)
    918887    ecoff_data (abfd)->gp_size = i;
     
    929898     bfd *abfd;
    930899{
    931   if (abfd->format == bfd_object)
    932     {
    933       if (abfd->xvec->flavour == bfd_target_ecoff_flavour)
    934         return ecoff_data (abfd)->gp;
    935       else if (abfd->xvec->flavour == bfd_target_elf_flavour)
    936         return elf_gp (abfd);
    937     }
     900  if (abfd->format != bfd_object)
     901    return 0;
     902
     903  if (abfd->xvec->flavour == bfd_target_ecoff_flavour)
     904    return ecoff_data (abfd)->gp;
     905  else if (abfd->xvec->flavour == bfd_target_elf_flavour)
     906    return elf_gp (abfd);
     907
    938908  return 0;
    939909}
     
    948918  if (abfd->format != bfd_object)
    949919    return;
     920
    950921  if (abfd->xvec->flavour == bfd_target_ecoff_flavour)
    951922    ecoff_data (abfd)->gp = v;
     
    959930
    960931SYNOPSIS
    961         bfd_vma bfd_scan_vma(CONST char *string, CONST char **end, int base);
     932        bfd_vma bfd_scan_vma (const char *string, const char **end, int base);
    962933
    963934DESCRIPTION
     
    971942        in octal if a leading zero is found, otherwise in decimal.
    972943
    973         Overflow is not detected.
     944        If the value would overflow, the maximum <<bfd_vma>> value is
     945        returned.
    974946*/
    975947
    976948bfd_vma
    977949bfd_scan_vma (string, end, base)
    978      CONST char *string;
    979      CONST char **end;
     950     const char *string;
     951     const char **end;
    980952     int base;
    981953{
    982954  bfd_vma value;
    983   int digit;
     955  bfd_vma cutoff;
     956  unsigned int cutlim;
     957  int overflow;
    984958
    985959  /* Let the host do it if possible.  */
    986960  if (sizeof (bfd_vma) <= sizeof (unsigned long))
    987961    return (bfd_vma) strtoul (string, (char **) end, base);
    988 
    989   /* A negative base makes no sense, and we only need to go as high as hex.  */
    990   if ((base < 0) || (base > 16))
    991     return (bfd_vma) 0;
    992962
    993963  if (base == 0)
     
    997967          if ((string[1] == 'x') || (string[1] == 'X'))
    998968            base = 16;
    999           /* XXX should we also allow "0b" or "0B" to set base to 2? */
    1000969          else
    1001970            base = 8;
    1002971        }
     972    }
     973
     974  if ((base < 2) || (base > 36))
     975    base = 10;
     976
     977  if (base == 16
     978      && string[0] == '0'
     979      && (string[1] == 'x' || string[1] == 'X')
     980      && ISXDIGIT (string[2]))
     981    {
     982      string += 2;
     983    }
     984
     985  cutoff = (~ (bfd_vma) 0) / (bfd_vma) base;
     986  cutlim = (~ (bfd_vma) 0) % (bfd_vma) base;
     987  value = 0;
     988  overflow = 0;
     989  while (1)
     990    {
     991      unsigned int digit;
     992
     993      digit = *string;
     994      if (ISDIGIT (digit))
     995        digit = digit - '0';
     996      else if (ISALPHA (digit))
     997        digit = TOUPPER (digit) - 'A' + 10;
    1003998      else
    1004         base = 10;
     999        break;
     1000      if (digit >= (unsigned int) base)
     1001        break;
     1002      if (value > cutoff || (value == cutoff && digit > cutlim))
     1003        overflow = 1;
     1004      value = value * base + digit;
     1005      ++string;
    10051006    }
    1006   if ((base == 16) &&
    1007       (string[0] == '0') && ((string[1] == 'x') || (string[1] == 'X')))
    1008     string += 2;
    1009   /* XXX should we also skip over "0b" or "0B" if base is 2? */
    1010 
    1011 /* Speed could be improved with a table like hex_value[] in gas.  */
    1012 #define HEX_VALUE(c) \
    1013   (isxdigit ((unsigned char) c)                                 \
    1014    ? (isdigit ((unsigned char) c)                               \
    1015       ? (c - '0')                                               \
    1016       : (10 + c - (islower ((unsigned char) c) ? 'a' : 'A')))   \
    1017    : 42)
    1018 
    1019   for (value = 0; (digit = HEX_VALUE(*string)) < base; string++)
    1020     {
    1021       value = value * base + digit;
    1022     }
    1023 
    1024   if (end)
     1007
     1008  if (overflow)
     1009    value = ~ (bfd_vma) 0;
     1010
     1011  if (end != NULL)
    10251012    *end = string;
    10261013
     
    10331020
    10341021SYNOPSIS
    1035         boolean bfd_copy_private_bfd_data(bfd *ibfd, bfd *obfd);
     1022        bfd_boolean bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd);
    10361023
    10371024DESCRIPTION
    10381025        Copy private BFD information from the BFD @var{ibfd} to the
    1039         the BFD @var{obfd}.  Return <<true>> on success, <<false>> on error.
     1026        the BFD @var{obfd}.  Return <<TRUE>> on success, <<FALSE>> on error.
    10401027        Possible error returns are:
    10411028
     
    10541041
    10551042SYNOPSIS
    1056         boolean bfd_merge_private_bfd_data(bfd *ibfd, bfd *obfd);
     1043        bfd_boolean bfd_merge_private_bfd_data (bfd *ibfd, bfd *obfd);
    10571044
    10581045DESCRIPTION
    10591046        Merge private BFD information from the BFD @var{ibfd} to the
    1060         the output file BFD @var{obfd} when linking.  Return <<true>>
    1061         on success, <<false>> on error.  Possible error returns are:
     1047        the output file BFD @var{obfd} when linking.  Return <<TRUE>>
     1048        on success, <<FALSE>> on error.  Possible error returns are:
    10621049
    10631050        o <<bfd_error_no_memory>> -
     
    10751062
    10761063SYNOPSIS
    1077         boolean bfd_set_private_flags(bfd *abfd, flagword flags);
     1064        bfd_boolean bfd_set_private_flags (bfd *abfd, flagword flags);
    10781065
    10791066DESCRIPTION
    10801067        Set private BFD flag information in the BFD @var{abfd}.
    1081         Return <<true>> on success, <<false>> on error.  Possible error
     1068        Return <<TRUE>> on success, <<FALSE>> on error.  Possible error
    10821069        returns are:
    10831070
     
    10861073
    10871074.#define bfd_set_private_flags(abfd, flags) \
    1088 .     BFD_SEND (abfd, _bfd_set_private_flags, \
    1089 .               (abfd, flags))
    1090 
    1091 */
    1092 
    1093 /*
    1094 FUNCTION
    1095         stuff
    1096 
    1097 DESCRIPTION
    1098         Stuff which should be documented:
     1075.     BFD_SEND (abfd, _bfd_set_private_flags, (abfd, flags))
     1076
     1077*/
     1078
     1079/*
     1080FUNCTION
     1081        Other functions
     1082
     1083DESCRIPTION
     1084        The following functions exist but have not yet been documented.
    10991085
    11001086.#define bfd_sizeof_headers(abfd, reloc) \
    1101 .     BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc))
     1087.       BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc))
    11021088.
    11031089.#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \
    1104 .     BFD_SEND (abfd, _bfd_find_nearest_line,  (abfd, sec, syms, off, file, func, line))
    1105 .
    1106 .       {* Do these three do anything useful at all, for any back end?  *}
     1090.       BFD_SEND (abfd, _bfd_find_nearest_line, \
     1091.                 (abfd, sec, syms, off, file, func, line))
     1092.
    11071093.#define bfd_debug_info_start(abfd) \
    1108 .        BFD_SEND (abfd, _bfd_debug_info_start, (abfd))
     1094.       BFD_SEND (abfd, _bfd_debug_info_start, (abfd))
    11091095.
    11101096.#define bfd_debug_info_end(abfd) \
    1111 .        BFD_SEND (abfd, _bfd_debug_info_end, (abfd))
     1097.       BFD_SEND (abfd, _bfd_debug_info_end, (abfd))
    11121098.
    11131099.#define bfd_debug_info_accumulate(abfd, section) \
    1114 .        BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section))
    1115 .
     1100.       BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section))
    11161101.
    11171102.#define bfd_stat_arch_elt(abfd, stat) \
    1118 .        BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat))
     1103.       BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat))
    11191104.
    11201105.#define bfd_update_armap_timestamp(abfd) \
    1121 .        BFD_SEND (abfd, _bfd_update_armap_timestamp, (abfd))
     1106.       BFD_SEND (abfd, _bfd_update_armap_timestamp, (abfd))
    11221107.
    11231108.#define bfd_set_arch_mach(abfd, arch, mach)\
    1124 .        BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach))
     1109.       BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach))
    11251110.
    11261111.#define bfd_relax_section(abfd, section, link_info, again) \
     
    11301115.       BFD_SEND (abfd, _bfd_gc_sections, (abfd, link_info))
    11311116.
     1117.#define bfd_merge_sections(abfd, link_info) \
     1118.       BFD_SEND (abfd, _bfd_merge_sections, (abfd, link_info))
     1119.
     1120.#define bfd_discard_group(abfd, sec) \
     1121.       BFD_SEND (abfd, _bfd_discard_group, (abfd, sec))
     1122.
    11321123.#define bfd_link_hash_table_create(abfd) \
    11331124.       BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd))
    11341125.
     1126.#define bfd_link_hash_table_free(abfd, hash) \
     1127.       BFD_SEND (abfd, _bfd_link_hash_table_free, (hash))
     1128.
    11351129.#define bfd_link_add_symbols(abfd, info) \
    11361130.       BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info))
     1131.
     1132.#define bfd_link_just_syms(sec, info) \
     1133.       BFD_SEND (abfd, _bfd_link_just_syms, (sec, info))
    11371134.
    11381135.#define bfd_final_link(abfd, info) \
     
    11601157.       PARAMS ((bfd *, struct bfd_link_info *,
    11611158.                 struct bfd_link_order *, bfd_byte *,
    1162 .                 boolean, asymbol **));
     1159.                 bfd_boolean, asymbol **));
    11631160.
    11641161
     
    11721169     struct bfd_link_order *link_order;
    11731170     bfd_byte *data;
    1174      boolean relocateable;
     1171     bfd_boolean relocateable;
    11751172     asymbol **symbols;
    11761173{
    11771174  bfd *abfd2;
    11781175  bfd_byte *(*fn) PARAMS ((bfd *, struct bfd_link_info *,
    1179                            struct bfd_link_order *, bfd_byte *, boolean,
     1176                           struct bfd_link_order *, bfd_byte *, bfd_boolean,
    11801177                           asymbol **));
    11811178
     
    11831180    {
    11841181      abfd2 = link_order->u.indirect.section->owner;
    1185       if (abfd2 == 0)
     1182      if (abfd2 == NULL)
    11861183        abfd2 = abfd;
    11871184    }
    11881185  else
    11891186    abfd2 = abfd;
     1187
    11901188  fn = abfd2->xvec->_bfd_get_relocated_section_contents;
    11911189
     
    11951193/* Record information about an ELF program header.  */
    11961194
    1197 boolean
     1195bfd_boolean
    11981196bfd_record_phdr (abfd, type, flags_valid, flags, at_valid, at,
    11991197                 includes_filehdr, includes_phdrs, count, secs)
    12001198     bfd *abfd;
    12011199     unsigned long type;
    1202      boolean flags_valid;
     1200     bfd_boolean flags_valid;
    12031201     flagword flags;
    1204      boolean at_valid;
     1202     bfd_boolean at_valid;
    12051203     bfd_vma at;
    1206      boolean includes_filehdr;
    1207      boolean includes_phdrs;
     1204     bfd_boolean includes_filehdr;
     1205     bfd_boolean includes_phdrs;
    12081206     unsigned int count;
    12091207     asection **secs;
    12101208{
    12111209  struct elf_segment_map *m, **pm;
     1210  bfd_size_type amt;
    12121211
    12131212  if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
    1214     return true;
    1215 
    1216   m = ((struct elf_segment_map *)
    1217        bfd_alloc (abfd,
    1218                   (sizeof (struct elf_segment_map)
    1219                    + ((size_t) count - 1) * sizeof (asection *))));
     1213    return TRUE;
     1214
     1215  amt = sizeof (struct elf_segment_map);
     1216  amt += ((bfd_size_type) count - 1) * sizeof (asection *);
     1217  m = (struct elf_segment_map *) bfd_alloc (abfd, amt);
    12201218  if (m == NULL)
    1221     return false;
     1219    return FALSE;
    12221220
    12231221  m->next = NULL;
     
    12251223  m->p_flags = flags;
    12261224  m->p_paddr = at;
    1227   m->p_flags_valid = flags_valid;
    1228   m->p_paddr_valid = at_valid;
    1229   m->includes_filehdr = includes_filehdr;
    1230   m->includes_phdrs = includes_phdrs;
     1225  m->p_flags_valid = (unsigned int) flags_valid;
     1226  m->p_paddr_valid = (unsigned int) at_valid;
     1227  m->includes_filehdr = (unsigned int) includes_filehdr;
     1228  m->includes_phdrs = (unsigned int) includes_phdrs;
    12311229  m->count = count;
    12321230  if (count > 0)
     
    12371235  *pm = m;
    12381236
    1239   return true;
    1240 }
     1237  return TRUE;
     1238}
     1239
     1240void
     1241bfd_sprintf_vma (abfd, buf, value)
     1242     bfd *abfd;
     1243     char *buf;
     1244     bfd_vma value;
     1245{
     1246  if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
     1247    get_elf_backend_data (abfd)->elf_backend_sprintf_vma (abfd, buf, value);
     1248  else
     1249    sprintf_vma (buf, value);
     1250}
     1251
     1252void
     1253bfd_fprintf_vma (abfd, stream, value)
     1254     bfd *abfd;
     1255     PTR stream;
     1256     bfd_vma value;
     1257{
     1258  if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
     1259    get_elf_backend_data (abfd)->elf_backend_fprintf_vma (abfd, stream, value);
     1260  else
     1261    fprintf_vma ((FILE *) stream, value);
     1262}
     1263
     1264/*
     1265FUNCTION
     1266        bfd_alt_mach_code
     1267
     1268SYNOPSIS
     1269        bfd_boolean bfd_alt_mach_code (bfd *abfd, int alternative);
     1270
     1271DESCRIPTION
     1272
     1273        When more than one machine code number is available for the
     1274        same machine type, this function can be used to switch between
     1275        the preferred one (alternative == 0) and any others.  Currently,
     1276        only ELF supports this feature, with up to two alternate
     1277        machine codes.
     1278*/
     1279
     1280bfd_boolean
     1281bfd_alt_mach_code (abfd, alternative)
     1282     bfd *abfd;
     1283     int alternative;
     1284{
     1285  if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
     1286    {
     1287      int code;
     1288
     1289      switch (alternative)
     1290        {
     1291        case 0:
     1292          code = get_elf_backend_data (abfd)->elf_machine_code;
     1293          break;
     1294
     1295        case 1:
     1296          code = get_elf_backend_data (abfd)->elf_machine_alt1;
     1297          if (code == 0)
     1298            return FALSE;
     1299          break;
     1300
     1301        case 2:
     1302          code = get_elf_backend_data (abfd)->elf_machine_alt2;
     1303          if (code == 0)
     1304            return FALSE;
     1305          break;
     1306
     1307        default:
     1308          return FALSE;
     1309        }
     1310
     1311      elf_elfheader (abfd)->e_machine = code;
     1312
     1313      return TRUE;
     1314    }
     1315
     1316  return FALSE;
     1317}
     1318
     1319/*
     1320CODE_FRAGMENT
     1321
     1322.struct bfd_preserve
     1323.{
     1324.  PTR marker;
     1325.  PTR tdata;
     1326.  flagword flags;
     1327.  const struct bfd_arch_info *arch_info;
     1328.  struct sec *sections;
     1329.  struct sec **section_tail;
     1330.  unsigned int section_count;
     1331.  struct bfd_hash_table section_htab;
     1332.};
     1333.
     1334*/
     1335
     1336/*
     1337FUNCTION
     1338        bfd_preserve_save
     1339
     1340SYNOPSIS
     1341        bfd_boolean bfd_preserve_save (bfd *, struct bfd_preserve *);
     1342
     1343DESCRIPTION
     1344        When testing an object for compatibility with a particular
     1345        target back-end, the back-end object_p function needs to set
     1346        up certain fields in the bfd on successfully recognizing the
     1347        object.  This typically happens in a piecemeal fashion, with
     1348        failures possible at many points.  On failure, the bfd is
     1349        supposed to be restored to its initial state, which is
     1350        virtually impossible.  However, restoring a subset of the bfd
     1351        state works in practice.  This function stores the subset and
     1352        reinitializes the bfd.
     1353
     1354*/
     1355
     1356bfd_boolean
     1357bfd_preserve_save (abfd, preserve)
     1358     bfd *abfd;
     1359     struct bfd_preserve *preserve;
     1360{
     1361  preserve->tdata = abfd->tdata.any;
     1362  preserve->arch_info = abfd->arch_info;
     1363  preserve->flags = abfd->flags;
     1364  preserve->sections = abfd->sections;
     1365  preserve->section_tail = abfd->section_tail;
     1366  preserve->section_count = abfd->section_count;
     1367  preserve->section_htab = abfd->section_htab;
     1368
     1369  if (! bfd_hash_table_init (&abfd->section_htab, bfd_section_hash_newfunc))
     1370    return FALSE;
     1371
     1372  abfd->tdata.any = NULL;
     1373  abfd->arch_info = &bfd_default_arch_struct;
     1374  abfd->flags &= BFD_IN_MEMORY;
     1375  abfd->sections = NULL;
     1376  abfd->section_tail = &abfd->sections;
     1377  abfd->section_count = 0;
     1378
     1379  return TRUE;
     1380}
     1381
     1382/*
     1383FUNCTION
     1384        bfd_preserve_restore
     1385
     1386SYNOPSIS
     1387        void bfd_preserve_restore (bfd *, struct bfd_preserve *);
     1388
     1389DESCRIPTION
     1390        This function restores bfd state saved by bfd_preserve_save.
     1391        If MARKER is non-NULL in struct bfd_preserve then that block
     1392        and all subsequently bfd_alloc'd memory is freed.
     1393
     1394*/
     1395
     1396void
     1397bfd_preserve_restore (abfd, preserve)
     1398     bfd *abfd;
     1399     struct bfd_preserve *preserve;
     1400{
     1401  bfd_hash_table_free (&abfd->section_htab);
     1402
     1403  abfd->tdata.any = preserve->tdata;
     1404  abfd->arch_info = preserve->arch_info;
     1405  abfd->flags = preserve->flags;
     1406  abfd->section_htab = preserve->section_htab;
     1407  abfd->sections = preserve->sections;
     1408  abfd->section_tail = preserve->section_tail;
     1409  abfd->section_count = preserve->section_count;
     1410
     1411  /* bfd_release frees all memory more recently bfd_alloc'd than
     1412     its arg, as well as its arg.  */
     1413  if (preserve->marker != NULL)
     1414    {
     1415      bfd_release (abfd, preserve->marker);
     1416      preserve->marker = NULL;
     1417    }
     1418}
     1419
     1420/*
     1421FUNCTION
     1422        bfd_preserve_finish
     1423
     1424SYNOPSIS
     1425        void bfd_preserve_finish (bfd *, struct bfd_preserve *);
     1426
     1427DESCRIPTION
     1428        This function should be called when the bfd state saved by
     1429        bfd_preserve_save is no longer needed.  ie. when the back-end
     1430        object_p function returns with success.
     1431
     1432*/
     1433
     1434void
     1435bfd_preserve_finish (abfd, preserve)
     1436     bfd *abfd ATTRIBUTE_UNUSED;
     1437     struct bfd_preserve *preserve;
     1438{
     1439  /* It would be nice to be able to free more memory here, eg. old
     1440     tdata, but that's not possible since these blocks are sitting
     1441     inside bfd_alloc'd memory.  The section hash is on a separate
     1442     objalloc.  */
     1443  bfd_hash_table_free (&preserve->section_htab);
     1444}
Note: See TracChangeset for help on using the changeset viewer.