Apply patch from Thomas de Lellis to allow nm to distinguish between weak
authorNick Clifton <nickc@redhat.com>
Fri, 28 Jan 2000 01:06:37 +0000 (01:06 +0000)
committerNick Clifton <nickc@redhat.com>
Fri, 28 Jan 2000 01:06:37 +0000 (01:06 +0000)
function symbols and weak data symbols.

bfd/ChangeLog
bfd/bfd-in2.h
bfd/syms.c
binutils/ChangeLog
binutils/binutils.texi
binutils/nm.c

index 9d7c9f6166ee8d1ed47a321261948b41c17aba2b..c2e74987655b24dc24426895dfa1e9072a3aca68 100644 (file)
@@ -1,5 +1,23 @@
-2000-01-27  Thomas de Lellis  <tdel@wrs.com>
+2000-01-27  Thomas de Lellis  <tdel@windriver.com>
+
+        * syms.c (bfd_decode_symclass)
+        Two new class characters were added - 'V' and 'v'.  The
+        meaning of 'W' is now restricted to just weak non-object
+        symbols.  This allows differentiation between, for example,
+        weak functions vs weak objects.  nm for example now dumps:
+        'W' = weak global
+        'w' = weak unresolved
+        'V' = weak global object
+        'v' = weak unresolved object
+
+       (bfd_is_undefined_symclass): New function.  Return true if the
+       given symbol class represents and undefined/unresolved symbol.
+       
+        (bfd_symbol_info): Use bfd_is_undefined_symclass to check for
+       unresolved symbols.
 
+       * bfd-in2.h: Add prototype for bfd_is_undefined_symbol().
+       
         * elf32-arm.h (elf32_arm_get_symbol_type): If a symbol has the
        STT_ARM_16BIT flag set, but it is not attached to a data object
        return STT_ARM_16BIT so that it will be treated as code by the
index a9b981c398057bd760670cce877d3c98b32cdd1a..9db6ec6a40ff6cbf7f08e1ed9df174d79a9f1916 100644 (file)
@@ -2433,6 +2433,9 @@ bfd_print_symbol_vandf PARAMS ((PTR file, asymbol *symbol));
 int 
 bfd_decode_symclass PARAMS ((asymbol *symbol));
 
+boolean
+bfd_is_undefined_symclass PARAMS ((int symclass));
+
 void 
 bfd_symbol_info PARAMS ((asymbol *symbol, symbol_info *ret));
 
index 676f067c2a353c65eb8e223822a7650e44b0f14d..6546f585054ac57673a13f43addbded5a15e1785 100644 (file)
@@ -584,14 +584,28 @@ bfd_decode_symclass (symbol)
   if (bfd_is_und_section (symbol->section))
     {
       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';
+       }
       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 '?';
 
@@ -615,6 +629,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
@@ -634,10 +668,12 @@ bfd_symbol_info (symbol, ret)
      symbol_info *ret;
 {
   ret->type = bfd_decode_symclass (symbol);
-  if (ret->type != 'U' && ret->type != 'w')
-    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;
 }
 
index 89d6520a78ec0f1213501b5d1d2465897d82c253..f20c78f11eabd746e5492e7a2ef16fdc822723c0 100644 (file)
@@ -1,3 +1,12 @@
+2000-27-01  Thomas de Lellis  <tdel@windriver.com>
+
+        * nm.c (print_symbol_info_bsd): Use bfd_is_undefined_symclass to
+       check to unresolved symbols.
+        (print_symbol_info_sysv):  Ditto.
+        (print_symbol_info_posix):  Ditto.
+
+        * binutils.texi: Document new 'V' symclass flag for nm.
+
 2000-01-27  Nick Clifton  <nickc@redhat.com>
 
        * binutils.texi (objdump): Document new ARM specific
index 44887d077ab0448a31b5ee2e7313cf6e83e3faed..95c684ab08d8c819b4d982c22d23a72914f8251b 100644 (file)
@@ -700,11 +700,18 @@ The symbol is in the text (code) section.
 @item U
 The symbol is undefined.
 
+@item V
+The symbol is a weak object.  When a weak defined symbol is linked with
+a normal defined symbol, the normal defined symbol is used with no error.
+When a weak undefined symbol is linked and the symbol is not defined,
+the value of the weak symbol becomes zero with no error.
+
 @item W
-The symbol is weak.  When a weak defined symbol is linked with a normal
-defined symbol, the normal defined symbol is used with no error.  When a
-weak undefined symbol is linked and the symbol is not defined, the value
-of the weak symbol becomes zero with no error.
+The symbol is a weak symbol that has not been specifically tagged as a
+weak object symbol.  When a weak defined symbol is linked with a normal
+defined symbol, the normal defined symbol is used with no error.
+When a weak undefined symbol is linked and the symbol is not defined,
+the value of the weak symbol becomes zero with no error.
 
 @item -
 The symbol is a stabs symbol in an a.out object file.  In this case, the
index 3e2ee12f492d1e71553813043fb2c6c2df1054f9..ade3f7cdf2a096380498fd14bd284bdba4be0078 100644 (file)
@@ -1427,7 +1427,7 @@ print_symbol_info_bsd (info, abfd)
      symbol_info *info;
      bfd *abfd;
 {
-  if (info->type == 'U' || info->type == 'w')
+  if (bfd_is_undefined_symclass (info->type))
     {
       printf ("%*s",
 #ifdef BFD64
@@ -1458,7 +1458,7 @@ print_symbol_info_sysv (info, abfd)
      bfd *abfd;
 {
   print_symname ("%-20s|", info->name, abfd);  /* Name */
-  if (info->type == 'U' || info->type == 'w')
+  if (bfd_is_undefined_symclass (info->type))
     printf ("        ");       /* Value */
   else
     print_value (info->value);
@@ -1481,7 +1481,7 @@ print_symbol_info_posix (info, abfd)
 {
   print_symname ("%s ", info->name, abfd);
   printf ("%c ", info->type);
-  if (info->type == 'U' || info->type == 'w')
+  if (bfd_is_undefined_symclass (info->type))
     printf ("        ");
   else
     print_value (info->value);
This page took 0.042266 seconds and 4 git commands to generate.