aboutsummaryrefslogtreecommitdiff
path: root/binutils/nm.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-03-24 04:23:11 -0700
committerH.J. Lu <hjl.tools@gmail.com>2020-03-24 04:23:11 -0700
commit7e6e972f74aeac0ebdbd95a7f905d871cd2581de (patch)
treeacbfcc916da7663766a6eb079c70ccdf8fa1f0d1 /binutils/nm.c
parenta64fafb54577a87919a600474a3e4abe3510341a (diff)
downloadgdb-7e6e972f74aeac0ebdbd95a7f905d871cd2581de.zip
gdb-7e6e972f74aeac0ebdbd95a7f905d871cd2581de.tar.gz
gdb-7e6e972f74aeac0ebdbd95a7f905d871cd2581de.tar.bz2
bfd: Display symbol version for nm -D
Extend _bfd_elf_get_symbol_version_string for nm -D to display symbol version. _bfd_elf_get_symbol_version_name is added to avoid updating all XXX_get_symbol_version_string functions. bfd/ PR binutils/25708 * elf-bfd.h (_bfd_elf_get_symbol_version_name): New. * elf.c (_bfd_elf_get_symbol_version_name): New function. Based on the previous _bfd_elf_get_symbol_version_string. (_bfd_elf_get_symbol_version_string): Use it. binutils/ PR binutils/25708 * nm.c (SYM_NAME): Removed. (print_symname): Add a pointer to struct extended_symbol_info argument. Call _bfd_elf_get_symbol_version_name to get symbol version. (print_symdef_entry): Pass NULL to print_symname. (print_symbol_info_bsd): Update call to print_symname. (print_symbol_info_sysv): Likewise. (print_symbol_info_posix): Likewise. ld/ PR binutils/25708 * testsuite/ld-elf/pr25708.d: New file.
Diffstat (limited to 'binutils/nm.c')
-rw-r--r--binutils/nm.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/binutils/nm.c b/binutils/nm.c
index 0ee3f88..0e475f8 100644
--- a/binutils/nm.c
+++ b/binutils/nm.c
@@ -67,7 +67,6 @@ struct extended_symbol_info
coff_symbol_type *coffinfo;
/* FIXME: We should add more fields for Type, Line, Section. */
};
-#define SYM_NAME(sym) (sym->sinfo->name)
#define SYM_VALUE(sym) (sym->sinfo->value)
#define SYM_TYPE(sym) (sym->sinfo->type)
#define SYM_STAB_NAME(sym) (sym->sinfo->stab_name)
@@ -394,8 +393,11 @@ get_coff_symbol_type (const struct internal_syment *sym)
demangling it if requested. */
static void
-print_symname (const char *form, const char *name, bfd *abfd)
+print_symname (const char *form, struct extended_symbol_info *info,
+ const char *name, bfd *abfd)
{
+ if (name == NULL)
+ name = info->sinfo->name;
if (do_demangle && *name)
{
char *res = bfd_demangle (abfd, name, demangle_flags);
@@ -409,6 +411,18 @@ print_symname (const char *form, const char *name, bfd *abfd)
}
printf (form, name);
+ if (info != NULL && info->elfinfo)
+ {
+ const char *version_string;
+ bfd_boolean hidden;
+
+ version_string
+ = _bfd_elf_get_symbol_version_name (abfd,
+ &info->elfinfo->symbol,
+ FALSE, &hidden);
+ if (version_string && version_string[0])
+ printf ("%s%s", hidden ? "@" : "@@", version_string);
+ }
}
static void
@@ -433,7 +447,7 @@ print_symdef_entry (bfd *abfd)
bfd_fatal ("bfd_get_elt_at_index");
if (thesym->name != (char *) NULL)
{
- print_symname ("%s", thesym->name, abfd);
+ print_symname ("%s", NULL, thesym->name, abfd);
printf (" in %s\n", bfd_get_filename (elt));
}
}
@@ -1606,13 +1620,13 @@ print_symbol_info_bsd (struct extended_symbol_info *info, bfd *abfd)
printf (desc_format, SYM_STAB_DESC (info));
printf (" %5s", SYM_STAB_NAME (info));
}
- print_symname (" %s", SYM_NAME (info), abfd);
+ print_symname (" %s", info, NULL, abfd);
}
static void
print_symbol_info_sysv (struct extended_symbol_info *info, bfd *abfd)
{
- print_symname ("%-20s|", SYM_NAME (info), abfd);
+ print_symname ("%-20s|", info, NULL, abfd);
if (bfd_is_undefined_symclass (SYM_TYPE (info)))
{
@@ -1667,7 +1681,7 @@ print_symbol_info_sysv (struct extended_symbol_info *info, bfd *abfd)
static void
print_symbol_info_posix (struct extended_symbol_info *info, bfd *abfd)
{
- print_symname ("%s ", SYM_NAME (info), abfd);
+ print_symname ("%s ", info, NULL, abfd);
printf ("%c ", SYM_TYPE (info));
if (bfd_is_undefined_symclass (SYM_TYPE (info)))