PR23652, Use symbols from debug bfd for _bfd_elf_find_function properly
authorAlan Modra <amodra@gmail.com>
Wed, 27 Nov 2019 07:30:59 +0000 (18:00 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 27 Nov 2019 08:40:11 +0000 (19:10 +1030)
There were a number of problems with the previous patch.  Firstly,
_bfd_dwarf2_stash_syms didn't do anything when the original file had
dynamic symbols, and secondly, info found by the symbol search didn't
make it out of _bfd_elf_find_nearest_line except in the case of DWARF
functions without external linkage.

PR 23652
* dwarf2.c (_bfd_dwarf2_stash_syms): Break out of loop on finding
matching section.
(_bfd_dwarf2_find_nearest_line): Return an int, with value 2 when
returning info from the symbol table.  Do the _bfd_elf_find_function
search also when !found.  Call _bfd_dwarf2_stash_syms regardless of
symbols.
* elf64-alpha.c (elf64_alpha_find_nearest_line): Accept dwarf2
result of 1 only.
* elfxx-mips.c (_bfd_mips_elf_find_nearest_line): Likewise.
* libbfd-in.h (_bfd_dwarf2_find_nearest_line): Update prototype.
* libbfd.h: Regenerate.

bfd/ChangeLog
bfd/dwarf2.c
bfd/elf64-alpha.c
bfd/elfxx-mips.c
bfd/libbfd-in.h
bfd/libbfd.h

index 4a0852e577d314ab19d762c625d52e2916c0dbc8..ab9174d71e4338d2771f93e2d7167ef28bb71ecf 100644 (file)
@@ -1,3 +1,18 @@
+2019-11-27  Alan Modra  <amodra@gmail.com>
+
+       PR 23652
+       * dwarf2.c (_bfd_dwarf2_stash_syms): Break out of loop on finding
+       matching section.
+       (_bfd_dwarf2_find_nearest_line): Return an int, with value 2 when
+       returning info from the symbol table.  Do the _bfd_elf_find_function
+       search also when !found.  Call _bfd_dwarf2_stash_syms regardless of
+       symbols.
+       * elf64-alpha.c (elf64_alpha_find_nearest_line): Accept dwarf2
+       result of 1 only.
+       * elfxx-mips.c (_bfd_mips_elf_find_nearest_line): Likewise.
+       * libbfd-in.h (_bfd_dwarf2_find_nearest_line): Update prototype.
+       * libbfd.h: Regenerate.
+
 2019-11-27  Alan Modra  <amodra@gmail.com>
 
        PR 23652
index e42483a535ab334dca2bbf50e35f191536b26953..a25f76ac2bd98bc8a1aac8e27100119f13389bd8 100644 (file)
@@ -3923,6 +3923,7 @@ _bfd_dwarf2_stash_syms (struct dwarf2_debug *stash, bfd *abfd,
            {
              *sec = d;
              *syms = stash->syms;
+             break;
            }
        }
     }
@@ -4692,15 +4693,19 @@ _bfd_dwarf2_find_symbol_bias (asymbol ** symbols, void ** pinfo)
 /* Find the source code location of SYMBOL.  If SYMBOL is NULL
    then find the nearest source code location corresponding to
    the address SECTION + OFFSET.
-   Returns TRUE if the line is found without error and fills in
+   Returns 1 if the line is found without error and fills in
    FILENAME_PTR and LINENUMBER_PTR.  In the case where SYMBOL was
    NULL the FUNCTIONNAME_PTR is also filled in.
+   Returns 2 if partial information from _bfd_elf_find_function is
+   returned (function and maybe file) by looking at symbols.  DWARF2
+   info is present but not regarding the requested code location.
+   Returns 0 otherwise.
    SYMBOLS contains the symbol table for ABFD.
    DEBUG_SECTIONS contains the name of the dwarf debug sections.
    field and in the abbreviation offset, or zero to indicate that the
    default value should be used.  */
 
