Ignore:
Timestamp:
Aug 16, 2003, 11:33:53 PM (22 years ago)
Author:
bird
Message:

Joined the port of 2.11.2 with 2.14.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/binutils/bfd/syms.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r617 r618  
    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.
    291 .       {* Symbol is an emx import reference.  *}
     288.  {* This symbol is thread local.  Used in ELF.  *}
     289.#define BSF_THREAD_LOCAL  0x40000
     290.
     291.  {* Symbol is an emx import reference.  *}
    292292.#define BSF_EMX_IMPORT1   0x20000000
    293293.
    294 .       {* Symbol is an emx import definition.  *}
     294.  {* Symbol is an emx import definition.  *}
    295295.#define BSF_EMX_IMPORT2   0x40000000
    296296.
    297297.  flagword flags;
    298298.
    299 .       {* A pointer to the section to which this symbol is
    300 .          relative.  This will always be non NULL, there are special
    301 .          sections for undefined and absolute symbols.  *}
     299.  {* A pointer to the section to which this symbol is
     300.     relative.  This will always be non NULL, there are special
     301.     sections for undefined and absolute symbols.  *}
    302302.  struct sec *section;
    303303.
    304 .       {* Back end special data.  *}
     304.  {* Back end special data.  *}
    305305.  union
    306306.    {
    307307.      PTR p;
    308308.      bfd_vma i;
    309 .    } udata;
    310 .
    311 .} asymbol;
     309.    }
     310.  udata;
     311.}
     312.asymbol;
     313.
    312314*/
    313315
     
    315317#include "sysdep.h"
    316318#include "libbfd.h"
     319#include "safe-ctype.h"
    317320#include "bfdlink.h"
    318321#include "aout/stab_gnu.h"
    319322
    320323static char coff_section_type PARAMS ((const char *));
     324static char decode_section_type PARAMS ((const struct sec *));
     325static int cmpindexentry PARAMS ((const PTR, const PTR));
    321326
    322327/*
     
    340345.#define bfd_get_symtab_upper_bound(abfd) \
    341346.     BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd))
    342 
     347.
    343348*/
    344349
     
    348353
    349354SYNOPSIS
    350         boolean bfd_is_local_label(bfd *abfd, asymbol *sym);
     355        bfd_boolean bfd_is_local_label (bfd *abfd, asymbol *sym);
    351356
    352357DESCRIPTION
    353         Return true if the given symbol @var{sym} in the BFD @var{abfd} is
    354         a compiler generated local label, else return false.
    355 */
    356 
    357 boolean
     358        Return TRUE if the given symbol @var{sym} in the BFD @var{abfd} is
     359        a compiler generated local label, else return FALSE.
     360*/
     361
     362bfd_boolean
    358363bfd_is_local_label (abfd, sym)
    359364     bfd *abfd;
    360365     asymbol *sym;
    361366{
    362   if ((sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0)
    363     return false;
     367  /* The BSF_SECTION_SYM check is needed for IA-64, where every label that
     368     starts with '.' is local.  This would accidentally catch section names
     369     if we didn't reject them here.  */
     370  if ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_SECTION_SYM)) != 0)
     371    return FALSE;
    364372  if (sym->name == NULL)
    365     return false;
     373    return FALSE;
    366374  return bfd_is_local_label_name (abfd, sym->name);
    367375}
     
    372380
    373381SYNOPSIS
    374         boolean bfd_is_local_label_name(bfd *abfd, const char *name);
     382        bfd_boolean bfd_is_local_label_name (bfd *abfd, const char *name);
    375383
    376384DESCRIPTION
    377         Return true if a symbol with the name @var{name} in the BFD
     385        Return TRUE if a symbol with the name @var{name} in the BFD
    378386        @var{abfd} is a compiler generated local label, else return
    379         false.  This just checks whether the name has the form of a
     387        FALSE.  This just checks whether the name has the form of a
    380388        local label.
    381389
    382390.#define bfd_is_local_label_name(abfd, name) \
    383391.     BFD_SEND (abfd, _bfd_is_local_label_name, (abfd, name))
     392.
    384393*/
    385394
     
    398407.     BFD_SEND (abfd, _bfd_canonicalize_symtab,\
    399408.                  (abfd, location))
    400 
     409.
    401410*/
    402411
     
    406415
    407416SYNOPSIS
    408         boolean bfd_set_symtab (bfd *abfd, asymbol **location, unsigned int count);
     417        bfd_boolean bfd_set_symtab (bfd *abfd, asymbol **location, unsigned int count);
    409418
    410419DESCRIPTION
     
    414423*/
    415424
    416 boolean
     425bfd_boolean
    417426bfd_set_symtab (abfd, location, symcount)
    418427     bfd *abfd;
     
    423432    {
    424433      bfd_set_error (bfd_error_invalid_operation);
    425       return false;
     434      return FALSE;
    426435    }
    427436
    428437  bfd_get_outsymbols (abfd) = location;
    429438  bfd_get_symcount (abfd) = symcount;
    430   return true;
     439  return TRUE;
    431440}
    432441
     
    436445
    437446SYNOPSIS
    438         void bfd_print_symbol_vandf(PTR file, asymbol *symbol);
     447        void bfd_print_symbol_vandf (bfd *abfd, PTR file, asymbol *symbol);
    439448
    440449DESCRIPTION
     
    443452*/
    444453void
    445 bfd_print_symbol_vandf (arg, symbol)
     454bfd_print_symbol_vandf (abfd, arg, symbol)
     455     bfd *abfd;
    446456     PTR arg;
    447457     asymbol *symbol;
    448458{
    449459  FILE *file = (FILE *) arg;
     460
    450461  flagword type = symbol->flags;
     462
    451463  if (symbol->section != (asection *) NULL)
    452     {
    453       fprintf_vma (file, symbol->value + symbol->section->vma);
    454     }
     464    bfd_fprintf_vma (abfd, file,
     465                     symbol->value + symbol->section->vma);
    455466  else
    456     {
    457       fprintf_vma (file, symbol->value);
    458     }
     467    bfd_fprintf_vma (abfd, file, symbol->value);
    459468
    460469  /* This presumes that a symbol can not be both BSF_DEBUGGING and
     
    496505.#define bfd_make_empty_symbol(abfd) \
    497506.     BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd))
    498 */
     507.
     508*/
     509
     510/*
     511FUNCTION
     512        _bfd_generic_make_empty_symbol
     513
     514SYNOPSIS
     515        asymbol * _bfd_generic_make_empty_symbol (bfd *);
     516
     517DESCRIPTION
     518        Create a new <<asymbol>> structure for the BFD @var{abfd}
     519        and return a pointer to it.  Used by core file routines,
     520        binary back-end and anywhere else where no private info
     521        is needed.
     522*/
     523
     524asymbol *
     525_bfd_generic_make_empty_symbol (abfd)
     526     bfd *abfd;
     527{
     528  bfd_size_type amt = sizeof (asymbol);
     529  asymbol *new = (asymbol *) bfd_zalloc (abfd, amt);
     530  if (new)
     531    new->the_bfd = abfd;
     532  return new;
     533}
    499534
    500535/*
     
    509544.#define bfd_make_debug_symbol(abfd,ptr,size) \
    510545.        BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size))
     546.
    511547*/
    512548
    513549struct section_to_type
    514550{
    515   CONST char *section;
     551  const char *section;
    516552  char type;
    517553};
     
    520556   This table is probably incomplete.  It is sorted for convenience of
    521557   adding entries.  Since it is so short, a linear search is used.  */
    522 static CONST struct section_to_type stt[] =
    523 {
     558static const struct section_to_type stt[] =
     559{
     560  {".bss", 'b'},
     561  {"code", 't'},                /* MRI .text */
     562  {".data", 'd'},
    524563  {"*DEBUG*", 'N'},
    525   {".bss", 'b'},
    526   {"zerovars", 'b'},            /* MRI .bss */
    527   {".data", 'd'},
    528   {"vars", 'd'},                /* MRI .data */
     564  {".debug", 'N'},              /* MSVC's .debug (non-standard debug syms) */
     565  {".drectve", 'i'},            /* MSVC's .drective section */
     566  {".edata", 'e'},              /* MSVC's .edata (export) section */
     567  {".fini", 't'},               /* ELF fini section */
     568  {".idata", 'i'},              /* MSVC's .idata (import) section */
     569  {".init", 't'},               /* ELF init section */
     570  {".pdata", 'p'},              /* MSVC's .pdata (stack unwind) section */
    529571  {".rdata", 'r'},              /* Read only data.  */
    530572  {".rodata", 'r'},             /* Read only data.  */
     
    533575  {".sdata", 'g'},              /* Small initialized data.  */
    534576  {".text", 't'},
    535   {"code", 't'},                /* MRI .text */
    536   {".drectve", 'i'},            /* MSVC's .drective section */
    537   {".idata", 'i'},              /* MSVC's .idata (import) section */
    538   {".edata", 'e'},              /* MSVC's .edata (export) section */
    539   {".pdata", 'p'},              /* MSVC's .pdata (stack unwind) section */
    540   {".debug", 'N'},              /* MSVC's .debug (non-standard debug syms) */
     577  {"vars", 'd'},                /* MRI .data */
     578  {"zerovars", 'b'},            /* MRI .bss */
    541579  {0, 0}
    542580};
     
    552590     const char *s;
    553591{
    554   CONST struct section_to_type *t;
     592  const struct section_to_type *t;
    555593
    556594  for (t = &stt[0]; t->section; t++)
     
    561599}
    562600
    563 #ifndef islower
    564 #define islower(c) ((c) >= 'a' && (c) <= 'z')
    565 #endif
    566 #ifndef toupper
    567 #define toupper(c) (islower(c) ? ((c) & ~0x20) : (c))
    568 #endif
     601/* Return the single-character symbol type corresponding to section
     602   SECTION, or '?' for an unknown section.  This uses section flags to
     603   identify sections.
     604
     605   FIXME These types are unhandled: c, i, e, p.  If we handled these also,
     606   we could perhaps obsolete coff_section_type.  */
     607
     608static char
     609decode_section_type (section)
     610     const struct sec *section;
     611{
     612  if (section->flags & SEC_CODE)
     613    return 't';
     614  if (section->flags & SEC_DATA)
     615    {
     616      if (section->flags & SEC_READONLY)
     617        return 'r';
     618      else if (section->flags & SEC_SMALL_DATA)
     619        return 'g';
     620      else
     621        return 'd';
     622    }
     623  if ((section->flags & SEC_HAS_CONTENTS) == 0)
     624    {
     625      if (section->flags & SEC_SMALL_DATA)
     626        return 's';
     627      else
     628        return 'b';
     629    }
     630  if (section->flags & SEC_DEBUGGING)
     631    return 'N';
     632
     633  return '?';
     634}
    569635
    570636/*
     
    577643
    578644SYNOPSIS
    579         int bfd_decode_symclass(asymbol *symbol);
     645        int bfd_decode_symclass (asymbol *symbol);
    580646*/
    581647int
     
    624690    c = 'a';
    625691  else if (symbol->section)
    626     c = coff_section_type (symbol->section->name);
     692    {
     693      c = coff_section_type (symbol->section->name);
     694      if (c == '?')
     695        c = decode_section_type (symbol->section);
     696    }
    627697  else
    628698    return '?';
    629699  if (symbol->flags & BSF_GLOBAL)
    630     c = toupper (c);
     700    c = TOUPPER (c);
    631701  return c;
    632702
     
    651721
    652722SYNOPSIS
    653         boolean bfd_is_undefined_symclass (int symclass);
    654 */
    655 
    656 boolean
     723        bfd_boolean bfd_is_undefined_symclass (int symclass);
     724*/
     725
     726bfd_boolean
    657727bfd_is_undefined_symclass (symclass)
    658728     int symclass;
     
    671741
    672742SYNOPSIS
    673         void bfd_symbol_info(asymbol *symbol, symbol_info *ret);
     743        void bfd_symbol_info (asymbol *symbol, symbol_info *ret);
    674744*/
    675745
     
    694764
    695765SYNOPSIS
    696         boolean bfd_copy_private_symbol_data(bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym);
     766        bfd_boolean bfd_copy_private_symbol_data (bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym);
    697767
    698768DESCRIPTION
    699769        Copy private symbol information from @var{isym} in the BFD
    700770        @var{ibfd} to the symbol @var{osym} in the BFD @var{obfd}.
    701         Return <<true>> on success, <<false>> on error.  Possible error
     771        Return <<TRUE>> on success, <<FALSE>> on error.  Possible error
    702772        returns are:
    703773
     
    708778.     BFD_SEND (obfd, _bfd_copy_private_symbol_data, \
    709779.               (ibfd, isymbol, obfd, osymbol))
    710 
     780.
    711781*/
    712782
     
    718788_bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep)
    719789     bfd *abfd;
    720      boolean dynamic;
     790     bfd_boolean dynamic;
    721791     PTR *minisymsp;
    722792     unsigned int *sizep;
     
    732802  if (storage < 0)
    733803    goto error_return;
    734 
    735   syms = (asymbol **) bfd_malloc ((size_t) storage);
     804  if (storage == 0)
     805    return 0;
     806
     807  syms = (asymbol **) bfd_malloc ((bfd_size_type) storage);
    736808  if (syms == NULL)
    737809    goto error_return;
     
    749821
    750822 error_return:
     823  bfd_set_error (bfd_error_no_symbols);
    751824  if (syms != NULL)
    752825    free (syms);
     
    758831   we just return the asymbol the minisymbol points to.  */
    759832
    760 /*ARGSUSED*/
    761833asymbol *
    762834_bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym)
    763835     bfd *abfd ATTRIBUTE_UNUSED;
    764      boolean dynamic ATTRIBUTE_UNUSED;
     836     bfd_boolean dynamic ATTRIBUTE_UNUSED;
    765837     const PTR minisym;
    766838     asymbol *sym ATTRIBUTE_UNUSED;
     
    772844   sections to find the source file and line closest to a desired
    773845   location.  This is used by COFF and ELF targets.  It sets *pfound
    774    to true if it finds some information.  The *pinfo field is used to
     846   to TRUE if it finds some information.  The *pinfo field is used to
    775847   pass cached information in and out of this routine; this first time
    776848   the routine is called for a BFD, *pinfo should be NULL.  The value
     
    844916};
    845917
    846 boolean
     918bfd_boolean
    847919_bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound,
    848920                                     pfilename, pfnname, pline, pinfo)
     
    851923     asection *section;
    852924     bfd_vma offset;
    853      boolean *pfound;
     925     bfd_boolean *pfound;
    854926     const char **pfilename;
    855927     const char **pfnname;
     
    863935  bfd_size_type stroff;
    864936  struct indexentry *indexentry;
    865   char *directory_name, *file_name;
     937  char *file_name;
     938  char *directory_name;
    866939  int saw_fun;
    867 
    868   *pfound = false;
     940  bfd_boolean saw_line, saw_func;
     941
     942  *pfound = FALSE;
    869943  *pfilename = bfd_get_filename (abfd);
    870944  *pfnname = NULL;
     
    897971        {
    898972          /* No stabs debugging information.  */
    899           return true;
     973          return TRUE;
    900974        }
    901975
     
    909983      int i;
    910984      char *name;
    911       char *file_name;
    912       char *directory_name;
    913985      char *function_name;
    914 
    915       info = (struct stab_find_info *) bfd_zalloc (abfd, sizeof *info);
     986      bfd_size_type amt = sizeof *info;
     987
     988      info = (struct stab_find_info *) bfd_zalloc (abfd, amt);
    916989      if (info == NULL)
    917         return false;
     990        return FALSE;
    918991
    919992      /* FIXME: When using the linker --split-by-file or
     
    9291002             can return quickly in the info != NULL case above.  */
    9301003          *pinfo = (PTR) info;
    931           return true;
     1004          return TRUE;
    9321005        }
    9331006
     
    9381011      info->strs = (bfd_byte *) bfd_alloc (abfd, strsize);
    9391012      if (info->stabs == NULL || info->strs == NULL)
    940         return false;
    941 
    942       if (! bfd_get_section_contents (abfd, info->stabsec, info->stabs, 0,
    943                                       stabsize)
    944           || ! bfd_get_section_contents (abfd, info->strsec, info->strs, 0,
    945                                          strsize))
    946         return false;
     1013        return FALSE;
     1014
     1015      if (! bfd_get_section_contents (abfd, info->stabsec, info->stabs,
     1016                                      (bfd_vma) 0, stabsize)
     1017          || ! bfd_get_section_contents (abfd, info->strsec, info->strs,
     1018                                         (bfd_vma) 0, strsize))
     1019        return FALSE;
    9471020
    9481021      /* If this is a relocateable object file, we have to relocate
     
    9521025      reloc_size = bfd_get_reloc_upper_bound (abfd, info->stabsec);
    9531026      if (reloc_size < 0)
    954         return false;
    955       reloc_vector = (arelent **) bfd_malloc (reloc_size);
     1027        return FALSE;
     1028      reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size);
    9561029      if (reloc_vector == NULL && reloc_size != 0)
    957         return false;
     1030        return FALSE;
    9581031      reloc_count = bfd_canonicalize_reloc (abfd, info->stabsec, reloc_vector,
    9591032                                            symbols);
     
    9621035          if (reloc_vector != NULL)
    9631036            free (reloc_vector);
    964           return false;
     1037          return FALSE;
    9651038        }
    9661039      if (reloc_count > 0)
     
    9871060                  if (reloc_vector != NULL)
    9881061                    free (reloc_vector);
    989                   return false;
     1062                  return FALSE;
    9901063                }
    9911064
     
    9941067              sym = *r->sym_ptr_ptr;
    9951068              val += sym->value + sym->section->vma + r->addend;
    996               bfd_put_32 (abfd, val, info->stabs + r->address);
     1069              bfd_put_32 (abfd, (bfd_vma) val, info->stabs + r->address);
    9971070            }
    9981071        }
     
    10111084      for (stab = info->stabs; stab < info->stabs + stabsize; stab += STABSIZE)
    10121085        {
    1013           if (stab[TYPEOFF] == N_SO)
     1086          if (stab[TYPEOFF] == (bfd_byte) N_SO)
    10141087            {
    10151088              /* N_SO with null name indicates EOF */
     
    10251098              /* two N_SO's in a row is a filename and directory. Skip */
    10261099              if (stab + STABSIZE < info->stabs + stabsize
    1027                   && *(stab + STABSIZE + TYPEOFF) == N_SO)
     1100                  && *(stab + STABSIZE + TYPEOFF) == (bfd_byte) N_SO)
    10281101                {
    10291102                  stab += STABSIZE;
    10301103                }
    10311104            }
    1032           else if (stab[TYPEOFF] == N_FUN)
     1105          else if (stab[TYPEOFF] == (bfd_byte) N_FUN)
    10331106            {
    10341107              saw_fun = 1;
     
    10411114
    10421115      if (info->indextablesize == 0)
    1043         return true;
     1116        return TRUE;
    10441117      ++info->indextablesize;
    10451118
    1046       info->indextable = ((struct indexentry *)
    1047                           bfd_alloc (abfd,
    1048                                      (sizeof (struct indexentry)
    1049                                       * info->indextablesize)));
     1119      amt = info->indextablesize;
     1120      amt *= sizeof (struct indexentry);
     1121      info->indextable = (struct indexentry *) bfd_alloc (abfd, amt);
    10501122      if (info->indextable == NULL)
    1051         return false;
     1123        return FALSE;
    10521124
    10531125      file_name = NULL;
     
    11001172                  last_stab = stab;
    11011173                  if (stab + STABSIZE >= info->stabs + stabsize
    1102                       || *(stab + STABSIZE + TYPEOFF) != N_SO)
     1174                      || *(stab + STABSIZE + TYPEOFF) != (bfd_byte) N_SO)
    11031175                    {
    11041176                      directory_name = NULL;
     
    11651237
    11661238      info->indextablesize = i;
    1167       qsort (info->indextable, i, sizeof (struct indexentry), cmpindexentry);
     1239      qsort (info->indextable, (size_t) i, sizeof (struct indexentry),
     1240             cmpindexentry);
    11681241
    11691242      *pinfo = (PTR) info;
     
    11861259#endif
    11871260    {
     1261      long low, high;
     1262      long mid = -1;
     1263
    11881264      /* Cache non-existant or invalid.  Do binary search on
    11891265         indextable.  */
    1190 
    1191       long low, high;
    1192       long mid = -1;
    1193 
    11941266      indexentry = NULL;
    11951267
     
    12131285
    12141286      if (indexentry == NULL)
    1215         return true;
     1287        return TRUE;
    12161288
    12171289      stab = indexentry->stab + STABSIZE;
     
    12221294  str = indexentry->str;
    12231295
     1296  saw_line = FALSE;
     1297  saw_func = FALSE;
    12241298  for (; stab < (indexentry+1)->stab; stab += STABSIZE)
    12251299    {
    1226       boolean done;
     1300      bfd_boolean done;
    12271301      bfd_vma val;
    12281302
    1229       done = false;
     1303      done = FALSE;
    12301304
    12311305      switch (stab[TYPEOFF])
     
    12441318        case N_DSLINE:
    12451319        case N_BSLINE:
    1246           /* A line number.  The value is relative to the start of the
    1247              current function.  */
    1248           val = indexentry->val + bfd_get_32 (abfd, stab + VALOFF);
    1249           if (val <= offset)
     1320          /* A line number.  If the function was specified, then the value
     1321             is relative to the start of the function.  Otherwise, the
     1322             value is an absolute address.  */
     1323          val = ((indexentry->function_name ? indexentry->val : 0)
     1324                 + bfd_get_32 (abfd, stab + VALOFF));
     1325          /* If this line starts before our desired offset, or if it's
     1326             the first line we've been able to find, use it.  The
     1327             !saw_line check works around a bug in GCC 2.95.3, which emits
     1328             the first N_SLINE late.  */
     1329          if (!saw_line || val <= offset)
    12501330            {
    12511331              *pline = bfd_get_16 (abfd, stab + DESCOFF);
     
    12591339            }
    12601340          if (val > offset)
    1261             done = true;
     1341            done = TRUE;
     1342          saw_line = TRUE;
    12621343          break;
    12631344
    12641345        case N_FUN:
    12651346        case N_SO:
    1266           done = true;
     1347          if (saw_func || saw_line)
     1348            done = TRUE;
     1349          saw_func = TRUE;
    12671350          break;
    12681351        }
     
    12721355    }
    12731356
    1274   *pfound = true;
    1275 
    1276   if (IS_ABSOLUTE_PATH(file_name) || directory_name == NULL)
     1357  *pfound = TRUE;
     1358
     1359  if (file_name == NULL || IS_ABSOLUTE_PATH (file_name)
     1360      || directory_name == NULL)
    12771361    *pfilename = file_name;
    12781362  else
     
    12851369          || strcmp (info->filename + dirlen, file_name) != 0)
    12861370        {
     1371          size_t len;
     1372
    12871373          if (info->filename != NULL)
    12881374            free (info->filename);
    1289           info->filename = (char *) bfd_malloc (dirlen +
    1290                                                 strlen (file_name)
    1291                                                 + 1);
     1375          len = strlen (file_name) + 1;
     1376          info->filename = (char *) bfd_malloc ((bfd_size_type) dirlen + len);
    12921377          if (info->filename == NULL)
    1293             return false;
    1294           strcpy (info->filename, directory_name);
    1295           strcpy (info->filename + dirlen, file_name);
     1378            return FALSE;
     1379          memcpy (info->filename, directory_name, dirlen);
     1380          memcpy (info->filename + dirlen, file_name, len);
    12961381        }
    12971382
     
    13061391         to clobber the colon.  It's OK to change the name, since the
    13071392         string is in our own local storage anyhow.  */
    1308 
    13091393      s = strchr (indexentry->function_name, ':');
    13101394      if (s != NULL)
     
    13141398    }
    13151399
    1316   return true;
     1400  return TRUE;
    13171401}
Note: See TracChangeset for help on using the changeset viewer.