From: Nick Clifton Date: Fri, 28 Jan 2000 01:06:37 +0000 (+0000) Subject: Apply patch from Thomas de Lellis to allow nm to distinguish between weak X-Git-Tag: gdb-2000-01-31~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fad6fcbb0080ab85b3c911b5b8b59852b7a5bfc7;p=external%2Fbinutils.git Apply patch from Thomas de Lellis to allow nm to distinguish between weak function symbols and weak data symbols. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 9d7c9f6..c2e7498 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,23 @@ -2000-01-27 Thomas de Lellis +2000-01-27 Thomas de Lellis + + * 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 diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index a9b981c..9db6ec6 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -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)); diff --git a/bfd/syms.c b/bfd/syms.c index 676f067..6546f58 100644 --- a/bfd/syms.c +++ b/bfd/syms.c @@ -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 '?'; @@ -617,6 +631,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 DESCRIPTION @@ -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; } diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 89d6520..f20c78f 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,12 @@ +2000-27-01 Thomas de Lellis + + * 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 * binutils.texi (objdump): Document new ARM specific diff --git a/binutils/binutils.texi b/binutils/binutils.texi index 44887d0..95c684a 100644 --- a/binutils/binutils.texi +++ b/binutils/binutils.texi @@ -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 diff --git a/binutils/nm.c b/binutils/nm.c index 3e2ee12..ade3f7c 100644 --- a/binutils/nm.c +++ b/binutils/nm.c @@ -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);