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

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* Generic symbol-table support for the BFD library.
    22   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
    3    2000
     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/*
     
    7575|           FAIL
    7676|
    77 |         if (storage_needed == 0) {
    78 |            return ;
    79 |         }
     77|         if (storage_needed == 0)
     78|           return;
     79|         
    8080|         symbol_table = (asymbol **) xmalloc (storage_needed);
    8181|           ...
     
    8686|           FAIL
    8787|
    88 |         for (i = 0; i < number_of_symbols; i++) {
    89 |            process_symbol (symbol_table[i]);
    90 |         }
     88|         for (i = 0; i < number_of_symbols; i++)
     89|           process_symbol (symbol_table[i]);
    9190
    9291        All storage for the symbols themselves is in an objalloc
     
    109108
    110109|       #include "bfd.h"
    111 |       main()
     110|       int main (void)
    112111|       {
    113112|         bfd *abfd;
     
    115114|         asymbol *new;
    116115|
    117 |         abfd = bfd_openw("foo","a.out-sunos-big");
    118 |         bfd_set_format(abfd, bfd_object);
    119 |         new = bfd_make_empty_symbol(abfd);
     116|         abfd = bfd_openw ("foo","a.out-sunos-big");
     117|         bfd_set_format (abfd, bfd_object);
     118|         new = bfd_make_empty_symbol (abfd);
    120119|         new->name = "dummy_symbol";
    121 |         new->section = bfd_make_section_old_way(abfd, ".text");
     120|         new->section = bfd_make_section_old_way (abfd, ".text");
    122121|         new->flags = BSF_GLOBAL;
    123122|         new->value = 0x12345;
     
    126125|         ptrs[1] = (asymbol *)0;
    127126|
    128 |         bfd_set_symtab(abfd, ptrs, 1);
    129 |         bfd_close(abfd);
     127|         bfd_set_symtab (abfd, ptrs, 1);
     128|         bfd_close (abfd);
     129|         return 0;
    130130|       }
    131131|
     
    184184.typedef struct symbol_cache_entry
    185185.{
    186 .       {* A pointer to the BFD which owns the symbol. This information
    187 .          is necessary so that a back end can work out what additional
    188 .          information (invisible to the application writer) is carried
    189 .          with the symbol.
    190 .
    191 .          This field is *almost* redundant, since you can use section->owner
    192 .          instead, except that some symbols point to the global sections
    193 .          bfd_{abs,com,und}_section.  This could be fixed by making
    194 .          these globals be per-bfd (or per-target-flavor).  FIXME. *}
    195 .
    196 .  struct _bfd *the_bfd; {* Use bfd_asymbol_bfd(sym) to access this field. *}
    197 .
    198 .       {* The text of the symbol. The name is left alone, and not copied; the
    199 .          application may not alter it. *}
    200 .  CONST char *name;
    201 .
    202 .       {* The value of the symbol.  This really should be a union of a
    203 .          numeric value with a pointer, since some flags indicate that
    204 .          a pointer to another symbol is stored here.  *}
     186.  {* A pointer to the BFD which owns the symbol. This information
     187.     is necessary so that a back end can work out what additional
     188.     information (invisible to the application writer) is carried
     189.     with the symbol.
     190.
     191.     This field is *almost* redundant, since you can use section->owner
     192.     instead, except that some symbols point to the global sections
     193.     bfd_{abs,com,und}_section.  This could be fixed by making
     194.     these globals be per-bfd (or per-target-flavor).  FIXME.  *}
     195.  struct bfd *the_bfd; {* Use bfd_asymbol_bfd(sym) to access this field.  *}
     196.
     197.  {* The text of the symbol. The name is left alone, and not copied; the
     198.     application may not alter it.  *}
     199.  const char *name;
     200.
     201.  {* The value of the symbol.  This really should be a union of a
     202.     numeric value with a pointer, since some flags indicate that
     203.     a pointer to another symbol is stored here.  *}
    205204.  symvalue value;
    206205.
    207 .       {* Attributes of a symbol: *}
    208 .
     206.  {* Attributes of a symbol.  *}
    209207.#define BSF_NO_FLAGS    0x00
    210208.
    211 .       {* The symbol has local scope; <<static>> in <<C>>. The value
    212 .          is the offset into the section of the data. *}
     209.  {* The symbol has local scope; <<static>> in <<C>>. The value
     210.     is the offset into the section of the data. *}
    213211.#define BSF_LOCAL      0x01
    214212.
    215 .       {* The symbol has global scope; initialized data in <<C>>. The
    216 .          value is the offset into the section of the data. *}
     213.  {* The symbol has global scope; initialized data in <<C>>. The
     214.     value is the offset into the section of the data. *}
    217215.#define BSF_GLOBAL     0x02
    218216.
    219 .       {* The symbol has global scope and is exported. The value is
    220 .          the offset into the section of the data. *}
    221 .#define BSF_EXPORT     BSF_GLOBAL {* no real difference *}
    222 .
    223 .       {* A normal C symbol would be one of:
    224 .          <<BSF_LOCAL>>, <<BSF_FORT_COMM>>,  <<BSF_UNDEFINED>> or
    225 .          <<BSF_GLOBAL>> *}
    226 .
    227 .       {* The symbol is a debugging record. The value has an arbitary
    228 .          meaning, unless BSF_DEBUGGING_RELOC is also set.  *}
     217.  {* The symbol has global scope and is exported. The value is
     218.     the offset into the section of the data. *}
     219.#define BSF_EXPORT     BSF_GLOBAL {* No real difference. *}
     220.
     221.  {* A normal C symbol would be one of:
     222.     <<BSF_LOCAL>>, <<BSF_FORT_COMM>>,  <<BSF_UNDEFINED>> or
     223.     <<BSF_GLOBAL>>. *}
     224.
     225.  {* The symbol is a debugging record. The value has an arbitary
     226.     meaning, unless BSF_DEBUGGING_RELOC is also set.  *}
    229227.#define BSF_DEBUGGING  0x08
    230228.
    231 .       {* The symbol denotes a function entry point.  Used in ELF,
    232 .          perhaps others someday.  *}
     229.  {* The symbol denotes a function entry point.  Used in ELF,
     230.     perhaps others someday.  *}
    233231.#define BSF_FUNCTION    0x10
    234232.
    235 .       {* Used by the linker. *}
     233.  {* Used by the linker. *}
    236234.#define BSF_KEEP        0x20
    237235.#define BSF_KEEP_G      0x40
    238236.
    239 .       {* A weak global symbol, overridable without warnings by
    240 .          a regular global symbol of the same name.  *}
     237.  {* A weak global symbol, overridable without warnings by
     238.     a regular global symbol of the same name.  *}
    241239.#define BSF_WEAK        0x80
    242240.
    243      {* This symbol was created to point to a section, e.g. ELF's
    244 .          STT_SECTION symbols.  *}
     241{* This symbol was created to point to a section, e.g. ELF's
     242.     STT_SECTION symbols.  *}
    245243.#define BSF_SECTION_SYM 0x100
    246244.
    247 .       {* The symbol used to be a common symbol, but now it is
    248 .          allocated. *}
     245.  {* The symbol used to be a common symbol, but now it is
     246.     allocated. *}
    249247.#define BSF_OLD_COMMON  0x200
    250248.
    251 .       {* The default value for common data. *}
     249.  {* The default value for common data. *}
    252250.#define BFD_FORT_COMM_DEFAULT_VALUE 0
    253251.
    254 .       {* In some files the type of a symbol sometimes alters its
    255 .          location in an output file - ie in coff a <<ISFCN>> symbol
    256 .          which is also <<C_EXT>> symbol appears where it was
    257 .          declared and not at the end of a section.  This bit is set
    258 .          by the target BFD part to convey this information. *}
    259 .
     252.  {* In some files the type of a symbol sometimes alters its
     253.     location in an output file - ie in coff a <<ISFCN>> symbol
     254.     which is also <<C_EXT>> symbol appears where it was
     255.     declared and not at the end of a section.  This bit is set
     256.     by the target BFD part to convey this information.  *}
    260257.#define BSF_NOT_AT_END    0x400
    261258.
    262 .       {* Signal that the symbol is the label of constructor section. *}
     259.  {* Signal that the symbol is the label of constructor section. *}
    263260.#define BSF_CONSTRUCTOR   0x800
    264261.
    265 .       {* Signal that the symbol is a warning symbol.  The name is a
    266 .          warning.  The name of the next symbol is the one to warn about;
    267 .          if a reference is made to a symbol with the same name as the next
    268 .          symbol, a warning is issued by the linker. *}
     262.  {* Signal that the symbol is a warning symbol.  The name is a
     263.     warning.  The name of the next symbol is the one to warn about;
     264.     if a reference is made to a symbol with the same name as the next
     265.     symbol, a warning is issued by the linker. *}
    269266.#define BSF_WARNING       0x1000
    270267.
    271 .       {* Signal that the symbol is indirect.  This symbol is an indirect
    272 .          pointer to the symbol with the same name as the next symbol. *}
     268.  {* Signal that the symbol is indirect.  This symbol is an indirect
     269.     pointer to the symbol with the same name as the next symbol. *}
    273270.#define BSF_INDIRECT      0x2000
    274271.
    275 .       {* BSF_FILE marks symbols that contain a file name.  This is used
    276 .          for ELF STT_FILE symbols.  *}
     272.  {* BSF_FILE marks symbols that contain a file name.  This is used
     273.     for ELF STT_FILE symbols.  *}
    277274.#define BSF_FILE          0x4000
    278275.
    279 .       {* Symbol is from dynamic linking information.  *}
     276.  {* Symbol is from dynamic linking information.  *}
    280277.#define BSF_DYNAMIC       0x8000
    281278.
    282      {* The symbol denotes a data object.  Used in ELF, and perhaps
    283 .          others someday.  *}
     279{* The symbol denotes a data object.  Used in ELF, and perhaps
     280.     others someday.  *}
    284281.#define BSF_OBJECT        0x10000
    285282.
    286      {* This symbol is a debugging symbol.  The value is the offset
    287 .          into the section of the data.  BSF_DEBUGGING should be set
    288 .          as well.  *}
     283{* This symbol is a debugging symbol.  The value is the offset
     284.     into the section of the data.  BSF_DEBUGGING should be set
     285.     as well.  *}
    289286.#define BSF_DEBUGGING_RELOC 0x20000
    290287.
     288.  {* This symbol is thread local.  Used in ELF.  *}
     289.#define BSF_THREAD_LOCAL  0x40000
     290.
    291291.  flagword flags;
    292292.
    293 .       {* A pointer to the section to which this symbol is
    294 .          relative.  This will always be non NULL, there are special
    295 .          sections for undefined and absolute symbols.  *}
     293.  {* A pointer to the section to which this symbol is
     294.     relative.  This will always be non NULL, there are special
     295.     sections for undefined and absolute symbols.  *}
    296296.  struct sec *section;
    297297.
    298 .       {* Back end special data.  *}
     298.  {* Back end special data.  *}
    299299.  union
    300300.    {
    301301.      PTR p;
    302302.      bfd_vma i;
    303 .    } udata;
    304 .
    305 .} asymbol;
     303.    }
     304.  udata;
     305.}
     306.asymbol;
     307.
    306308*/
    307309
     
    309311#include "sysdep.h"
    310312#include "libbfd.h"
     313#include "safe-ctype.h"
    311314#include "bfdlink.h"
    312315#include "aout/stab_gnu.h"
    313316
    314317static char coff_section_type PARAMS ((const char *));
     318static char decode_section_type PARAMS ((const struct sec *));
     319static int cmpindexentry PARAMS ((const PTR, const PTR));
    315320
    316321/*
     
    334339.#define bfd_get_symtab_upper_bound(abfd) \
    335340.     BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd))
    336 
     341.
    337342*/
    338343
     
    342347
    343348SYNOPSIS
    344         boolean bfd_is_local_label(bfd *abfd, asymbol *sym);
     349        bfd_boolean bfd_is_local_label (bfd *abfd, asymbol *sym);
    345350
    346351DESCRIPTION
    347         Return true if the given symbol @var{sym} in the BFD @var{abfd} is
    348         a compiler generated local label, else return false.
    349 */
    350 
    351 boolean
     352        Return TRUE if the given symbol @var{sym} in the BFD @var{abfd} is
     353        a compiler generated local label, else return FALSE.
     354*/
     355
     356bfd_boolean
    352357bfd_is_local_label (abfd, sym)
    353358     bfd *abfd;
    354359     asymbol *sym;
    355360{
    356   if ((sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0)
    357     return false;
     361  /* The BSF_SECTION_SYM check is needed for IA-64, where every label that
     362     starts with '.' is local.  This would accidentally catch section names
     363     if we didn't reject them here.  */
     364  if ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_SECTION_SYM)) != 0)
     365    return FALSE;
    358366  if (sym->name == NULL)
    359     return false;
     367    return FALSE;
    360368  return bfd_is_local_label_name (abfd, sym->name);
    361369}
     
    366374
    367375SYNOPSIS
    368         boolean bfd_is_local_label_name(bfd *abfd, const char *name);
     376        bfd_boolean bfd_is_local_label_name (bfd *abfd, const char *name);
    369377
    370378DESCRIPTION
    371         Return true if a symbol with the name @var{name} in the BFD
     379        Return TRUE if a symbol with the name @var{name} in the BFD
    372380        @var{abfd} is a compiler generated local label, else return
    373         false.  This just checks whether the name has the form of a
     381        FALSE.  This just checks whether the name has the form of a
    374382        local label.
    375383
    376384.#define bfd_is_local_label_name(abfd, name) \
    377385.     BFD_SEND (abfd, _bfd_is_local_label_name, (abfd, name))
     386.
    378387*/
    379388
     
    392401.     BFD_SEND (abfd, _bfd_canonicalize_symtab,\
    393402.                  (abfd, location))
    394 
     403.
    395404*/
    396405
     
    400409
    401410SYNOPSIS
    402         boolean bfd_set_symtab (bfd *abfd, asymbol **location, unsigned int count);
     411        bfd_boolean bfd_set_symtab (bfd *abfd, asymbol **location, unsigned int count);
    403412
    404413DESCRIPTION
     
    408417*/
    409418
    410 boolean
     419bfd_boolean
    411420bfd_set_symtab (abfd, location, symcount)
    412421     bfd *abfd;
     
    417426    {
    418427      bfd_set_error (bfd_error_invalid_operation);
    419       return false;
     428      return FALSE;
    420429    }
    421430
    422431  bfd_get_outsymbols (abfd) = location;
    423432  bfd_get_symcount (abfd) = symcount;
    424   return true;
     433  return TRUE;
    425434}
    426435
     
    430439
    431440SYNOPSIS
    432         void bfd_print_symbol_vandf(PTR file, asymbol *symbol);
     441        void bfd_print_symbol_vandf (bfd *abfd, PTR file, asymbol *symbol);
    433442
    434443DESCRIPTION
     
    437446*/
    438447void
    439 bfd_print_symbol_vandf (arg, symbol)
     448bfd_print_symbol_vandf (abfd, arg, symbol)
     449     bfd *abfd;
    440450     PTR arg;
    441451     asymbol *symbol;
    442452{
    443453  FILE *file = (FILE *) arg;
     454
    444455  flagword type = symbol->flags;
     456
    445457  if (symbol->section != (asection *) NULL)
    446     {
    447       fprintf_vma (file, symbol->value + symbol->section->vma);
    448     }
     458    bfd_fprintf_vma (abfd, file,
     459                     symbol->value + symbol->section->vma);
    449460  else
    450     {
    451       fprintf_vma (file, symbol->value);
    452     }
     461    bfd_fprintf_vma (abfd, file, symbol->value);
    453462
    454463  /* This presumes that a symbol can not be both BSF_DEBUGGING and
     
    486495.#define bfd_make_empty_symbol(abfd) \
    487496.     BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd))
    488 */
     497.
     498*/
     499
     500/*
     501FUNCTION
     502        _bfd_generic_make_empty_symbol
     503
     504SYNOPSIS
     505        asymbol * _bfd_generic_make_empty_symbol (bfd *);
     506
     507DESCRIPTION
     508        Create a new <<asymbol>> structure for the BFD @var{abfd}
     509        and return a pointer to it.  Used by core file routines,
     510        binary back-end and anywhere else where no private info
     511        is needed.
     512*/
     513
     514asymbol *
     515_bfd_generic_make_empty_symbol (abfd)
     516     bfd *abfd;
     517{
     518  bfd_size_type amt = sizeof (asymbol);
     519  asymbol *new = (asymbol *) bfd_zalloc (abfd, amt);
     520  if (new)
     521    new->the_bfd = abfd;
     522  return new;
     523}
    489524
    490525/*
     
    499534.#define bfd_make_debug_symbol(abfd,ptr,size) \
    500535.        BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size))
     536.
    501537*/
    502538
    503539struct section_to_type
    504540{
    505   CONST char *section;
     541  const char *section;
    506542  char type;
    507543};
     
    510546   This table is probably incomplete.  It is sorted for convenience of
    511547   adding entries.  Since it is so short, a linear search is used.  */
    512 static CONST struct section_to_type stt[] =
    513 {
     548static const struct section_to_type stt[] =
     549{
     550  {".bss", 'b'},
     551  {"code", 't'},                /* MRI .text */
     552  {".data", 'd'},
    514553  {"*DEBUG*", 'N'},
    515   {".bss", 'b'},
    516   {"zerovars", 'b'},            /* MRI .bss */
    517   {".data", 'd'},
    518   {"vars", 'd'},                /* MRI .data */
     554  {".debug", 'N'},              /* MSVC's .debug (non-standard debug syms) */
     555  {".drectve", 'i'},            /* MSVC's .drective section */
     556  {".edata", 'e'},              /* MSVC's .edata (export) section */
     557  {".fini", 't'},               /* ELF fini section */
     558  {".idata", 'i'},              /* MSVC's .idata (import) section */
     559  {".init", 't'},               /* ELF init section */
     560  {".pdata", 'p'},              /* MSVC's .pdata (stack unwind) section */
    519561  {".rdata", 'r'},              /* Read only data.  */
    520562  {".rodata", 'r'},             /* Read only data.  */
     
    523565  {".sdata", 'g'},              /* Small initialized data.  */
    524566  {".text", 't'},
    525   {"code", 't'},                /* MRI .text */
    526   {".drectve", 'i'},            /* MSVC's .drective section */
    527   {".idata", 'i'},              /* MSVC's .idata (import) section */
    528   {".edata", 'e'},              /* MSVC's .edata (export) section */
    529   {".pdata", 'p'},              /* MSVC's .pdata (stack unwind) section */
    530   {".debug", 'N'},              /* MSVC's .debug (non-standard debug syms) */
     567  {"vars", 'd'},                /* MRI .data */
     568  {"zerovars", 'b'},            /* MRI .bss */
    531569  {0, 0}
    532570};
     
    542580     const char *s;
    543581{
    544   CONST struct section_to_type *t;
     582  const struct section_to_type *t;
    545583
    546584  for (t = &stt[0]; t->section; t++)
     
    551589}
    552590
    553 #ifndef islower
    554 #define islower(c) ((c) >= 'a' && (c) <= 'z')
    555 #endif
    556 #ifndef toupper
    557 #define toupper(c) (islower(c) ? ((c) & ~0x20) : (c))
    558 #endif
     591/* Return the single-character symbol type corresponding to section
     592   SECTION, or '?' for an unknown section.  This uses section flags to
     593   identify sections.
     594
     595   FIXME These types are unhandled: c, i, e, p.  If we handled these also,
     596   we could perhaps obsolete coff_section_type.  */
     597
     598static char
     599decode_section_type (section)
     600     const struct sec *section;
     601{
     602  if (section->flags & SEC_CODE)
     603    return 't';
     604  if (section->flags & SEC_DATA)
     605    {
     606      if (section->flags & SEC_READONLY)
     607        return 'r';
     608      else if (section->flags & SEC_SMALL_DATA)
     609        return 'g';
     610      else
     611        return 'd';
     612    }
     613  if ((section->flags & SEC_HAS_CONTENTS) == 0)
     614    {
     615      if (section->flags & SEC_SMALL_DATA)
     616        return 's';
     617      else
     618        return 'b';
     619    }
     620  if (section->flags & SEC_DEBUGGING)
     621    return 'N';
     622
     623  return '?';
     624}
    559625
    560626/*
     
    567633
    568634SYNOPSIS
    569         int bfd_decode_symclass(asymbol *symbol);
     635        int bfd_decode_symclass (asymbol *symbol);
    570636*/
    571637int
     
    608674    c = 'a';
    609675  else if (symbol->section)
    610     c = coff_section_type (symbol->section->name);
     676    {
     677      c = coff_section_type (symbol->section->name);
     678      if (c == '?')
     679        c = decode_section_type (symbol->section);
     680    }
    611681  else
    612682    return '?';
    613683  if (symbol->flags & BSF_GLOBAL)
    614     c = toupper (c);
     684    c = TOUPPER (c);
    615685  return c;
    616686
     
    635705
    636706SYNOPSIS
    637         boolean bfd_is_undefined_symclass (int symclass);
    638 */
    639 
    640 boolean
     707        bfd_boolean bfd_is_undefined_symclass (int symclass);
     708*/
     709
     710bfd_boolean
    641711bfd_is_undefined_symclass (symclass)
    642712     int symclass;
     
    655725
    656726SYNOPSIS
    657         void bfd_symbol_info(asymbol *symbol, symbol_info *ret);
     727        void bfd_symbol_info (asymbol *symbol, symbol_info *ret);
    658728*/
    659729
     
    678748
    679749SYNOPSIS
    680         boolean bfd_copy_private_symbol_data(bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym);
     750        bfd_boolean bfd_copy_private_symbol_data (bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym);
    681751
    682752DESCRIPTION
    683753        Copy private symbol information from @var{isym} in the BFD
    684754        @var{ibfd} to the symbol @var{osym} in the BFD @var{obfd}.
    685         Return <<true>> on success, <<false>> on error.  Possible error
     755        Return <<TRUE>> on success, <<FALSE>> on error.  Possible error
    686756        returns are:
    687757
     
    692762.     BFD_SEND (obfd, _bfd_copy_private_symbol_data, \
    693763.               (ibfd, isymbol, obfd, osymbol))
    694 
     764.
    695765*/
    696766
     
    702772_bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep)
    703773     bfd *abfd;
    704      boolean dynamic;
     774     bfd_boolean dynamic;
    705775     PTR *minisymsp;
    706776     unsigned int *sizep;
     
    716786  if (storage < 0)
    717787    goto error_return;
    718 
    719   syms = (asymbol **) bfd_malloc ((size_t) storage);
     788  if (storage == 0)
     789    return 0;
     790
     791  syms = (asymbol **) bfd_malloc ((bfd_size_type) storage);
    720792  if (syms == NULL)
    721793    goto error_return;
     
    733805
    734806 error_return:
     807  bfd_set_error (bfd_error_no_symbols);
    735808  if (syms != NULL)
    736809    free (syms);
     
    742815   we just return the asymbol the minisymbol points to.  */
    743816
    744 /*ARGSUSED*/
    745817asymbol *
    746818_bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym)
    747819     bfd *abfd ATTRIBUTE_UNUSED;
    748      boolean dynamic ATTRIBUTE_UNUSED;
     820     bfd_boolean dynamic ATTRIBUTE_UNUSED;
    749821     const PTR minisym;
    750822     asymbol *sym ATTRIBUTE_UNUSED;
     
    756828   sections to find the source file and line closest to a desired
    757829   location.  This is used by COFF and ELF targets.  It sets *pfound
    758    to true if it finds some information.  The *pinfo field is used to
     830   to TRUE if it finds some information.  The *pinfo field is used to
    759831   pass cached information in and out of this routine; this first time
    760832   the routine is called for a BFD, *pinfo should be NULL.  The value
     
    828900};
    829901
    830 boolean
     902bfd_boolean
    831903_bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound,
    832904                                     pfilename, pfnname, pline, pinfo)
     
    835907     asection *section;
    836908     bfd_vma offset;
    837      boolean *pfound;
     909     bfd_boolean *pfound;
    838910     const char **pfilename;
    839911     const char **pfnname;
     
    847919  bfd_size_type stroff;
    848920  struct indexentry *indexentry;
    849   char *directory_name, *file_name;
     921  char *file_name;
     922  char *directory_name;
    850923  int saw_fun;
    851 
    852   *pfound = false;
     924  bfd_boolean saw_line, saw_func;
     925
     926  *pfound = FALSE;
    853927  *pfilename = bfd_get_filename (abfd);
    854928  *pfnname = NULL;
     
    881955        {
    882956          /* No stabs debugging information.  */
    883           return true;
     957          return TRUE;
    884958        }
    885959
     
    893967      int i;
    894968      char *name;
    895       char *file_name;
    896       char *directory_name;
    897969      char *function_name;
    898 
    899       info = (struct stab_find_info *) bfd_zalloc (abfd, sizeof *info);
     970      bfd_size_type amt = sizeof *info;
     971
     972      info = (struct stab_find_info *) bfd_zalloc (abfd, amt);
    900973      if (info == NULL)
    901         return false;
     974        return FALSE;
    902975
    903976      /* FIXME: When using the linker --split-by-file or
     
    913986             can return quickly in the info != NULL case above.  */
    914987          *pinfo = (PTR) info;
    915           return true;
     988          return TRUE;
    916989        }
    917990
     
    922995      info->strs = (bfd_byte *) bfd_alloc (abfd, strsize);
    923996      if (info->stabs == NULL || info->strs == NULL)
    924         return false;
    925 
    926       if (! bfd_get_section_contents (abfd, info->stabsec, info->stabs, 0,
    927                                       stabsize)
    928           || ! bfd_get_section_contents (abfd, info->strsec, info->strs, 0,
    929                                          strsize))
    930         return false;
     997        return FALSE;
     998
     999      if (! bfd_get_section_contents (abfd, info->stabsec, info->stabs,
     1000                                      (bfd_vma) 0, stabsize)
     1001          || ! bfd_get_section_contents (abfd, info->strsec, info->strs,
     1002                                         (bfd_vma) 0, strsize))
     1003        return FALSE;
    9311004
    9321005      /* If this is a relocateable object file, we have to relocate
     
    9361009      reloc_size = bfd_get_reloc_upper_bound (abfd, info->stabsec);
    9371010      if (reloc_size < 0)
    938         return false;
    939       reloc_vector = (arelent **) bfd_malloc (reloc_size);
     1011        return FALSE;
     1012      reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size);
    9401013      if (reloc_vector == NULL && reloc_size != 0)
    941         return false;
     1014        return FALSE;
    9421015      reloc_count = bfd_canonicalize_reloc (abfd, info->stabsec, reloc_vector,
    9431016                                            symbols);
     
    9461019          if (reloc_vector != NULL)
    9471020            free (reloc_vector);
    948           return false;
     1021          return FALSE;
    9491022        }
    9501023      if (reloc_count > 0)
     
    9711044                  if (reloc_vector != NULL)
    9721045                    free (reloc_vector);
    973                   return false;
     1046                  return FALSE;
    9741047                }
    9751048
     
    9781051              sym = *r->sym_ptr_ptr;
    9791052              val += sym->value + sym->section->vma + r->addend;
    980               bfd_put_32 (abfd, val, info->stabs + r->address);
     1053              bfd_put_32 (abfd, (bfd_vma) val, info->stabs + r->address);
    9811054            }
    9821055        }
     
    9951068      for (stab = info->stabs; stab < info->stabs + stabsize; stab += STABSIZE)
    9961069        {
    997           if (stab[TYPEOFF] == N_SO)
     1070          if (stab[TYPEOFF] == (bfd_byte) N_SO)
    9981071            {
    9991072              /* N_SO with null name indicates EOF */
     
    10091082              /* two N_SO's in a row is a filename and directory. Skip */
    10101083              if (stab + STABSIZE < info->stabs + stabsize
    1011                   && *(stab + STABSIZE + TYPEOFF) == N_SO)
     1084                  && *(stab + STABSIZE + TYPEOFF) == (bfd_byte) N_SO)
    10121085                {
    10131086                  stab += STABSIZE;
    10141087                }
    10151088            }
    1016           else if (stab[TYPEOFF] == N_FUN)
     1089          else if (stab[TYPEOFF] == (bfd_byte) N_FUN)
    10171090            {
    10181091              saw_fun = 1;
     
    10251098
    10261099      if (info->indextablesize == 0)
    1027         return true;
     1100        return TRUE;
    10281101      ++info->indextablesize;
    10291102
    1030       info->indextable = ((struct indexentry *)
    1031                           bfd_alloc (abfd,
    1032                                      (sizeof (struct indexentry)
    1033                                       * info->indextablesize)));
     1103      amt = info->indextablesize;
     1104      amt *= sizeof (struct indexentry);
     1105      info->indextable = (struct indexentry *) bfd_alloc (abfd, amt);
    10341106      if (info->indextable == NULL)
    1035         return false;
     1107        return FALSE;
    10361108
    10371109      file_name = NULL;
     
    10841156                  last_stab = stab;
    10851157                  if (stab + STABSIZE >= info->stabs + stabsize
    1086                       || *(stab + STABSIZE + TYPEOFF) != N_SO)
     1158                      || *(stab + STABSIZE + TYPEOFF) != (bfd_byte) N_SO)
    10871159                    {
    10881160                      directory_name = NULL;
     
    11491221
    11501222      info->indextablesize = i;
    1151       qsort (info->indextable, i, sizeof (struct indexentry), cmpindexentry);
     1223      qsort (info->indextable, (size_t) i, sizeof (struct indexentry),
     1224             cmpindexentry);
    11521225
    11531226      *pinfo = (PTR) info;
     
    11701243#endif
    11711244    {
     1245      long low, high;
     1246      long mid = -1;
     1247
    11721248      /* Cache non-existant or invalid.  Do binary search on
    11731249         indextable.  */
    1174 
    1175       long low, high;
    1176       long mid = -1;
    1177 
    11781250      indexentry = NULL;
    11791251
     
    11971269
    11981270      if (indexentry == NULL)
    1199         return true;
     1271        return TRUE;
    12001272
    12011273      stab = indexentry->stab + STABSIZE;
     
    12061278  str = indexentry->str;
    12071279
     1280  saw_line = FALSE;
     1281  saw_func = FALSE;
    12081282  for (; stab < (indexentry+1)->stab; stab += STABSIZE)
    12091283    {
    1210       boolean done;
     1284      bfd_boolean done;
    12111285      bfd_vma val;
    12121286
    1213       done = false;
     1287      done = FALSE;
    12141288
    12151289      switch (stab[TYPEOFF])
     
    12281302        case N_DSLINE:
    12291303        case N_BSLINE:
    1230           /* A line number.  The value is relative to the start of the
    1231              current function.  */
    1232           val = indexentry->val + bfd_get_32 (abfd, stab + VALOFF);
    1233           if (val <= offset)
     1304          /* A line number.  If the function was specified, then the value
     1305             is relative to the start of the function.  Otherwise, the
     1306             value is an absolute address.  */
     1307          val = ((indexentry->function_name ? indexentry->val : 0)
     1308                 + bfd_get_32 (abfd, stab + VALOFF));
     1309          /* If this line starts before our desired offset, or if it's
     1310             the first line we've been able to find, use it.  The
     1311             !saw_line check works around a bug in GCC 2.95.3, which emits
     1312             the first N_SLINE late.  */
     1313          if (!saw_line || val <= offset)
    12341314            {
    12351315              *pline = bfd_get_16 (abfd, stab + DESCOFF);
     
    12431323            }
    12441324          if (val > offset)
    1245             done = true;
     1325            done = TRUE;
     1326          saw_line = TRUE;
    12461327          break;
    12471328
    12481329        case N_FUN:
    12491330        case N_SO:
    1250           done = true;
     1331          if (saw_func || saw_line)
     1332            done = TRUE;
     1333          saw_func = TRUE;
    12511334          break;
    12521335        }
     
    12561339    }
    12571340
    1258   *pfound = true;
    1259 
    1260   if (IS_ABSOLUTE_PATH(file_name) || directory_name == NULL)
     1341  *pfound = TRUE;
     1342
     1343  if (file_name == NULL || IS_ABSOLUTE_PATH (file_name)
     1344      || directory_name == NULL)
    12611345    *pfilename = file_name;
    12621346  else
     
    12691353          || strcmp (info->filename + dirlen, file_name) != 0)
    12701354        {
     1355          size_t len;
     1356
    12711357          if (info->filename != NULL)
    12721358            free (info->filename);
    1273           info->filename = (char *) bfd_malloc (dirlen +
    1274                                                 strlen (file_name)
    1275                                                 + 1);
     1359          len = strlen (file_name) + 1;
     1360          info->filename = (char *) bfd_malloc ((bfd_size_type) dirlen + len);
    12761361          if (info->filename == NULL)
    1277             return false;
    1278           strcpy (info->filename, directory_name);
    1279           strcpy (info->filename + dirlen, file_name);
     1362            return FALSE;
     1363          memcpy (info->filename, directory_name, dirlen);
     1364          memcpy (info->filename + dirlen, file_name, len);
    12801365        }
    12811366
     
    12901375         to clobber the colon.  It's OK to change the name, since the
    12911376         string is in our own local storage anyhow.  */
    1292 
    12931377      s = strchr (indexentry->function_name, ':');
    12941378      if (s != NULL)
     
    12981382    }
    12991383
    1300   return true;
     1384  return TRUE;
    13011385}
Note: See TracChangeset for help on using the changeset viewer.