bfd: Add a bfd_boolean argument to bfd_get_symbol_version_string
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 24 Mar 2020 22:37:14 +0000 (15:37 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 24 Mar 2020 22:37:26 +0000 (15:37 -0700)
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
bfd/bfd-in2.h
bfd/elf-bfd.h
bfd/elf.c
bfd/libbfd-in.h
bfd/libbfd.h
bfd/syms.c
bfd/targets.c
binutils/ChangeLog
binutils/nm.c
binutils/objdump.c

index 4120b968e3a041d73b51b512de6cd5dafa3b79c4..f273ea54e9b25d06965e34f9ed3d2bb22c1cd0ca 100644 (file)
@@ -1,3 +1,19 @@
+2020-03-24  H.J. Lu  <hongjiu.lu@intel.com>
+
+       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  <nickc@redhat.com>
            Jaydeep Chauhan  <jaydeepchauhan1494@gmail.com>
 
index 14e2e3b481995b9a357d8294c73edd35efd08f40..a5f0609fbb9351b902df9fd5a20c028d8db462fe 100644 (file)
@@ -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 *);
index 5f3a5cc04b17aa825098f3567426f36b67d290dc..03e2b6fe85a96baf7783a0d34ede7552a5d5e513 100644 (file)
@@ -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);
index f5354d2c7a11cf62dd2679aaec14cf3d2804f2a1..2512b6543b1b19d3e141da8de041dc7d104babce 100644 (file)
--- 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)
          {
index c8cf079a919f14157d88c90059212619cc69385f..5d24efbeb269ddb91f425dc14d0db20e0397d509 100644 (file)
@@ -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
index 3c184fcadadf82cb093753f2d10ddeb6b0af9dd7..348ccfd4b5758cf361424032664375105b720564 100644 (file)
@@ -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
index c1de8ebab17c5e7633357d765c0dcc60ca308b9e..76c212344eb8631cdec209cc1223863ee84a6daa 100644 (file)
@@ -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);
index 39683e83d414f6689710491901e382d68bd47520..d05b9158536fc3239898474ac8d4e0ddca664b2e 100644 (file)
@@ -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 *);
index 2565f36db26cdcc89a7078628819a13eb4bdee85..accd265007efba09daec05da7cdc9fa90e5cd07a 100644 (file)
@@ -1,3 +1,11 @@
+2020-03-24  H.J. Lu  <hongjiu.lu@intel.com>
+
+       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  <hongjiu.lu@intel.com>
 
        PR binutils/25708
index 0e475f8006345a1b5ddf54680ef726c3c26e6d17..1b5122d56ab5c00fc710a775053eb2ee300b0665 100644 (file)
@@ -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;
index 211be9239f885739a0d4cc188db12e1fa1423e3b..81c0b4f3d065fe939a7aee8a66235bc30341c466 100644 (file)
@@ -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;