Back to index

cell-binutils  2.17cvs20070401
syms.c
Go to the documentation of this file.
00001 /* Generic symbol-table support for the BFD library.
00002    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
00003    2000, 2001, 2002, 2003, 2004
00004    Free Software Foundation, Inc.
00005    Written by Cygnus Support.
00006 
00007    This file is part of BFD, the Binary File Descriptor library.
00008 
00009    This program is free software; you can redistribute it and/or modify
00010    it under the terms of the GNU General Public License as published by
00011    the Free Software Foundation; either version 2 of the License, or
00012    (at your option) any later version.
00013 
00014    This program is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017    GNU General Public License for more details.
00018 
00019    You should have received a copy of the GNU General Public License
00020    along with this program; if not, write to the Free Software
00021    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
00022 
00023 /*
00024 SECTION
00025        Symbols
00026 
00027        BFD tries to maintain as much symbol information as it can when
00028        it moves information from file to file. BFD passes information
00029        to applications though the <<asymbol>> structure. When the
00030        application requests the symbol table, BFD reads the table in
00031        the native form and translates parts of it into the internal
00032        format. To maintain more than the information passed to
00033        applications, some targets keep some information ``behind the
00034        scenes'' in a structure only the particular back end knows
00035        about. For example, the coff back end keeps the original
00036        symbol table structure as well as the canonical structure when
00037        a BFD is read in. On output, the coff back end can reconstruct
00038        the output symbol table so that no information is lost, even
00039        information unique to coff which BFD doesn't know or
00040        understand. If a coff symbol table were read, but were written
00041        through an a.out back end, all the coff specific information
00042        would be lost. The symbol table of a BFD
00043        is not necessarily read in until a canonicalize request is
00044        made. Then the BFD back end fills in a table provided by the
00045        application with pointers to the canonical information.  To
00046        output symbols, the application provides BFD with a table of
00047        pointers to pointers to <<asymbol>>s. This allows applications
00048        like the linker to output a symbol as it was read, since the ``behind
00049        the scenes'' information will be still available.
00050 @menu
00051 @* Reading Symbols::
00052 @* Writing Symbols::
00053 @* Mini Symbols::
00054 @* typedef asymbol::
00055 @* symbol handling functions::
00056 @end menu
00057 
00058 INODE
00059 Reading Symbols, Writing Symbols, Symbols, Symbols
00060 SUBSECTION
00061        Reading symbols
00062 
00063        There are two stages to reading a symbol table from a BFD:
00064        allocating storage, and the actual reading process. This is an
00065        excerpt from an application which reads the symbol table:
00066 
00067 |        long storage_needed;
00068 |        asymbol **symbol_table;
00069 |        long number_of_symbols;
00070 |        long i;
00071 |
00072 |        storage_needed = bfd_get_symtab_upper_bound (abfd);
00073 |
00074 |         if (storage_needed < 0)
00075 |           FAIL
00076 |
00077 |        if (storage_needed == 0)
00078 |          return;
00079 |        
00080 |        symbol_table = xmalloc (storage_needed);
00081 |          ...
00082 |        number_of_symbols =
00083 |           bfd_canonicalize_symtab (abfd, symbol_table);
00084 |
00085 |         if (number_of_symbols < 0)
00086 |           FAIL
00087 |
00088 |        for (i = 0; i < number_of_symbols; i++)
00089 |          process_symbol (symbol_table[i]);
00090 
00091        All storage for the symbols themselves is in an objalloc
00092        connected to the BFD; it is freed when the BFD is closed.
00093 
00094 INODE
00095 Writing Symbols, Mini Symbols, Reading Symbols, Symbols
00096 SUBSECTION
00097        Writing symbols
00098 
00099        Writing of a symbol table is automatic when a BFD open for
00100        writing is closed. The application attaches a vector of
00101        pointers to pointers to symbols to the BFD being written, and
00102        fills in the symbol count. The close and cleanup code reads
00103        through the table provided and performs all the necessary
00104        operations. The BFD output code must always be provided with an
00105        ``owned'' symbol: one which has come from another BFD, or one
00106        which has been created using <<bfd_make_empty_symbol>>.  Here is an
00107        example showing the creation of a symbol table with only one element:
00108 
00109 |      #include "bfd.h"
00110 |      int main (void)
00111 |      {
00112 |        bfd *abfd;
00113 |        asymbol *ptrs[2];
00114 |        asymbol *new;
00115 |
00116 |        abfd = bfd_openw ("foo","a.out-sunos-big");
00117 |        bfd_set_format (abfd, bfd_object);
00118 |        new = bfd_make_empty_symbol (abfd);
00119 |        new->name = "dummy_symbol";
00120 |        new->section = bfd_make_section_old_way (abfd, ".text");
00121 |        new->flags = BSF_GLOBAL;
00122 |        new->value = 0x12345;
00123 |
00124 |        ptrs[0] = new;
00125 |        ptrs[1] = 0;
00126 |
00127 |        bfd_set_symtab (abfd, ptrs, 1);
00128 |        bfd_close (abfd);
00129 |        return 0;
00130 |      }
00131 |
00132 |      ./makesym
00133 |      nm foo
00134 |      00012345 A dummy_symbol
00135 
00136        Many formats cannot represent arbitrary symbol information; for
00137        instance, the <<a.out>> object format does not allow an
00138        arbitrary number of sections. A symbol pointing to a section
00139        which is not one  of <<.text>>, <<.data>> or <<.bss>> cannot
00140        be described.
00141 
00142 INODE
00143 Mini Symbols, typedef asymbol, Writing Symbols, Symbols
00144 SUBSECTION
00145        Mini Symbols
00146 
00147        Mini symbols provide read-only access to the symbol table.
00148        They use less memory space, but require more time to access.
00149        They can be useful for tools like nm or objdump, which may
00150        have to handle symbol tables of extremely large executables.
00151 
00152        The <<bfd_read_minisymbols>> function will read the symbols
00153        into memory in an internal form.  It will return a <<void *>>
00154        pointer to a block of memory, a symbol count, and the size of
00155        each symbol.  The pointer is allocated using <<malloc>>, and
00156        should be freed by the caller when it is no longer needed.
00157 
00158        The function <<bfd_minisymbol_to_symbol>> will take a pointer
00159        to a minisymbol, and a pointer to a structure returned by
00160        <<bfd_make_empty_symbol>>, and return a <<asymbol>> structure.
00161        The return value may or may not be the same as the value from
00162        <<bfd_make_empty_symbol>> which was passed in.
00163 
00164 */
00165 
00166 /*
00167 DOCDD
00168 INODE
00169 typedef asymbol, symbol handling functions, Mini Symbols, Symbols
00170 
00171 */
00172 /*
00173 SUBSECTION
00174        typedef asymbol
00175 
00176        An <<asymbol>> has the form:
00177 
00178 */
00179 
00180 /*
00181 CODE_FRAGMENT
00182 
00183 .
00184 .typedef struct bfd_symbol
00185 .{
00186 .  {* A pointer to the BFD which owns the symbol. This information
00187 .     is necessary so that a back end can work out what additional
00188 .     information (invisible to the application writer) is carried
00189 .     with the symbol.
00190 .
00191 .     This field is *almost* redundant, since you can use section->owner
00192 .     instead, except that some symbols point to the global sections
00193 .     bfd_{abs,com,und}_section.  This could be fixed by making
00194 .     these globals be per-bfd (or per-target-flavor).  FIXME.  *}
00195 .  struct bfd *the_bfd; {* Use bfd_asymbol_bfd(sym) to access this field.  *}
00196 .
00197 .  {* The text of the symbol. The name is left alone, and not copied; the
00198 .     application may not alter it.  *}
00199 .  const char *name;
00200 .
00201 .  {* The value of the symbol.  This really should be a union of a
00202 .     numeric value with a pointer, since some flags indicate that
00203 .     a pointer to another symbol is stored here.  *}
00204 .  symvalue value;
00205 .
00206 .  {* Attributes of a symbol.  *}
00207 .#define BSF_NO_FLAGS    0x00
00208 .
00209 .  {* The symbol has local scope; <<static>> in <<C>>. The value
00210 .     is the offset into the section of the data.  *}
00211 .#define BSF_LOCAL   0x01
00212 .
00213 .  {* The symbol has global scope; initialized data in <<C>>. The
00214 .     value is the offset into the section of the data.  *}
00215 .#define BSF_GLOBAL  0x02
00216 .
00217 .  {* The symbol has global scope and is exported. The value is
00218 .     the offset into the section of the data.  *}
00219 .#define BSF_EXPORT  BSF_GLOBAL {* No real difference.  *}
00220 .
00221 .  {* A normal C symbol would be one of:
00222 .     <<BSF_LOCAL>>, <<BSF_FORT_COMM>>,  <<BSF_UNDEFINED>> or
00223 .     <<BSF_GLOBAL>>.  *}
00224 .
00225 .  {* The symbol is a debugging record. The value has an arbitrary
00226 .     meaning, unless BSF_DEBUGGING_RELOC is also set.  *}
00227 .#define BSF_DEBUGGING      0x08
00228 .
00229 .  {* The symbol denotes a function entry point.  Used in ELF,
00230 .     perhaps others someday.  *}
00231 .#define BSF_FUNCTION    0x10
00232 .
00233 .  {* Used by the linker.  *}
00234 .#define BSF_KEEP        0x20
00235 .#define BSF_KEEP_G      0x40
00236 .
00237 .  {* A weak global symbol, overridable without warnings by
00238 .     a regular global symbol of the same name.  *}
00239 .#define BSF_WEAK        0x80
00240 .
00241 .  {* This symbol was created to point to a section, e.g. ELF's
00242 .     STT_SECTION symbols.  *}
00243 .#define BSF_SECTION_SYM 0x100
00244 .
00245 .  {* The symbol used to be a common symbol, but now it is
00246 .     allocated.  *}
00247 .#define BSF_OLD_COMMON  0x200
00248 .
00249 .  {* The default value for common data.  *}
00250 .#define BFD_FORT_COMM_DEFAULT_VALUE 0
00251 .
00252 .  {* In some files the type of a symbol sometimes alters its
00253 .     location in an output file - ie in coff a <<ISFCN>> symbol
00254 .     which is also <<C_EXT>> symbol appears where it was
00255 .     declared and not at the end of a section.  This bit is set
00256 .     by the target BFD part to convey this information.  *}
00257 .#define BSF_NOT_AT_END    0x400
00258 .
00259 .  {* Signal that the symbol is the label of constructor section.  *}
00260 .#define BSF_CONSTRUCTOR   0x800
00261 .
00262 .  {* Signal that the symbol is a warning symbol.  The name is a
00263 .     warning.  The name of the next symbol is the one to warn about;
00264 .     if a reference is made to a symbol with the same name as the next
00265 .     symbol, a warning is issued by the linker.  *}
00266 .#define BSF_WARNING       0x1000
00267 .
00268 .  {* Signal that the symbol is indirect.  This symbol is an indirect
00269 .     pointer to the symbol with the same name as the next symbol.  *}
00270 .#define BSF_INDIRECT      0x2000
00271 .
00272 .  {* BSF_FILE marks symbols that contain a file name.  This is used
00273 .     for ELF STT_FILE symbols.  *}
00274 .#define BSF_FILE          0x4000
00275 .
00276 .  {* Symbol is from dynamic linking information.  *}
00277 .#define BSF_DYNAMIC    0x8000
00278 .
00279 .  {* The symbol denotes a data object.  Used in ELF, and perhaps
00280 .     others someday.  *}
00281 .#define BSF_OBJECT     0x10000
00282 .
00283 .  {* This symbol is a debugging symbol.  The value is the offset
00284 .     into the section of the data.  BSF_DEBUGGING should be set
00285 .     as well.  *}
00286 .#define BSF_DEBUGGING_RELOC 0x20000
00287 .
00288 .  {* This symbol is thread local.  Used in ELF.  *}
00289 .#define BSF_THREAD_LOCAL  0x40000
00290 .
00291 .  {* This symbol represents a complex relocation expression,
00292 .     with the expression tree serialized in the symbol name.  *}
00293 .#define BSF_RELC 0x80000
00294 .
00295 .  {* This symbol represents a signed complex relocation expression,
00296 .     with the expression tree serialized in the symbol name.  *}
00297 .#define BSF_SRELC 0x100000
00298 .
00299 .  flagword flags;
00300 .
00301 .  {* A pointer to the section to which this symbol is
00302 .     relative.  This will always be non NULL, there are special
00303 .     sections for undefined and absolute symbols.  *}
00304 .  struct bfd_section *section;
00305 .
00306 .  {* Back end special data.  *}
00307 .  union
00308 .    {
00309 .      void *p;
00310 .      bfd_vma i;
00311 .    }
00312 .  udata;
00313 .}
00314 .asymbol;
00315 .
00316 */
00317 
00318 #include "bfd.h"
00319 #include "sysdep.h"
00320 #include "libbfd.h"
00321 #include "safe-ctype.h"
00322 #include "bfdlink.h"
00323 #include "aout/stab_gnu.h"
00324 
00325 /*
00326 DOCDD
00327 INODE
00328 symbol handling functions,  , typedef asymbol, Symbols
00329 SUBSECTION
00330        Symbol handling functions
00331 */
00332 
00333 /*
00334 FUNCTION
00335        bfd_get_symtab_upper_bound
00336 
00337 DESCRIPTION
00338        Return the number of bytes required to store a vector of pointers
00339        to <<asymbols>> for all the symbols in the BFD @var{abfd},
00340        including a terminal NULL pointer. If there are no symbols in
00341        the BFD, then return 0.  If an error occurs, return -1.
00342 
00343 .#define bfd_get_symtab_upper_bound(abfd) \
00344 .     BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd))
00345 .
00346 */
00347 
00348 /*
00349 FUNCTION
00350        bfd_is_local_label
00351 
00352 SYNOPSIS
00353         bfd_boolean bfd_is_local_label (bfd *abfd, asymbol *sym);
00354 
00355 DESCRIPTION
00356        Return TRUE if the given symbol @var{sym} in the BFD @var{abfd} is
00357        a compiler generated local label, else return FALSE.
00358 */
00359 
00360 bfd_boolean
00361 bfd_is_local_label (bfd *abfd, asymbol *sym)
00362 {
00363   /* The BSF_SECTION_SYM check is needed for IA-64, where every label that
00364      starts with '.' is local.  This would accidentally catch section names
00365      if we didn't reject them here.  */
00366   if ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_FILE | BSF_SECTION_SYM)) != 0)
00367     return FALSE;
00368   if (sym->name == NULL)
00369     return FALSE;
00370   return bfd_is_local_label_name (abfd, sym->name);
00371 }
00372 
00373 /*
00374 FUNCTION
00375        bfd_is_local_label_name
00376 
00377 SYNOPSIS
00378         bfd_boolean bfd_is_local_label_name (bfd *abfd, const char *name);
00379 
00380 DESCRIPTION
00381        Return TRUE if a symbol with the name @var{name} in the BFD
00382        @var{abfd} is a compiler generated local label, else return
00383        FALSE.  This just checks whether the name has the form of a
00384        local label.
00385 
00386 .#define bfd_is_local_label_name(abfd, name) \
00387 .  BFD_SEND (abfd, _bfd_is_local_label_name, (abfd, name))
00388 .
00389 */
00390 
00391 /*
00392 FUNCTION
00393        bfd_is_target_special_symbol
00394 
00395 SYNOPSIS
00396         bfd_boolean bfd_is_target_special_symbol (bfd *abfd, asymbol *sym);
00397 
00398 DESCRIPTION
00399        Return TRUE iff a symbol @var{sym} in the BFD @var{abfd} is something
00400        special to the particular target represented by the BFD.  Such symbols
00401        should normally not be mentioned to the user.
00402 
00403 .#define bfd_is_target_special_symbol(abfd, sym) \
00404 .  BFD_SEND (abfd, _bfd_is_target_special_symbol, (abfd, sym))
00405 .
00406 */
00407 
00408 /*
00409 FUNCTION
00410        bfd_canonicalize_symtab
00411 
00412 DESCRIPTION
00413        Read the symbols from the BFD @var{abfd}, and fills in
00414        the vector @var{location} with pointers to the symbols and
00415        a trailing NULL.
00416        Return the actual number of symbol pointers, not
00417        including the NULL.
00418 
00419 .#define bfd_canonicalize_symtab(abfd, location) \
00420 .  BFD_SEND (abfd, _bfd_canonicalize_symtab, (abfd, location))
00421 .
00422 */
00423 
00424 /*
00425 FUNCTION
00426        bfd_set_symtab
00427 
00428 SYNOPSIS
00429        bfd_boolean bfd_set_symtab
00430          (bfd *abfd, asymbol **location, unsigned int count);
00431 
00432 DESCRIPTION
00433        Arrange that when the output BFD @var{abfd} is closed,
00434        the table @var{location} of @var{count} pointers to symbols
00435        will be written.
00436 */
00437 
00438 bfd_boolean
00439 bfd_set_symtab (bfd *abfd, asymbol **location, unsigned int symcount)
00440 {
00441   if (abfd->format != bfd_object || bfd_read_p (abfd))
00442     {
00443       bfd_set_error (bfd_error_invalid_operation);
00444       return FALSE;
00445     }
00446 
00447   bfd_get_outsymbols (abfd) = location;
00448   bfd_get_symcount (abfd) = symcount;
00449   return TRUE;
00450 }
00451 
00452 /*
00453 FUNCTION
00454        bfd_print_symbol_vandf
00455 
00456 SYNOPSIS
00457        void bfd_print_symbol_vandf (bfd *abfd, void *file, asymbol *symbol);
00458 
00459 DESCRIPTION
00460        Print the value and flags of the @var{symbol} supplied to the
00461        stream @var{file}.
00462 */
00463 void
00464 bfd_print_symbol_vandf (bfd *abfd, void *arg, asymbol *symbol)
00465 {
00466   FILE *file = arg;
00467 
00468   flagword type = symbol->flags;
00469 
00470   if (symbol->section != NULL)
00471     bfd_fprintf_vma (abfd, file, symbol->value + symbol->section->vma);
00472   else
00473     bfd_fprintf_vma (abfd, file, symbol->value);
00474 
00475   /* This presumes that a symbol can not be both BSF_DEBUGGING and
00476      BSF_DYNAMIC, nor more than one of BSF_FUNCTION, BSF_FILE, and
00477      BSF_OBJECT.  */
00478   fprintf (file, " %c%c%c%c%c%c%c",
00479           ((type & BSF_LOCAL)
00480            ? (type & BSF_GLOBAL) ? '!' : 'l'
00481            : (type & BSF_GLOBAL) ? 'g' : ' '),
00482           (type & BSF_WEAK) ? 'w' : ' ',
00483           (type & BSF_CONSTRUCTOR) ? 'C' : ' ',
00484           (type & BSF_WARNING) ? 'W' : ' ',
00485           (type & BSF_INDIRECT) ? 'I' : ' ',
00486           (type & BSF_DEBUGGING) ? 'd' : (type & BSF_DYNAMIC) ? 'D' : ' ',
00487           ((type & BSF_FUNCTION)
00488            ? 'F'
00489            : ((type & BSF_FILE)
00490               ? 'f'
00491               : ((type & BSF_OBJECT) ? 'O' : ' '))));
00492 }
00493 
00494 /*
00495 FUNCTION
00496        bfd_make_empty_symbol
00497 
00498 DESCRIPTION
00499        Create a new <<asymbol>> structure for the BFD @var{abfd}
00500        and return a pointer to it.
00501 
00502        This routine is necessary because each back end has private
00503        information surrounding the <<asymbol>>. Building your own
00504        <<asymbol>> and pointing to it will not create the private
00505        information, and will cause problems later on.
00506 
00507 .#define bfd_make_empty_symbol(abfd) \
00508 .  BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd))
00509 .
00510 */
00511 
00512 /*
00513 FUNCTION
00514        _bfd_generic_make_empty_symbol
00515 
00516 SYNOPSIS
00517        asymbol *_bfd_generic_make_empty_symbol (bfd *);
00518 
00519 DESCRIPTION
00520        Create a new <<asymbol>> structure for the BFD @var{abfd}
00521        and return a pointer to it.  Used by core file routines,
00522        binary back-end and anywhere else where no private info
00523        is needed.
00524 */
00525 
00526 asymbol *
00527 _bfd_generic_make_empty_symbol (bfd *abfd)
00528 {
00529   bfd_size_type amt = sizeof (asymbol);
00530   asymbol *new = bfd_zalloc (abfd, amt);
00531   if (new)
00532     new->the_bfd = abfd;
00533   return new;
00534 }
00535 
00536 /*
00537 FUNCTION
00538        bfd_make_debug_symbol
00539 
00540 DESCRIPTION
00541        Create a new <<asymbol>> structure for the BFD @var{abfd},
00542        to be used as a debugging symbol.  Further details of its use have
00543        yet to be worked out.
00544 
00545 .#define bfd_make_debug_symbol(abfd,ptr,size) \
00546 .  BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size))
00547 .
00548 */
00549 
00550 struct section_to_type
00551 {
00552   const char *section;
00553   char type;
00554 };
00555 
00556 /* Map section names to POSIX/BSD single-character symbol types.
00557    This table is probably incomplete.  It is sorted for convenience of
00558    adding entries.  Since it is so short, a linear search is used.  */
00559 static const struct section_to_type stt[] =
00560 {
00561   {".bss", 'b'},
00562   {"code", 't'},            /* MRI .text */
00563   {".data", 'd'},
00564   {"*DEBUG*", 'N'},
00565   {".debug", 'N'},              /* MSVC's .debug (non-standard debug syms) */
00566   {".drectve", 'i'},            /* MSVC's .drective section */
00567   {".edata", 'e'},              /* MSVC's .edata (export) section */
00568   {".fini", 't'},           /* ELF fini section */
00569   {".idata", 'i'},              /* MSVC's .idata (import) section */
00570   {".init", 't'},           /* ELF init section */
00571   {".pdata", 'p'},              /* MSVC's .pdata (stack unwind) section */
00572   {".rdata", 'r'},          /* Read only data.  */
00573   {".rodata", 'r'},         /* Read only data.  */
00574   {".sbss", 's'},           /* Small BSS (uninitialized data).  */
00575   {".scommon", 'c'},        /* Small common.  */
00576   {".sdata", 'g'},          /* Small initialized data.  */
00577   {".text", 't'},
00578   {"vars", 'd'},            /* MRI .data */
00579   {"zerovars", 'b'},        /* MRI .bss */
00580   {0, 0}
00581 };
00582 
00583 /* Return the single-character symbol type corresponding to
00584    section S, or '?' for an unknown COFF section.
00585 
00586    Check for any leading string which matches, so .text5 returns
00587    't' as well as .text */
00588 
00589 static char
00590 coff_section_type (const char *s)
00591 {
00592   const struct section_to_type *t;
00593 
00594   for (t = &stt[0]; t->section; t++)
00595     if (!strncmp (s, t->section, strlen (t->section)))
00596       return t->type;
00597 
00598   return '?';
00599 }
00600 
00601 /* Return the single-character symbol type corresponding to section
00602    SECTION, or '?' for an unknown section.  This uses section flags to
00603    identify sections.
00604 
00605    FIXME These types are unhandled: c, i, e, p.  If we handled these also,
00606    we could perhaps obsolete coff_section_type.  */
00607 
00608 static char
00609 decode_section_type (const struct bfd_section *section)
00610 {
00611   if (section->flags & SEC_CODE)
00612     return 't';
00613   if (section->flags & SEC_DATA)
00614     {
00615       if (section->flags & SEC_READONLY)
00616        return 'r';
00617       else if (section->flags & SEC_SMALL_DATA)
00618        return 'g';
00619       else
00620        return 'd';
00621     }
00622   if ((section->flags & SEC_HAS_CONTENTS) == 0)
00623     {
00624       if (section->flags & SEC_SMALL_DATA)
00625        return 's';
00626       else
00627        return 'b';
00628     }
00629   if (section->flags & SEC_DEBUGGING)
00630     return 'N';
00631   if ((section->flags & SEC_HAS_CONTENTS) && (section->flags & SEC_READONLY))
00632     return 'n';
00633 
00634   return '?';
00635 }
00636 
00637 /*
00638 FUNCTION
00639        bfd_decode_symclass
00640 
00641 DESCRIPTION
00642        Return a character corresponding to the symbol
00643        class of @var{symbol}, or '?' for an unknown class.
00644 
00645 SYNOPSIS
00646        int bfd_decode_symclass (asymbol *symbol);
00647 */
00648 int
00649 bfd_decode_symclass (asymbol *symbol)
00650 {
00651   char c;
00652 
00653   if (bfd_is_com_section (symbol->section))
00654     return 'C';
00655   if (bfd_is_und_section (symbol->section))
00656     {
00657       if (symbol->flags & BSF_WEAK)
00658        {
00659          /* If weak, determine if it's specifically an object
00660             or non-object weak.  */
00661          if (symbol->flags & BSF_OBJECT)
00662            return 'v';
00663          else
00664            return 'w';
00665        }
00666       else
00667        return 'U';
00668     }
00669   if (bfd_is_ind_section (symbol->section))
00670     return 'I';
00671   if (symbol->flags & BSF_WEAK)
00672     {
00673       /* If weak, determine if it's specifically an object
00674         or non-object weak.  */
00675       if (symbol->flags & BSF_OBJECT)
00676        return 'V';
00677       else
00678        return 'W';
00679     }
00680   if (!(symbol->flags & (BSF_GLOBAL | BSF_LOCAL)))
00681     return '?';
00682 
00683   if (bfd_is_abs_section (symbol->section))
00684     c = 'a';
00685   else if (symbol->section)
00686     {
00687       c = coff_section_type (symbol->section->name);
00688       if (c == '?')
00689        c = decode_section_type (symbol->section);
00690     }
00691   else
00692     return '?';
00693   if (symbol->flags & BSF_GLOBAL)
00694     c = TOUPPER (c);
00695   return c;
00696 
00697   /* We don't have to handle these cases just yet, but we will soon:
00698      N_SETV: 'v';
00699      N_SETA: 'l';
00700      N_SETT: 'x';
00701      N_SETD: 'z';
00702      N_SETB: 's';
00703      N_INDR: 'i';
00704      */
00705 }
00706 
00707 /*
00708 FUNCTION
00709        bfd_is_undefined_symclass
00710 
00711 DESCRIPTION
00712        Returns non-zero if the class symbol returned by
00713        bfd_decode_symclass represents an undefined symbol.
00714        Returns zero otherwise.
00715 
00716 SYNOPSIS
00717        bfd_boolean bfd_is_undefined_symclass (int symclass);
00718 */
00719 
00720 bfd_boolean
00721 bfd_is_undefined_symclass (int symclass)
00722 {
00723   return symclass == 'U' || symclass == 'w' || symclass == 'v';
00724 }
00725 
00726 /*
00727 FUNCTION
00728        bfd_symbol_info
00729 
00730 DESCRIPTION
00731        Fill in the basic info about symbol that nm needs.
00732        Additional info may be added by the back-ends after
00733        calling this function.
00734 
00735 SYNOPSIS
00736        void bfd_symbol_info (asymbol *symbol, symbol_info *ret);
00737 */
00738 
00739 void
00740 bfd_symbol_info (asymbol *symbol, symbol_info *ret)
00741 {
00742   ret->type = bfd_decode_symclass (symbol);
00743 
00744   if (bfd_is_undefined_symclass (ret->type))
00745     ret->value = 0;
00746   else
00747     ret->value = symbol->value + symbol->section->vma;
00748 
00749   ret->name = symbol->name;
00750 }
00751 
00752 /*
00753 FUNCTION
00754        bfd_copy_private_symbol_data
00755 
00756 SYNOPSIS
00757        bfd_boolean bfd_copy_private_symbol_data
00758          (bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym);
00759 
00760 DESCRIPTION
00761        Copy private symbol information from @var{isym} in the BFD
00762        @var{ibfd} to the symbol @var{osym} in the BFD @var{obfd}.
00763        Return <<TRUE>> on success, <<FALSE>> on error.  Possible error
00764        returns are:
00765 
00766        o <<bfd_error_no_memory>> -
00767        Not enough memory exists to create private data for @var{osec}.
00768 
00769 .#define bfd_copy_private_symbol_data(ibfd, isymbol, obfd, osymbol) \
00770 .  BFD_SEND (obfd, _bfd_copy_private_symbol_data, \
00771 .            (ibfd, isymbol, obfd, osymbol))
00772 .
00773 */
00774 
00775 /* The generic version of the function which returns mini symbols.
00776    This is used when the backend does not provide a more efficient
00777    version.  It just uses BFD asymbol structures as mini symbols.  */
00778 
00779 long
00780 _bfd_generic_read_minisymbols (bfd *abfd,
00781                             bfd_boolean dynamic,
00782                             void **minisymsp,
00783                             unsigned int *sizep)
00784 {
00785   long storage;
00786   asymbol **syms = NULL;
00787   long symcount;
00788 
00789   if (dynamic)
00790     storage = bfd_get_dynamic_symtab_upper_bound (abfd);
00791   else
00792     storage = bfd_get_symtab_upper_bound (abfd);
00793   if (storage < 0)
00794     goto error_return;
00795   if (storage == 0)
00796     return 0;
00797 
00798   syms = bfd_malloc (storage);
00799   if (syms == NULL)
00800     goto error_return;
00801 
00802   if (dynamic)
00803     symcount = bfd_canonicalize_dynamic_symtab (abfd, syms);
00804   else
00805     symcount = bfd_canonicalize_symtab (abfd, syms);
00806   if (symcount < 0)
00807     goto error_return;
00808 
00809   *minisymsp = syms;
00810   *sizep = sizeof (asymbol *);
00811   return symcount;
00812 
00813  error_return:
00814   bfd_set_error (bfd_error_no_symbols);
00815   if (syms != NULL)
00816     free (syms);
00817   return -1;
00818 }
00819 
00820 /* The generic version of the function which converts a minisymbol to
00821    an asymbol.  We don't worry about the sym argument we are passed;
00822    we just return the asymbol the minisymbol points to.  */
00823 
00824 asymbol *
00825 _bfd_generic_minisymbol_to_symbol (bfd *abfd ATTRIBUTE_UNUSED,
00826                                bfd_boolean dynamic ATTRIBUTE_UNUSED,
00827                                const void *minisym,
00828                                asymbol *sym ATTRIBUTE_UNUSED)
00829 {
00830   return *(asymbol **) minisym;
00831 }
00832 
00833 /* Look through stabs debugging information in .stab and .stabstr
00834    sections to find the source file and line closest to a desired
00835    location.  This is used by COFF and ELF targets.  It sets *pfound
00836    to TRUE if it finds some information.  The *pinfo field is used to
00837    pass cached information in and out of this routine; this first time
00838    the routine is called for a BFD, *pinfo should be NULL.  The value
00839    placed in *pinfo should be saved with the BFD, and passed back each
00840    time this function is called.  */
00841 
00842 /* We use a cache by default.  */
00843 
00844 #define ENABLE_CACHING
00845 
00846 /* We keep an array of indexentry structures to record where in the
00847    stabs section we should look to find line number information for a
00848    particular address.  */
00849 
00850 struct indexentry
00851 {
00852   bfd_vma val;
00853   bfd_byte *stab;
00854   bfd_byte *str;
00855   char *directory_name;
00856   char *file_name;
00857   char *function_name;
00858 };
00859 
00860 /* Compare two indexentry structures.  This is called via qsort.  */
00861 
00862 static int
00863 cmpindexentry (const void *a, const void *b)
00864 {
00865   const struct indexentry *contestantA = a;
00866   const struct indexentry *contestantB = b;
00867 
00868   if (contestantA->val < contestantB->val)
00869     return -1;
00870   else if (contestantA->val > contestantB->val)
00871     return 1;
00872   else
00873     return 0;
00874 }
00875 
00876 /* A pointer to this structure is stored in *pinfo.  */
00877 
00878 struct stab_find_info
00879 {
00880   /* The .stab section.  */
00881   asection *stabsec;
00882   /* The .stabstr section.  */
00883   asection *strsec;
00884   /* The contents of the .stab section.  */
00885   bfd_byte *stabs;
00886   /* The contents of the .stabstr section.  */
00887   bfd_byte *strs;
00888 
00889   /* A table that indexes stabs by memory address.  */
00890   struct indexentry *indextable;
00891   /* The number of entries in indextable.  */
00892   int indextablesize;
00893 
00894 #ifdef ENABLE_CACHING
00895   /* Cached values to restart quickly.  */
00896   struct indexentry *cached_indexentry;
00897   bfd_vma cached_offset;
00898   bfd_byte *cached_stab;
00899   char *cached_file_name;
00900 #endif
00901 
00902   /* Saved ptr to malloc'ed filename.  */
00903   char *filename;
00904 };
00905 
00906 bfd_boolean
00907 _bfd_stab_section_find_nearest_line (bfd *abfd,
00908                                  asymbol **symbols,
00909                                  asection *section,
00910                                  bfd_vma offset,
00911                                  bfd_boolean *pfound,
00912                                  const char **pfilename,
00913                                  const char **pfnname,
00914                                  unsigned int *pline,
00915                                  void **pinfo)
00916 {
00917   struct stab_find_info *info;
00918   bfd_size_type stabsize, strsize;
00919   bfd_byte *stab, *str;
00920   bfd_byte *last_stab = NULL;
00921   bfd_size_type stroff;
00922   struct indexentry *indexentry;
00923   char *file_name;
00924   char *directory_name;
00925   int saw_fun;
00926   bfd_boolean saw_line, saw_func;
00927 
00928   *pfound = FALSE;
00929   *pfilename = bfd_get_filename (abfd);
00930   *pfnname = NULL;
00931   *pline = 0;
00932 
00933   /* Stabs entries use a 12 byte format:
00934        4 byte string table index
00935        1 byte stab type
00936        1 byte stab other field
00937        2 byte stab desc field
00938        4 byte stab value
00939      FIXME: This will have to change for a 64 bit object format.
00940 
00941      The stabs symbols are divided into compilation units.  For the
00942      first entry in each unit, the type of 0, the value is the length
00943      of the string table for this unit, and the desc field is the
00944      number of stabs symbols for this unit.  */
00945 
00946 #define STRDXOFF (0)
00947 #define TYPEOFF (4)
00948 #define OTHEROFF (5)
00949 #define DESCOFF (6)
00950 #define VALOFF (8)
00951 #define STABSIZE (12)
00952 
00953   info = *pinfo;
00954   if (info != NULL)
00955     {
00956       if (info->stabsec == NULL || info->strsec == NULL)
00957        {
00958          /* No stabs debugging information.  */
00959          return TRUE;
00960        }
00961 
00962       stabsize = (info->stabsec->rawsize
00963                 ? info->stabsec->rawsize
00964                 : info->stabsec->size);
00965       strsize = (info->strsec->rawsize
00966                ? info->strsec->rawsize
00967                : info->strsec->size);
00968     }
00969   else
00970     {
00971       long reloc_size, reloc_count;
00972       arelent **reloc_vector;
00973       int i;
00974       char *name;
00975       char *function_name;
00976       bfd_size_type amt = sizeof *info;
00977 
00978       info = bfd_zalloc (abfd, amt);
00979       if (info == NULL)
00980        return FALSE;
00981 
00982       /* FIXME: When using the linker --split-by-file or
00983         --split-by-reloc options, it is possible for the .stab and
00984         .stabstr sections to be split.  We should handle that.  */
00985 
00986       info->stabsec = bfd_get_section_by_name (abfd, ".stab");
00987       info->strsec = bfd_get_section_by_name (abfd, ".stabstr");
00988 
00989       if (info->stabsec == NULL || info->strsec == NULL)
00990        {
00991          /* No stabs debugging information.  Set *pinfo so that we
00992              can return quickly in the info != NULL case above.  */
00993          *pinfo = info;
00994          return TRUE;
00995        }
00996 
00997       stabsize = (info->stabsec->rawsize
00998                 ? info->stabsec->rawsize
00999                 : info->stabsec->size);
01000       strsize = (info->strsec->rawsize
01001                ? info->strsec->rawsize
01002                : info->strsec->size);
01003 
01004       info->stabs = bfd_alloc (abfd, stabsize);
01005       info->strs = bfd_alloc (abfd, strsize);
01006       if (info->stabs == NULL || info->strs == NULL)
01007        return FALSE;
01008 
01009       if (! bfd_get_section_contents (abfd, info->stabsec, info->stabs,
01010                                   0, stabsize)
01011          || ! bfd_get_section_contents (abfd, info->strsec, info->strs,
01012                                     0, strsize))
01013        return FALSE;
01014 
01015       /* If this is a relocatable object file, we have to relocate
01016         the entries in .stab.  This should always be simple 32 bit
01017         relocations against symbols defined in this object file, so
01018         this should be no big deal.  */
01019       reloc_size = bfd_get_reloc_upper_bound (abfd, info->stabsec);
01020       if (reloc_size < 0)
01021        return FALSE;
01022       reloc_vector = bfd_malloc (reloc_size);
01023       if (reloc_vector == NULL && reloc_size != 0)
01024        return FALSE;
01025       reloc_count = bfd_canonicalize_reloc (abfd, info->stabsec, reloc_vector,
01026                                        symbols);
01027       if (reloc_count < 0)
01028        {
01029          if (reloc_vector != NULL)
01030            free (reloc_vector);
01031          return FALSE;
01032        }
01033       if (reloc_count > 0)
01034        {
01035          arelent **pr;
01036 
01037          for (pr = reloc_vector; *pr != NULL; pr++)
01038            {
01039              arelent *r;
01040              unsigned long val;
01041              asymbol *sym;
01042 
01043              r = *pr;
01044              /* Ignore R_*_NONE relocs.  */
01045              if (r->howto->dst_mask == 0)
01046               continue;
01047 
01048              if (r->howto->rightshift != 0
01049                 || r->howto->size != 2
01050                 || r->howto->bitsize != 32
01051                 || r->howto->pc_relative
01052                 || r->howto->bitpos != 0
01053                 || r->howto->dst_mask != 0xffffffff)
01054               {
01055                 (*_bfd_error_handler)
01056                   (_("Unsupported .stab relocation"));
01057                 bfd_set_error (bfd_error_invalid_operation);
01058                 if (reloc_vector != NULL)
01059                   free (reloc_vector);
01060                 return FALSE;
01061               }
01062 
01063              val = bfd_get_32 (abfd, info->stabs + r->address);
01064              val &= r->howto->src_mask;
01065              sym = *r->sym_ptr_ptr;
01066              val += sym->value + sym->section->vma + r->addend;
01067              bfd_put_32 (abfd, (bfd_vma) val, info->stabs + r->address);
01068            }
01069        }
01070 
01071       if (reloc_vector != NULL)
01072        free (reloc_vector);
01073 
01074       /* First time through this function, build a table matching
01075         function VM addresses to stabs, then sort based on starting
01076         VM address.  Do this in two passes: once to count how many
01077         table entries we'll need, and a second to actually build the
01078         table.  */
01079 
01080       info->indextablesize = 0;
01081       saw_fun = 1;
01082       for (stab = info->stabs; stab < info->stabs + stabsize; stab += STABSIZE)
01083        {
01084          if (stab[TYPEOFF] == (bfd_byte) N_SO)
01085            {
01086              /* N_SO with null name indicates EOF */
01087              if (bfd_get_32 (abfd, stab + STRDXOFF) == 0)
01088               continue;
01089 
01090              /* if we did not see a function def, leave space for one.  */
01091              if (saw_fun == 0)
01092               ++info->indextablesize;
01093 
01094              saw_fun = 0;
01095 
01096              /* two N_SO's in a row is a filename and directory. Skip */
01097              if (stab + STABSIZE < info->stabs + stabsize
01098                 && *(stab + STABSIZE + TYPEOFF) == (bfd_byte) N_SO)
01099               {
01100                 stab += STABSIZE;
01101               }
01102            }
01103          else if (stab[TYPEOFF] == (bfd_byte) N_FUN)
01104            {
01105              saw_fun = 1;
01106              ++info->indextablesize;
01107            }
01108        }
01109 
01110       if (saw_fun == 0)
01111        ++info->indextablesize;
01112 
01113       if (info->indextablesize == 0)
01114        return TRUE;
01115       ++info->indextablesize;
01116 
01117       amt = info->indextablesize;
01118       amt *= sizeof (struct indexentry);
01119       info->indextable = bfd_alloc (abfd, amt);
01120       if (info->indextable == NULL)
01121        return FALSE;
01122 
01123       file_name = NULL;
01124       directory_name = NULL;
01125       saw_fun = 1;
01126 
01127       for (i = 0, stroff = 0, stab = info->stabs, str = info->strs;
01128           i < info->indextablesize && stab < info->stabs + stabsize;
01129           stab += STABSIZE)
01130        {
01131          switch (stab[TYPEOFF])
01132            {
01133            case 0:
01134              /* This is the first entry in a compilation unit.  */
01135              if ((bfd_size_type) ((info->strs + strsize) - str) < stroff)
01136               break;
01137              str += stroff;
01138              stroff = bfd_get_32 (abfd, stab + VALOFF);
01139              break;
01140 
01141            case N_SO:
01142              /* The main file name.  */
01143 
01144              /* The following code creates a new indextable entry with
01145                 a NULL function name if there were no N_FUNs in a file.
01146                 Note that a N_SO without a file name is an EOF and
01147                 there could be 2 N_SO following it with the new filename
01148                 and directory.  */
01149              if (saw_fun == 0)
01150               {
01151                 info->indextable[i].val = bfd_get_32 (abfd, last_stab + VALOFF);
01152                 info->indextable[i].stab = last_stab;
01153                 info->indextable[i].str = str;
01154                 info->indextable[i].directory_name = directory_name;
01155                 info->indextable[i].file_name = file_name;
01156                 info->indextable[i].function_name = NULL;
01157                 ++i;
01158               }
01159              saw_fun = 0;
01160 
01161              file_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
01162              if (*file_name == '\0')
01163               {
01164                 directory_name = NULL;
01165                 file_name = NULL;
01166                 saw_fun = 1;
01167               }
01168              else
01169               {
01170                 last_stab = stab;
01171                 if (stab + STABSIZE >= info->stabs + stabsize
01172                     || *(stab + STABSIZE + TYPEOFF) != (bfd_byte) N_SO)
01173                   {
01174                     directory_name = NULL;
01175                   }
01176                 else
01177                   {
01178                     /* Two consecutive N_SOs are a directory and a
01179                       file name.  */
01180                     stab += STABSIZE;
01181                     directory_name = file_name;
01182                     file_name = ((char *) str
01183                                + bfd_get_32 (abfd, stab + STRDXOFF));
01184                   }
01185               }
01186              break;
01187 
01188            case N_SOL:
01189              /* The name of an include file.  */
01190              file_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
01191              break;
01192 
01193            case N_FUN:
01194              /* A function name.  */
01195              saw_fun = 1;
01196              name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
01197 
01198              if (*name == '\0')
01199               name = NULL;
01200 
01201              function_name = name;
01202 
01203              if (name == NULL)
01204               continue;
01205 
01206              info->indextable[i].val = bfd_get_32 (abfd, stab + VALOFF);
01207              info->indextable[i].stab = stab;
01208              info->indextable[i].str = str;
01209              info->indextable[i].directory_name = directory_name;
01210              info->indextable[i].file_name = file_name;
01211              info->indextable[i].function_name = function_name;
01212              ++i;
01213              break;
01214            }
01215        }
01216 
01217       if (saw_fun == 0)
01218        {
01219          info->indextable[i].val = bfd_get_32 (abfd, last_stab + VALOFF);
01220          info->indextable[i].stab = last_stab;
01221          info->indextable[i].str = str;
01222          info->indextable[i].directory_name = directory_name;
01223          info->indextable[i].file_name = file_name;
01224          info->indextable[i].function_name = NULL;
01225          ++i;
01226        }
01227 
01228       info->indextable[i].val = (bfd_vma) -1;
01229       info->indextable[i].stab = info->stabs + stabsize;
01230       info->indextable[i].str = str;
01231       info->indextable[i].directory_name = NULL;
01232       info->indextable[i].file_name = NULL;
01233       info->indextable[i].function_name = NULL;
01234       ++i;
01235 
01236       info->indextablesize = i;
01237       qsort (info->indextable, (size_t) i, sizeof (struct indexentry),
01238             cmpindexentry);
01239 
01240       *pinfo = info;
01241     }
01242 
01243   /* We are passed a section relative offset.  The offsets in the
01244      stabs information are absolute.  */
01245   offset += bfd_get_section_vma (abfd, section);
01246 
01247 #ifdef ENABLE_CACHING
01248   if (info->cached_indexentry != NULL
01249       && offset >= info->cached_offset
01250       && offset < (info->cached_indexentry + 1)->val)
01251     {
01252       stab = info->cached_stab;
01253       indexentry = info->cached_indexentry;
01254       file_name = info->cached_file_name;
01255     }
01256   else
01257 #endif
01258     {
01259       long low, high;
01260       long mid = -1;
01261 
01262       /* Cache non-existent or invalid.  Do binary search on
01263          indextable.  */
01264       indexentry = NULL;
01265 
01266       low = 0;
01267       high = info->indextablesize - 1;
01268       while (low != high)
01269        {
01270          mid = (high + low) / 2;
01271          if (offset >= info->indextable[mid].val
01272              && offset < info->indextable[mid + 1].val)
01273            {
01274              indexentry = &info->indextable[mid];
01275              break;
01276            }
01277 
01278          if (info->indextable[mid].val > offset)
01279            high = mid;
01280          else
01281            low = mid + 1;
01282        }
01283 
01284       if (indexentry == NULL)
01285        return TRUE;
01286 
01287       stab = indexentry->stab + STABSIZE;
01288       file_name = indexentry->file_name;
01289     }
01290 
01291   directory_name = indexentry->directory_name;
01292   str = indexentry->str;
01293 
01294   saw_line = FALSE;
01295   saw_func = FALSE;
01296   for (; stab < (indexentry+1)->stab; stab += STABSIZE)
01297     {
01298       bfd_boolean done;
01299       bfd_vma val;
01300 
01301       done = FALSE;
01302 
01303       switch (stab[TYPEOFF])
01304        {
01305        case N_SOL:
01306          /* The name of an include file.  */
01307          val = bfd_get_32 (abfd, stab + VALOFF);
01308          if (val <= offset)
01309            {
01310              file_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
01311              *pline = 0;
01312            }
01313          break;
01314 
01315        case N_SLINE:
01316        case N_DSLINE:
01317        case N_BSLINE:
01318          /* A line number.  If the function was specified, then the value
01319             is relative to the start of the function.  Otherwise, the
01320             value is an absolute address.  */
01321          val = ((indexentry->function_name ? indexentry->val : 0)
01322                + bfd_get_32 (abfd, stab + VALOFF));
01323          /* If this line starts before our desired offset, or if it's
01324             the first line we've been able to find, use it.  The
01325             !saw_line check works around a bug in GCC 2.95.3, which emits
01326             the first N_SLINE late.  */
01327          if (!saw_line || val <= offset)
01328            {
01329              *pline = bfd_get_16 (abfd, stab + DESCOFF);
01330 
01331 #ifdef ENABLE_CACHING
01332              info->cached_stab = stab;
01333              info->cached_offset = val;
01334              info->cached_file_name = file_name;
01335              info->cached_indexentry = indexentry;
01336 #endif
01337            }
01338          if (val > offset)
01339            done = TRUE;
01340          saw_line = TRUE;
01341          break;
01342 
01343        case N_FUN:
01344        case N_SO:
01345          if (saw_func || saw_line)
01346            done = TRUE;
01347          saw_func = TRUE;
01348          break;
01349        }
01350 
01351       if (done)
01352        break;
01353     }
01354 
01355   *pfound = TRUE;
01356 
01357   if (file_name == NULL || IS_ABSOLUTE_PATH (file_name)
01358       || directory_name == NULL)
01359     *pfilename = file_name;
01360   else
01361     {
01362       size_t dirlen;
01363 
01364       dirlen = strlen (directory_name);
01365       if (info->filename == NULL
01366          || strncmp (info->filename, directory_name, dirlen) != 0
01367          || strcmp (info->filename + dirlen, file_name) != 0)
01368        {
01369          size_t len;
01370 
01371          if (info->filename != NULL)
01372            free (info->filename);
01373          len = strlen (file_name) + 1;
01374          info->filename = bfd_malloc (dirlen + len);
01375          if (info->filename == NULL)
01376            return FALSE;
01377          memcpy (info->filename, directory_name, dirlen);
01378          memcpy (info->filename + dirlen, file_name, len);
01379        }
01380 
01381       *pfilename = info->filename;
01382     }
01383 
01384   if (indexentry->function_name != NULL)
01385     {
01386       char *s;
01387 
01388       /* This will typically be something like main:F(0,1), so we want
01389          to clobber the colon.  It's OK to change the name, since the
01390          string is in our own local storage anyhow.  */
01391       s = strchr (indexentry->function_name, ':');
01392       if (s != NULL)
01393        *s = '\0';
01394 
01395       *pfnname = indexentry->function_name;
01396     }
01397 
01398   return TRUE;
01399 }