aboutsummaryrefslogtreecommitdiff
path: root/bfd
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 /bfd
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 'bfd')
-rw-r--r--bfd/ChangeLog8
-rw-r--r--bfd/elf-bfd.h2
-rw-r--r--bfd/elf.c27
3 files changed, 31 insertions, 6 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index da8e058..7cc34c1 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,11 @@
+2020-03-24 H.J. Lu <hongjiu.lu@intel.com>
+
+ 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.
+
2020-03-24 Alan Modra <amodra@gmail.com>
* archive.c (_bfd_generic_read_ar_hdr_mag): Sanity check extended
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index d4ac515..c546b58 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -2078,6 +2078,8 @@ extern bfd_boolean _bfd_elf_print_private_bfd_data
(bfd *, void *);
const char * _bfd_elf_get_symbol_version_string
(bfd *, asymbol *, bfd_boolean *);
+const char * _bfd_elf_get_symbol_version_name
+ (bfd *, asymbol *, bfd_boolean, bfd_boolean *);
extern void bfd_elf_print_symbol
(bfd *, void *, asymbol *, bfd_print_symbol_type);
diff --git a/bfd/elf.c b/bfd/elf.c
index 975eeb0..1004809 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1883,11 +1883,13 @@ _bfd_elf_print_private_bfd_data (bfd *abfd, void *farg)
return FALSE;
}
-/* Get version string. */
+/* Get version name. If BASE_P is TRUE, return "Base" for VER_FLG_BASE
+ and return symbol version for symbol version itself. */
const char *
-_bfd_elf_get_symbol_version_string (bfd *abfd, asymbol *symbol,
- bfd_boolean *hidden)
+_bfd_elf_get_symbol_version_name (bfd *abfd, asymbol *symbol,
+ bfd_boolean base_p,
+ bfd_boolean *hidden)
{
const char *version_string = NULL;
if (elf_dynversym (abfd) != 0
@@ -1904,10 +1906,14 @@ _bfd_elf_get_symbol_version_string (bfd *abfd, asymbol *symbol,
&& (vernum > elf_tdata (abfd)->cverdefs
|| (elf_tdata (abfd)->verdef[0].vd_flags
== VER_FLG_BASE)))
- version_string = "Base";
+ version_string = base_p ? "Base" : "";
else if (vernum <= elf_tdata (abfd)->cverdefs)
- version_string =
- elf_tdata (abfd)->verdef[vernum - 1].vd_nodename;
+ {
+ const char *nodename
+ = elf_tdata (abfd)->verdef[vernum - 1].vd_nodename;
+ version_string = ((base_p || strcmp (symbol->name, nodename))
+ ? nodename : "");
+ }
else
{
Elf_Internal_Verneed *t;
@@ -1933,6 +1939,15 @@ _bfd_elf_get_symbol_version_string (bfd *abfd, asymbol *symbol,
return version_string;
}
+/* Get version string. */
+
+const char *
+_bfd_elf_get_symbol_version_string (bfd *abfd, asymbol *symbol,
+ bfd_boolean *hidden)
+{
+ return _bfd_elf_get_symbol_version_name (abfd, symbol, TRUE, hidden);
+}
+
/* Display ELF-specific fields of a symbol. */
void