daily update
[deliverable/binutils-gdb.git] / bfd / syms.c
index 86ea521909925a9b03aa7776a05dfcd65ee1a735..8831b9257c2609972dbfee496000d39b6a2a2ad1 100644 (file)
@@ -1,6 +1,6 @@
 /* Generic symbol-table support for the BFD library.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003
+   2000, 2001, 2002, 2003, 2004, 2007
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -8,7 +8,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -18,7 +18,8 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
 
 /*
 SECTION
@@ -133,9 +134,9 @@ SUBSECTION
 |      nm foo
 |      00012345 A dummy_symbol
 
-       Many formats cannot represent arbitary symbol information; for
+       Many formats cannot represent arbitrary symbol information; for
        instance, the <<a.out>> object format does not allow an
-       arbitary number of sections. A symbol pointing to a section
+       arbitrary number of sections. A symbol pointing to a section
        which is not one  of <<.text>>, <<.data>> or <<.bss>> cannot
        be described.
 
@@ -181,7 +182,7 @@ SUBSECTION
 CODE_FRAGMENT
 
 .
-.typedef struct symbol_cache_entry
+.typedef struct bfd_symbol
 .{
 .  {* A pointer to the BFD which owns the symbol. This information
 .     is necessary so that a back end can work out what additional
@@ -222,7 +223,7 @@ CODE_FRAGMENT
 .     <<BSF_LOCAL>>, <<BSF_FORT_COMM>>,  <<BSF_UNDEFINED>> or
 .     <<BSF_GLOBAL>>.  *}
 .
-.  {* The symbol is a debugging record. The value has an arbitary
+.  {* The symbol is a debugging record. The value has an arbitrary
 .     meaning, unless BSF_DEBUGGING_RELOC is also set.  *}
 .#define BSF_DEBUGGING 0x08
 .
@@ -288,6 +289,14 @@ CODE_FRAGMENT
 .  {* This symbol is thread local.  Used in ELF.  *}
 .#define BSF_THREAD_LOCAL  0x40000
 .
+.  {* This symbol represents a complex relocation expression,
+.     with the expression tree serialized in the symbol name.  *}
+.#define BSF_RELC 0x80000
+.
+.  {* This symbol represents a signed complex relocation expression,
+.     with the expression tree serialized in the symbol name.  *}
+.#define BSF_SRELC 0x100000
+.
 .  flagword flags;
 .
 .  {* A pointer to the section to which this symbol is
@@ -307,8 +316,8 @@ CODE_FRAGMENT
 .
 */
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "libbfd.h"
 #include "safe-ctype.h"
 #include "bfdlink.h"
@@ -355,7 +364,7 @@ bfd_is_local_label (bfd *abfd, asymbol *sym)
   /* The BSF_SECTION_SYM check is needed for IA-64, where every label that
      starts with '.' is local.  This would accidentally catch section names
      if we didn't reject them here.  */
-  if ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_SECTION_SYM)) != 0)
+  if ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_FILE | BSF_SECTION_SYM)) != 0)
     return FALSE;
   if (sym->name == NULL)
     return FALSE;
@@ -380,6 +389,23 @@ DESCRIPTION
 .
 */
 
+/*
+FUNCTION
+       bfd_is_target_special_symbol
+
+SYNOPSIS
+        bfd_boolean bfd_is_target_special_symbol (bfd *abfd, asymbol *sym);
+
+DESCRIPTION
+       Return TRUE iff a symbol @var{sym} in the BFD @var{abfd} is something
+       special to the particular target represented by the BFD.  Such symbols
+       should normally not be mentioned to the user.
+
+.#define bfd_is_target_special_symbol(abfd, sym) \
+.  BFD_SEND (abfd, _bfd_is_target_special_symbol, (abfd, sym))
+.
+*/
+
 /*
 FUNCTION
        bfd_canonicalize_symtab
@@ -625,7 +651,7 @@ bfd_decode_symclass (asymbol *symbol)
 {
   char c;
 
-  if (bfd_is_com_section (symbol->section))
+  if (symbol->section && bfd_is_com_section (symbol->section))
     return 'C';
   if (bfd_is_und_section (symbol->section))
     {
@@ -934,8 +960,12 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
          return TRUE;
        }
 
-      stabsize = info->stabsec->_raw_size;
-      strsize = info->strsec->_raw_size;
+      stabsize = (info->stabsec->rawsize
+                 ? info->stabsec->rawsize
+                 : info->stabsec->size);
+      strsize = (info->strsec->rawsize
+                ? info->strsec->rawsize
+                : info->strsec->size);
     }
   else
     {
@@ -959,14 +989,25 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
 
       if (info->stabsec == NULL || info->strsec == NULL)
        {
-         /* No stabs debugging information.  Set *pinfo so that we
-             can return quickly in the info != NULL case above.  */
-         *pinfo = info;
-         return TRUE;
+         /* Try SOM section names.  */
+         info->stabsec = bfd_get_section_by_name (abfd, "$GDB_SYMBOLS$");
+         info->strsec  = bfd_get_section_by_name (abfd, "$GDB_STRINGS$");
+  
+         if (info->stabsec == NULL || info->strsec == NULL)
+           {
+             /* No stabs debugging information.  Set *pinfo so that we
+                can return quickly in the info != NULL case above.  */
+             *pinfo = info;
+             return TRUE;
+           }
        }
 
-      stabsize = info->stabsec->_raw_size;
-      strsize = info->strsec->_raw_size;
+      stabsize = (info->stabsec->rawsize
+                 ? info->stabsec->rawsize
+                 : info->stabsec->size);
+      strsize = (info->strsec->rawsize
+                ? info->strsec->rawsize
+                : info->strsec->size);
 
       info->stabs = bfd_alloc (abfd, stabsize);
       info->strs = bfd_alloc (abfd, strsize);
@@ -974,9 +1015,9 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
        return FALSE;
 
       if (! bfd_get_section_contents (abfd, info->stabsec, info->stabs,
-                                     (bfd_vma) 0, stabsize)
+                                     0, stabsize)
          || ! bfd_get_section_contents (abfd, info->strsec, info->strs,
-                                        (bfd_vma) 0, strsize))
+                                        0, strsize))
        return FALSE;
 
       /* If this is a relocatable object file, we have to relocate
@@ -1008,6 +1049,10 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
              asymbol *sym;
 
              r = *pr;
+             /* Ignore R_*_NONE relocs.  */
+             if (r->howto->dst_mask == 0)
+               continue;
+
              if (r->howto->rightshift != 0
                  || r->howto->size != 2
                  || r->howto->bitsize != 32
@@ -1222,7 +1267,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
       long low, high;
       long mid = -1;
 
-      /* Cache non-existant or invalid.  Do binary search on
+      /* Cache non-existent or invalid.  Do binary search on
          indextable.  */
       indexentry = NULL;
 
This page took 0.026395 seconds and 4 git commands to generate.