-bfd_boolean
+int
 _bfd_dwarf2_find_nearest_line (bfd *abfd,
                               asymbol **symbols,
                               asymbol *symbol,
@@ -4726,7 +4731,7 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd,
   bfd_vma addr;
   struct comp_unit* each;
   struct funcinfo *function = NULL;
-  bfd_boolean found = FALSE;
+  int found = FALSE;
   bfd_boolean do_line;
 
   *filename_ptr = NULL;
@@ -4925,19 +4930,21 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd,
   if (functionname_ptr && function && function->is_linkage)
     *functionname_ptr = function->name;
   else if (functionname_ptr
-          && ((found && !*functionname_ptr)
+          && (!*functionname_ptr
               || (function && !function->is_linkage)))
     {
       asymbol *fun;
       asymbol **syms = symbols;
       asection *sec = section;
 
-      if (symbols == NULL || *symbols == NULL)
-       _bfd_dwarf2_stash_syms (stash, abfd, &sec, &syms);
+      _bfd_dwarf2_stash_syms (stash, abfd, &sec, &syms);
       fun = _bfd_elf_find_function (abfd, syms, sec, offset,
                                    *filename_ptr ? NULL : filename_ptr,
                                    functionname_ptr);
 
+      if (!found && fun != NULL)
+       found = 2;
+
       if (function && !function->is_linkage)
        {
          bfd_vma sec_vma;
index d4ac0c1469319eeb763d63f650f8b75c2f5a0ae4..f312a6e03d640691927260cdc8e581378b5342c1 100644 (file)
@@ -1468,7 +1468,8 @@ elf64_alpha_find_nearest_line (bfd *abfd, asymbol **symbols,
                                     filename_ptr, functionname_ptr,
                                     line_ptr, discriminator_ptr,
                                     dwarf_debug_sections,
-                                    &elf_tdata (abfd)->dwarf2_find_line_info))
+                                    &elf_tdata (abfd)->dwarf2_find_line_info)
+      == 1)
     return TRUE;
 
   msec = bfd_get_section_by_name (abfd, ".mdebug");
index e9af7abd4b5d0be75b8e312866c00041d9da69e7..b1f83a0545d013ca27d79f7f046ab580921d842d 100644 (file)
@@ -13078,7 +13078,8 @@ _bfd_mips_elf_find_nearest_line (bfd *abfd, asymbol **symbols,
                                     filename_ptr, functionname_ptr,
                                     line_ptr, discriminator_ptr,
                                     dwarf_debug_sections,
-                                    &elf_tdata (abfd)->dwarf2_find_line_info))
+                                    &elf_tdata (abfd)->dwarf2_find_line_info)
+      == 1)
     return TRUE;
 
   if (_bfd_dwarf1_find_nearest_line (abfd, symbols, section, offset,
index f498ffd5e7a295dac69d25982597e83038e66537..64ae6c6e9149c81f0597030fb05bba063db3276c 100644 (file)
@@ -596,7 +596,7 @@ struct dwarf_debug_section
 extern const struct dwarf_debug_section dwarf_debug_sections[] ATTRIBUTE_HIDDEN;
 
 /* Find the nearest line using DWARF 2 debugging information.  */
-extern bfd_boolean _bfd_dwarf2_find_nearest_line
+extern int _bfd_dwarf2_find_nearest_line
   (bfd *, asymbol **, asymbol *, asection *, bfd_vma,
    const char **, const char **, unsigned int *, unsigned int *,
    const struct dwarf_debug_section *, void **) ATTRIBUTE_HIDDEN;
index 77b732ee4b08229889bfa3e2a078a7ff90d19caa..44cefbd66d46de79b2358ee3a9d52ad698df4050 100644 (file)
@@ -601,7 +601,7 @@ struct dwarf_debug_section
 extern const struct dwarf_debug_section dwarf_debug_sections[] ATTRIBUTE_HIDDEN;
 
 /* Find the nearest line using DWARF 2 debugging information.  */
-extern bfd_boolean _bfd_dwarf2_find_nearest_line
+extern int _bfd_dwarf2_find_nearest_line
   (bfd *, asymbol **, asymbol *, asection *, bfd_vma,
    const char **, const char **, unsigned int *, unsigned int *,
    const struct dwarf_debug_section *, void **) ATTRIBUTE_HIDDEN;
This page took 0.030338 seconds and 4 git commands to generate.