]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Return symbol from symbol_at_address_func
authorAlan Modra <amodra@gmail.com>
Tue, 6 Apr 2021 09:27:04 +0000 (18:57 +0930)
committerAlan Modra <amodra@gmail.com>
Tue, 6 Apr 2021 13:55:09 +0000 (23:25 +0930)
include/
* dis-asm.h (struct disassemble_info <symbol_at_address_func>):
Return asymbol*.
binutils/
* objdump.c (objdump_symbol_at_address): Return asymbol*.
opcodes/
* dis-buf.c (generic_symbol_at_address): Return symbol* NULL.
* s12z-dis.c (decode_possible_symbol): Use symbol returned from
symbol_at_address_func.

binutils/ChangeLog
binutils/objdump.c
include/ChangeLog
include/dis-asm.h
opcodes/ChangeLog
opcodes/dis-buf.c
opcodes/s12z-dis.c

index 13fa6d2d40114ee2da4058801845815f93ac51d8..413757d685921f9cf87fee488c3045ab9883049c 100644 (file)
@@ -1,3 +1,7 @@
+2021-04-06  Alan Modra  <amodra@gmail.com>
+
+       * objdump.c (objdump_symbol_at_address): Return asymbol*.
+
 2021-04-06  Alan Modra  <amodra@gmail.com>
 
        * NEWS: Mention C99 requirement.
index aa1215cede8f781846e7aa77275bdb52d7ce97f7..ea80a704ee39e44a393de085cf3ada0b527dd79e 100644 (file)
@@ -1459,14 +1459,16 @@ objdump_print_address (bfd_vma vma, struct disassemble_info *inf)
 
 /* Determine if the given address has a symbol associated with it.  */
 
-static int
+static asymbol *
 objdump_symbol_at_address (bfd_vma vma, struct disassemble_info * inf)
 {
   asymbol * sym;
 
   sym = find_symbol_for_address (vma, inf, NULL);
+  if (sym != NULL && bfd_asymbol_value (sym) == vma)
+    return sym;
 
-  return (sym != NULL && (bfd_asymbol_value (sym) == vma));
+  return NULL;
 }
 
 /* Hold the last function name and the last line number we displayed
index 9eb5f0a7bedefe72e0b9f6c4e64999c0b1a397e7..639f2bf932433a0899f01e7bce23f68fa0ac0bdd 100644 (file)
@@ -1,3 +1,8 @@
+2021-04-06  Alan Modra  <amodra@gmail.com>
+
+       * dis-asm.h (struct disassemble_info <symbol_at_address_func>):
+       Return asymbol*.
+
 2021-04-01  Martin Liska  <mliska@suse.cz>
 
        * opcode/cr16.h (strneq): Remove strneq and use startswith.
index 4f5008436d4f2ac42ab5e48d725723674d868b08..f3562faa000a32f8c849e661b655851b83a21f1e 100644 (file)
@@ -144,13 +144,13 @@ typedef struct disassemble_info
      some circumstances we want to include the overlay number in the
      address, (normally because there is a symbol associated with
      that address), but sometimes we want to mask out the overlay bits.  */
-  int (* symbol_at_address_func)
+  asymbol * (*symbol_at_address_func)
     (bfd_vma addr, struct disassemble_info *dinfo);
 
   /* Function called to check if a SYMBOL is can be displayed to the user.
      This is used by some ports that want to hide special symbols when
      displaying debugging outout.  */
-  bool (* symbol_is_valid)
+  bool (*symbol_is_valid)
     (asymbol *, struct disassemble_info *dinfo);
 
   /* These are for buffer_read_memory.  */
@@ -376,11 +376,11 @@ extern void perror_memory (int, bfd_vma, struct disassemble_info *);
 extern void generic_print_address
   (bfd_vma, struct disassemble_info *);
 
-/* Always true.  */
-extern int generic_symbol_at_address
+/* Always NULL.  */
+extern asymbol *generic_symbol_at_address
   (bfd_vma, struct disassemble_info *);
 
-/* Also always true.  */
+/* Always true.  */
 extern bool generic_symbol_is_valid
   (asymbol *, struct disassemble_info *);
 
index f3572a60cb8e3395c9dd52a8587d400254d0f8da..7a380dc0087eb11e086f2fb0334fe571a50c34d2 100644 (file)
@@ -1,3 +1,9 @@
+2021-04-06  Alan Modra  <amodra@gmail.com>
+
+       * dis-buf.c (generic_symbol_at_address): Return symbol* NULL.
+       * s12z-dis.c (decode_possible_symbol): Use symbol returned from
+       symbol_at_address_func.
+
 2021-04-05  Alan Modra  <amodra@gmail.com>
 
        * configure.ac: Don't check for limits.h, string.h, strings.h or
index 2a934652a1ef1b2784a800232317203ef9982438..dfc1563f09d72ef6391dd36a0c26356176a55001 100644 (file)
@@ -87,13 +87,13 @@ generic_print_address (bfd_vma addr, struct disassemble_info *info)
   (*info->fprintf_func) (info->stream, "0x%s", buf);
 }
 
-/* Just return true.  */
+/* Just return NULL.  */
 
-int
+asymbol *
 generic_symbol_at_address (bfd_vma addr ATTRIBUTE_UNUSED,
                           struct disassemble_info *info ATTRIBUTE_UNUSED)
 {
-  return 1;
+  return NULL;
 }
 
 /* Just return TRUE.  */
index 4616bc827111413de87b7b26650170579a92a51a..ec8f4f708837021048db85aef99d563ed32b4a0d 100644 (file)
@@ -206,27 +206,12 @@ decode_possible_symbol (bfd_vma addr, bfd_vma base,
                         struct disassemble_info *info, bool relative)
 {
   const char *fmt = relative  ? "*%+" BFD_VMA_FMT "d" : "%" BFD_VMA_FMT "d";
-  if (!info->symbol_at_address_func (addr + base, info))
-    {
-      (*info->fprintf_func) (info->stream, fmt, addr);
-    }
+  asymbol *sym = info->symbol_at_address_func (addr + base, info);
+
+  if (!sym)
+    (*info->fprintf_func) (info->stream, fmt, addr);
   else
-    {
-      asymbol *sym = NULL;
-      int j;
-      for (j = 0; j < info->symtab_size; ++j)
-       {
-         sym = info->symtab[j];
-         if (bfd_asymbol_value (sym) == addr + base)
-           {
-             break;
-           }
-       }
-      if (j < info->symtab_size)
-       (*info->fprintf_func) (info->stream, "%s", bfd_asymbol_name (sym));
-      else
-        (*info->fprintf_func) (info->stream, fmt, addr);
-    }
+    (*info->fprintf_func) (info->stream, "%s", bfd_asymbol_name (sym));
 }