From 1081065c519d1bfc3847bf4b0a0ce4bc3224bcd3 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 24 Mar 2020 15:37:14 -0700 Subject: [PATCH] bfd: Add a bfd_boolean argument to bfd_get_symbol_version_string We can't call _bfd_elf_get_symbol_version_name from nm.c since it isn't available for all target configurations. This patch add a bfd_boolean argument to bfd_get_symbol_version_string instead. bfd/ PR binutils/25708 * elf-bfd.h (_bfd_elf_get_symbol_version_name): Renamed to ... (_bfd_elf_get_symbol_version_string): This. * elf.c (_bfd_elf_get_symbol_version_name): Renamed to ... (_bfd_elf_get_symbol_version_string): This. (bfd_elf_print_symbol): Pass TRUE to _bfd_elf_get_symbol_version_string. * libbfd-in.h (_bfd_nosymbols_get_symbol_version_string): Add a bfd_boolean argument. * syms.c (_bfd_nosymbols_get_symbol_version_string): Likewise. * targets.c (_bfd_get_symbol_version_string): Likewise. (bfd_get_symbol_version_string): Likewise. * bfd-in2.h: Regenerated. binutils/ PR binutils/25708 * nm.c (print_symname): Replace _bfd_elf_get_symbol_version_name with bfd_get_symbol_version_string. (print_symbo): Pass TRUE to bfd_get_symbol_version_string. * objdump.c (objdump_print_symname): Likewise. --- bfd/ChangeLog | 16 ++++++++++++++++ bfd/bfd-in2.h | 5 +++-- bfd/elf-bfd.h | 2 -- bfd/elf.c | 16 ++++------------ bfd/libbfd-in.h | 2 +- bfd/libbfd.h | 2 +- bfd/syms.c | 1 + bfd/targets.c | 5 +++-- binutils/ChangeLog | 8 ++++++++ binutils/nm.c | 8 ++++---- binutils/objdump.c | 3 ++- 11 files changed, 43 insertions(+), 25 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 4120b968e3a..f273ea54e9b 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,19 @@ +2020-03-24 H.J. Lu + + PR binutils/25708 + * elf-bfd.h (_bfd_elf_get_symbol_version_name): Renamed to ... + (_bfd_elf_get_symbol_version_string): This. + * elf.c (_bfd_elf_get_symbol_version_name): Renamed to ... + (_bfd_elf_get_symbol_version_string): This. + (bfd_elf_print_symbol): Pass TRUE to + _bfd_elf_get_symbol_version_string. + * libbfd-in.h (_bfd_nosymbols_get_symbol_version_string): Add a + bfd_boolean argument. + * syms.c (_bfd_nosymbols_get_symbol_version_string): Likewise. + * targets.c (_bfd_get_symbol_version_string): Likewise. + (bfd_get_symbol_version_string): Likewise. + * bfd-in2.h: Regenerated. + 2020-03-24 Nick Clifton Jaydeep Chauhan diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 14e2e3b4819..a5f0609fbb9 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -7514,9 +7514,10 @@ typedef struct bfd_target #define bfd_get_symbol_info(b,p,e) \ BFD_SEND (b, _bfd_get_symbol_info, (b,p,e)) const char *(*_bfd_get_symbol_version_string) (bfd *, struct bfd_symbol *, + bfd_boolean, bfd_boolean *); -#define bfd_get_symbol_version_string(b,s,h) \ - BFD_SEND (b, _bfd_get_symbol_version_string, (b,s,h)) +#define bfd_get_symbol_version_string(b,s,p,h) \ + BFD_SEND (b, _bfd_get_symbol_version_string, (b,s,p,h)) bfd_boolean (*_bfd_is_local_label_name) (bfd *, const char *); bfd_boolean (*_bfd_is_target_special_symbol) (bfd *, asymbol *); alent * (*_get_lineno) (bfd *, struct bfd_symbol *); diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 5f3a5cc04b1..03e2b6fe85a 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -2077,8 +2077,6 @@ extern bfd_boolean _bfd_elf_copy_private_bfd_data 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 f5354d2c7a1..2512b6543b1 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -1887,9 +1887,9 @@ _bfd_elf_print_private_bfd_data (bfd *abfd, void *farg) and return symbol version for symbol version itself. */ const char * -_bfd_elf_get_symbol_version_name (bfd *abfd, asymbol *symbol, - bfd_boolean base_p, - bfd_boolean *hidden) +_bfd_elf_get_symbol_version_string (bfd *abfd, asymbol *symbol, + bfd_boolean base_p, + bfd_boolean *hidden) { const char *version_string = NULL; if (elf_dynversym (abfd) != 0 @@ -1939,15 +1939,6 @@ _bfd_elf_get_symbol_version_name (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 @@ -2003,6 +1994,7 @@ bfd_elf_print_symbol (bfd *abfd, /* If we have version information, print it. */ version_string = _bfd_elf_get_symbol_version_string (abfd, symbol, + TRUE, &hidden); if (version_string) { diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h index c8cf079a919..5d24efbeb26 100644 --- a/bfd/libbfd-in.h +++ b/bfd/libbfd-in.h @@ -447,7 +447,7 @@ extern void _bfd_nosymbols_print_symbol extern void _bfd_nosymbols_get_symbol_info (bfd *, asymbol *, symbol_info *) ATTRIBUTE_HIDDEN; extern const char * _bfd_nosymbols_get_symbol_version_string - (bfd *, asymbol *, bfd_boolean *) ATTRIBUTE_HIDDEN; + (bfd *, asymbol *, bfd_boolean, bfd_boolean *) ATTRIBUTE_HIDDEN; extern bfd_boolean _bfd_nosymbols_bfd_is_local_label_name (bfd *, const char *) ATTRIBUTE_HIDDEN; #define _bfd_nosymbols_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false diff --git a/bfd/libbfd.h b/bfd/libbfd.h index 3c184fcadad..348ccfd4b57 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -452,7 +452,7 @@ extern void _bfd_nosymbols_print_symbol extern void _bfd_nosymbols_get_symbol_info (bfd *, asymbol *, symbol_info *) ATTRIBUTE_HIDDEN; extern const char * _bfd_nosymbols_get_symbol_version_string - (bfd *, asymbol *, bfd_boolean *) ATTRIBUTE_HIDDEN; + (bfd *, asymbol *, bfd_boolean, bfd_boolean *) ATTRIBUTE_HIDDEN; extern bfd_boolean _bfd_nosymbols_bfd_is_local_label_name (bfd *, const char *) ATTRIBUTE_HIDDEN; #define _bfd_nosymbols_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false diff --git a/bfd/syms.c b/bfd/syms.c index c1de8ebab17..76c212344eb 100644 --- a/bfd/syms.c +++ b/bfd/syms.c @@ -1468,6 +1468,7 @@ _bfd_nosymbols_get_symbol_info (bfd *abfd ATTRIBUTE_UNUSED, const char * _bfd_nosymbols_get_symbol_version_string (bfd *abfd, asymbol *symbol ATTRIBUTE_UNUSED, + bfd_boolean base_p ATTRIBUTE_UNUSED, bfd_boolean *hidden ATTRIBUTE_UNUSED) { return (const char *) _bfd_ptr_bfd_null_error (abfd); diff --git a/bfd/targets.c b/bfd/targets.c index 39683e83d41..d05b9158536 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -392,9 +392,10 @@ BFD_JUMP_TABLE macros. .#define bfd_get_symbol_info(b,p,e) \ . BFD_SEND (b, _bfd_get_symbol_info, (b,p,e)) . const char *(*_bfd_get_symbol_version_string) (bfd *, struct bfd_symbol *, +. bfd_boolean, . bfd_boolean *); -.#define bfd_get_symbol_version_string(b,s,h) \ -. BFD_SEND (b, _bfd_get_symbol_version_string, (b,s,h)) +.#define bfd_get_symbol_version_string(b,s,p,h) \ +. BFD_SEND (b, _bfd_get_symbol_version_string, (b,s,p,h)) . bfd_boolean (*_bfd_is_local_label_name) (bfd *, const char *); . bfd_boolean (*_bfd_is_target_special_symbol) (bfd *, asymbol *); . alent * (*_get_lineno) (bfd *, struct bfd_symbol *); diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 2565f36db26..accd265007e 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,11 @@ +2020-03-24 H.J. Lu + + PR binutils/25708 + * nm.c (print_symname): Replace _bfd_elf_get_symbol_version_name + with bfd_get_symbol_version_string. + (print_symbo): Pass TRUE to bfd_get_symbol_version_string. + * objdump.c (objdump_print_symname): Likewise. + 2020-03-24 H.J. Lu PR binutils/25708 diff --git a/binutils/nm.c b/binutils/nm.c index 0e475f80063..1b5122d56ab 100644 --- a/binutils/nm.c +++ b/binutils/nm.c @@ -417,9 +417,8 @@ print_symname (const char *form, struct extended_symbol_info *info, bfd_boolean hidden; version_string - = _bfd_elf_get_symbol_version_name (abfd, - &info->elfinfo->symbol, - FALSE, &hidden); + = bfd_get_symbol_version_string (abfd, &info->elfinfo->symbol, + FALSE, &hidden); if (version_string && version_string[0]) printf ("%s%s", hidden ? "@" : "@@", version_string); } @@ -908,7 +907,8 @@ print_symbol (bfd * abfd, bfd_boolean hidden = FALSE; if ((sym->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0) - version_string = bfd_get_symbol_version_string (abfd, sym, &hidden); + version_string = bfd_get_symbol_version_string (abfd, sym, + TRUE, &hidden); if (bfd_is_und_section (bfd_asymbol_section (sym))) hidden = TRUE; diff --git a/binutils/objdump.c b/binutils/objdump.c index 211be9239f8..81c0b4f3d06 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -1031,7 +1031,8 @@ objdump_print_symname (bfd *abfd, struct disassemble_info *inf, } if ((sym->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0) - version_string = bfd_get_symbol_version_string (abfd, sym, &hidden); + version_string = bfd_get_symbol_version_string (abfd, sym, TRUE, + &hidden); if (bfd_is_und_section (bfd_asymbol_section (sym))) hidden = TRUE; -- 2.30.2