Support for xcoff64
[deliverable/binutils-gdb.git] / bfd / syms.c
index f69d1f21fa489a5bca0717e5ed9828017d8cc3ac..311806e1f6b68b923d80d030345ce7c6d8053f9b 100644 (file)
@@ -1,5 +1,6 @@
 /* Generic symbol-table support for the BFD library.
-   Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+   2000
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -91,7 +92,6 @@ SUBSECTION
        All storage for the symbols themselves is in an objalloc
        connected to the BFD; it is freed when the BFD is closed.
 
-
 INODE
 Writing Symbols, Mini Symbols, Reading Symbols, Symbols
 SUBSECTION
@@ -163,8 +163,6 @@ SUBSECTION
 
 */
 
-
-
 /*
 DOCDD
 INODE
@@ -227,7 +225,7 @@ CODE_FRAGMENT
 .         <<BSF_GLOBAL>> *}
 .
 .      {* The symbol is a debugging record. The value has an arbitary
-.         meaning. *}
+.         meaning, unless BSF_DEBUGGING_RELOC is also set.  *}
 .#define BSF_DEBUGGING 0x08
 .
 .      {* The symbol denotes a function entry point.  Used in ELF,
@@ -285,6 +283,11 @@ CODE_FRAGMENT
 .          others someday.  *}
 .#define BSF_OBJECT       0x10000
 .
+.       {* This symbol is a debugging symbol.  The value is the offset
+.          into the section of the data.  BSF_DEBUGGING should be set
+.          as well.  *}
+.#define BSF_DEBUGGING_RELOC 0x20000
+.
 .  flagword flags;
 .
 .      {* A pointer to the section to which this symbol is
@@ -385,14 +388,12 @@ DESCRIPTION
        Return the actual number of symbol pointers, not
        including the NULL.
 
-
 .#define bfd_canonicalize_symtab(abfd, location) \
 .     BFD_SEND (abfd, _bfd_canonicalize_symtab,\
 .                  (abfd, location))
 
 */
 
-
 /*
 FUNCTION
        bfd_set_symtab
@@ -469,7 +470,6 @@ bfd_print_symbol_vandf (arg, symbol)
               : ((type & BSF_OBJECT) ? 'O' : ' '))));
 }
 
-
 /*
 FUNCTION
        bfd_make_empty_symbol
@@ -523,11 +523,16 @@ static CONST struct section_to_type stt[] =
   {".sdata", 'g'},             /* Small initialized data.  */
   {".text", 't'},
   {"code", 't'},               /* MRI .text */
+  {".drectve", 'i'},            /* MSVC's .drective section */
+  {".idata", 'i'},              /* MSVC's .idata (import) section */
+  {".edata", 'e'},              /* MSVC's .edata (export) section */
+  {".pdata", 'p'},              /* MSVC's .pdata (stack unwind) section */
+  {".debug", 'N'},              /* MSVC's .debug (non-standard debug syms) */
   {0, 0}
 };
 
 /* Return the single-character symbol type corresponding to
-   section S, or '?' for an unknown COFF section.  
+   section S, or '?' for an unknown COFF section.
 
    Check for any leading string which matches, so .text5 returns
    't' as well as .text */
@@ -538,7 +543,7 @@ coff_section_type (s)
 {
   CONST struct section_to_type *t;
 
-  for (t = &stt[0]; t->section; t++) 
+  for (t = &stt[0]; t->section; t++)
     if (!strncmp (s, t->section, strlen (t->section)))
       return t->type;
 
@@ -572,11 +577,30 @@ bfd_decode_symclass (symbol)
   if (bfd_is_com_section (symbol->section))
     return 'C';
   if (bfd_is_und_section (symbol->section))
-    return 'U';
+    {
+      if (symbol->flags & BSF_WEAK)
+       {
+         /* If weak, determine if it's specifically an object
+            or non-object weak.  */
+         if (symbol->flags & BSF_OBJECT)
+           return 'v';
+         else
+           return 'w';
+       }
+      else
+       return 'U';
+    }
   if (bfd_is_ind_section (symbol->section))
     return 'I';
   if (symbol->flags & BSF_WEAK)
-    return 'W';
+    {
+      /* If weak, determine if it's specifically an object
+        or non-object weak.  */
+      if (symbol->flags & BSF_OBJECT)
+       return 'V';
+      else
+       return 'W';
+    }
   if (!(symbol->flags & (BSF_GLOBAL | BSF_LOCAL)))
     return '?';
 
@@ -600,6 +624,26 @@ bfd_decode_symclass (symbol)
      */
 }
 
