Apply patch from Thomas de Lellis to allow nm to distinguish between weak

function symbols and weak data symbols.
This commit is contained in:
Nick Clifton 2000-01-28 01:06:37 +00:00
parent 58efb6c0fd
commit fad6fcbb00
6 changed files with 86 additions and 13 deletions

View 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

View 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));

View 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;
}

View 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

View 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

View 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);