+/*
+FUNCTION
+       bfd_is_undefined_symclass
+
+DESCRIPTION
+       Returns non-zero if the class symbol returned by
+       bfd_decode_symclass represents an undefined symbol.
+       Returns zero otherwise.
+
+SYNOPSIS
+       boolean bfd_is_undefined_symclass (int symclass);
+*/
+
+boolean
+bfd_is_undefined_symclass (symclass)
+     int symclass;
+{
+  return symclass == 'U' || symclass == 'w' || symclass == 'v';
+}
+
 /*
 FUNCTION
        bfd_symbol_info
@@ -619,10 +663,12 @@ bfd_symbol_info (symbol, ret)
      symbol_info *ret;
 {
   ret->type = bfd_decode_symclass (symbol);
-  if (ret->type != 'U')
-    ret->value = symbol->value + symbol->section->vma;
-  else
+
+  if (bfd_is_undefined_symclass (ret->type))
     ret->value = 0;
+  else
+    ret->value = symbol->value + symbol->section->vma;
+
   ret->name = symbol->name;
 }
 
@@ -698,10 +744,10 @@ _bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep)
 /*ARGSUSED*/
 asymbol *
 _bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym)
-     bfd *abfd;
-     boolean dynamic;
+     bfd *abfd ATTRIBUTE_UNUSED;
+     boolean dynamic ATTRIBUTE_UNUSED;
      const PTR minisym;
-     asymbol *sym;
+     asymbol *sym ATTRIBUTE_UNUSED;
 {
   return *(asymbol **) minisym;
 }
@@ -737,8 +783,8 @@ struct indexentry
 
 static int
 cmpindexentry (a, b)
-     const PTR *a;
-     const PTR *b;
+     const PTR a;
+     const PTR b;
 {
   const struct indexentry *contestantA = (const struct indexentry *) a;
   const struct indexentry *contestantB = (const struct indexentry *) b;
@@ -796,7 +842,8 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound,
 {
   struct stab_find_info *info;
   bfd_size_type stabsize, strsize;
-  bfd_byte *stab, *str, *last_stab;
+  bfd_byte *stab, *str;
+  bfd_byte *last_stab = NULL;
   bfd_size_type stroff;
   struct indexentry *indexentry;
   char *directory_name, *file_name;
@@ -953,7 +1000,7 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound,
              if (bfd_get_32 (abfd, stab + STRDXOFF) == 0)
                continue;
 
-             /* if we did not see a function def, leave space for one. */
+             /* if we did not see a function def, leave space for one.  */
              if (saw_fun == 0)
                ++info->indextablesize;
 
@@ -975,7 +1022,7 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound,
 
       if (saw_fun == 0)
        ++info->indextablesize;
-      
+
       if (info->indextablesize == 0)
        return true;
       ++info->indextablesize;
@@ -1011,8 +1058,8 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound,
              /* The following code creates a new indextable entry with
                 a NULL function name if there were no N_FUNs in a file.
                 Note that a N_SO without a file name is an EOF and
-                there could be 2 N_SO following it with the new filename 
-                and directory. */
+                there could be 2 N_SO following it with the new filename
+                and directory.  */
              if (saw_fun == 0)
                {
                  info->indextable[i].val = bfd_get_32 (abfd, last_stab + VALOFF);
@@ -1024,7 +1071,7 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound,
                  ++i;
                }
              saw_fun = 0;
-             
+
              file_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
              if (*file_name == '\0')
                {
@@ -1032,23 +1079,24 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound,
                  file_name = NULL;
                  saw_fun = 1;
                }
-             else {
-               last_stab = stab;
-               if (stab + STABSIZE >= info->stabs + stabsize
-                   || *(stab + STABSIZE + TYPEOFF) != N_SO)
-                 {
-                   directory_name = NULL;
-                 }
-               else
-                 {
-                   /* Two consecutive N_SOs are a directory and a file
-                      name.  */
-                   stab += STABSIZE;
-                   directory_name = file_name;
-                   file_name = ((char *) str
-                                + bfd_get_32 (abfd, stab + STRDXOFF));
-                 }
-             }
+             else
+               {
+                 last_stab = stab;
+                 if (stab + STABSIZE >= info->stabs + stabsize
+                     || *(stab + STABSIZE + TYPEOFF) != N_SO)
+                   {
+                     directory_name = NULL;
+                   }
+                 else
+                   {
+                     /* Two consecutive N_SOs are a directory and a
+                        file name.  */
+                     stab += STABSIZE;
+                     directory_name = file_name;
+                     file_name = ((char *) str
+                                  + bfd_get_32 (abfd, stab + STRDXOFF));
+                   }
+               }
              break;
 
            case N_SOL:
@@ -1209,7 +1257,7 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound,
 
   *pfound = true;
 
-  if (file_name[0] == '/' || directory_name == NULL)
+  if (IS_ABSOLUTE_PATH(file_name) || directory_name == NULL)
     *pfilename = file_name;
   else
     {
This page took 0.027869 seconds and 4 git commands to generate.