public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] bfd: Add bfd_find_nearest_line_with_alt
@ 2022-09-06 14:54 Aaron Merey
  0 siblings, 0 replies; only message in thread
From: Aaron Merey @ 2022-09-06 14:54 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6e7a29c7de4e1df679f2b6f6449b20474fbbcfdf

commit 6e7a29c7de4e1df679f2b6f6449b20474fbbcfdf
Author: Aaron Merey <amerey@redhat.com>
Date:   Fri Sep 2 14:16:30 2022 -0400

    bfd: Add bfd_find_nearest_line_with_alt
    
    bfd_find_nearest_line_with_alt functions like bfd_find_nearest_line with
    the addition of a parameter for specifying the filename of a supplementary
    debug file such as one referenced by .gnu_debugaltlink or .debug_sup.
    
    This patch focuses on implementing bfd_find_nearest_line_with_alt
    support for ELF/DWARF2 .gnu_debugaltlink. For other targets this
    function simply sets the invalid_operation bfd_error.

Diff:
---
 bfd/ChangeLog       | 49 +++++++++++++++++++++++++++++++++++++++
 bfd/aout-target.h   |  3 +++
 bfd/bfd-in2.h       | 11 +++++++++
 bfd/bfd.c           |  5 ++++
 bfd/binary.c        |  1 +
 bfd/coff-rs6000.c   |  2 ++
 bfd/coff64-rs6000.c |  2 ++
 bfd/dwarf2.c        | 67 +++++++++++++++++++++++++++++++++++++++++++----------
 bfd/elf-bfd.h       |  3 +++
 bfd/elf.c           | 32 +++++++++++++++++++++----
 bfd/elf32-mips.c    |  2 ++
 bfd/elf64-mips.c    |  2 ++
 bfd/elfn32-mips.c   |  2 ++
 bfd/elfxx-mips.h    |  2 ++
 bfd/elfxx-target.h  |  4 ++++
 bfd/i386msdos.c     |  1 +
 bfd/ihex.c          |  1 +
 bfd/libbfd-in.h     | 11 +++++++++
 bfd/libbfd.h        | 11 +++++++++
 bfd/libcoff-in.h    |  2 ++
 bfd/libcoff.h       |  2 ++
 bfd/libecoff.h      |  2 ++
 bfd/mach-o.h        |  2 ++
 bfd/mmo.c           |  1 +
 bfd/pef.c           |  1 +
 bfd/plugin.c        |  1 +
 bfd/ppcboot.c       |  1 +
 bfd/som.h           |  3 +++
 bfd/srec.c          |  1 +
 bfd/syms.c          | 15 ++++++++++++
 bfd/targets.c       |  6 +++++
 bfd/tekhex.c        |  1 +
 bfd/verilog.c       |  1 +
 bfd/vms-alpha.c     |  2 ++
 bfd/wasm-module.c   |  1 +
 bfd/xsym.c          |  1 +
 36 files changed, 237 insertions(+), 17 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 50e60dad102..a0e1e87ea26 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,52 @@
+2022-09-02  Aaron Merey  <amerey@redhat.com>
+
+	* aout-target.h (MY_find_nearest_line_with_alt): New macro.
+	* bfd-in2.h: Regenerate.
+	* bfd.c (bfd_find_nearest_line_with_alt): New macro.
+	* binary.c (binary_find_nearest_line_with_alt): New macro.
+	* coff-rs6000.c (_bfd_xcoff_find_nearest_line_with_alt): New macro.
+	(rs6000_xcoff64_vec): Add coff_find_nearest_line_with_alt.
+	* dwarf2.c (_bfd_dwarf2_find_nearest_line): Calls
+	_bfd_dwarf2_find_nearest_line_with_alt.
+	(_bfd_dwarf2_find_nearest_line_with_alt): New function. Implements the
+	former _bfd_dwarf2_find_nearest_line. Adds parameter alt_filename.
+	Attempt to open alt_filename and use it as the .dwz file if not NULL.
+	* elf-bfd.h (_bfd_elf_find_nearest_line_with_alt): New declaration.
+	* elf.c (_bfd_elf_find_nearest_line): Calls
+	_bfd_elf_find_nearest_line_with_alt.
+	(_bfd_elf_find_nearest_line_with_alt): New function. Implements the
+	former _bfd_elf_find_nearest_line. Adds parameter alt_filename.
+	* elf32-mips.c (bfd_elf32_find_nearest_line_with_alt): New macro.
+	* elf64-mips.c (bfd_elf64_find_nearest_line_with_alt): New macro.
+	* elfn32-mips.c (bfd_elf32_find_nearest_line_with_alt): New macro.
+	* elfxx-mips.h (_bfd_mips_elf_find_nearest_line_with_alt): New macro.
+	* elfxx-target.h (bfd_elfNN_find_nearest_line_with_alt): New macro.
+	* i386mdos.c (msdos_find_nearest_line_with_alt): New macro.
+	* ihex.c (ihex_find_nearest_line_with_alt): New macro.
+	* libbfd-in.h (_bfd_nosymbols_find_nearest_line_with_alt): New
+	declaration.
+	(_bfd_dwarf2_find_nearest_line_with_alt): New declaration.
+	* libbfd.h: Regenerate.
+	* libcoff-in.h (coff_find_nearest_line_with_alt): New macro.
+	* libcoff.h: Regenerate.
+	* libecoff.h (_bfd_ecoff_find_nearest_line_with_alt): New macro.
+	* mach-o.h (bfd_mach_o_find_nearest_line_with_alt): New macro.
+	* mmo.c (mmo_find_nearest_line_with_alt): New macro.
+	* pef.c (bfd_pef_find_nearest_line_with_alt): New macro.
+	* plugin.c (bfd_plugin_find_nearest_line_with_alt): New macro.
+	* ppcboot.c (ppcboot_find_nearest_line_with_alt): New macro.
+	* som.h (som_find_nearest_line_with_alt): New macro.
+	* srec.c (srec_find_nearest_line_with_alt): New macro.
+	* syms.c (_bfd_nosymbols_find_nearest_line_with_alt): New function.
+	* targets.c (BFD_JUMP_TABLE_SYMBOLS): Add symbol for
+	NAME##_find_nearest_line_with_alt.
+	(_bfd_find_nearest_line_with_alt): Add declaration.
+	* tekhex.c (tekhex_find_nearest_line_with_alt): New macro.
+	* verilog.c (verilog_find_nearest_line_with_alt): New macro.
+	* vms-alpha.c (_bfd_vms_find_nearest_line_with_alt): New macro.
+	* wasm-module.c (wasm_find_nearest_line_with_alt): New macro.
+	* xsym.c (bfd_sym_find_nearest_line_with_alt): New macro.
+
 2022-09-02  Frederic Cambus  <fred@statdns.com>
 
 	* config.bfd (arm-*-openbsd*): Restore target.
diff --git a/bfd/aout-target.h b/bfd/aout-target.h
index bce90f14530..1b8c2f13fa8 100644
--- a/bfd/aout-target.h
+++ b/bfd/aout-target.h
@@ -475,6 +475,9 @@ MY_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
 #ifndef MY_find_nearest_line
 #define MY_find_nearest_line NAME (aout, find_nearest_line)
 #endif
+#ifndef MY_find_nearest_line_with_alt
+#define MY_find_nearest_line_with_alt _bfd_nosymbols_find_nearest_line_with_alt
+#endif
 #ifndef MY_find_line
 #define MY_find_line _bfd_nosymbols_find_line
 #endif
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 6aefdd7cdb2..79fcc4eb912 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -7162,6 +7162,11 @@ bool bfd_set_private_flags (bfd *abfd, flagword flags);
        BFD_SEND (abfd, _bfd_find_nearest_line, \
                  (abfd, syms, sec, off, file, func, line, NULL))
 
+#define bfd_find_nearest_line_with_alt(abfd, alt_filename, sec, syms, off, \
+                                       file, func, line, disc) \
+       BFD_SEND (abfd, _bfd_find_nearest_line_with_alt, \
+                 (abfd, alt_filename, syms, sec, off, file, func, line, disc))
+
 #define bfd_find_nearest_line_discriminator(abfd, sec, syms, off, file, func, \
                                            line, disc) \
        BFD_SEND (abfd, _bfd_find_nearest_line, \
@@ -7554,6 +7559,7 @@ typedef struct bfd_target
   NAME##_bfd_is_target_special_symbol, \
   NAME##_get_lineno, \
   NAME##_find_nearest_line, \
+  NAME##_find_nearest_line_with_alt, \
   NAME##_find_line, \
   NAME##_find_inliner_info, \
   NAME##_bfd_make_debug_symbol, \
@@ -7584,6 +7590,11 @@ typedef struct bfd_target
                                   struct bfd_section *, bfd_vma,
                                   const char **, const char **,
                                   unsigned int *, unsigned int *);
+  bool (*_bfd_find_nearest_line_with_alt) (bfd *, const char *,
+                                           struct bfd_symbol **,
+                                           struct bfd_section *, bfd_vma,
+                                           const char **, const char **,
+                                           unsigned int *, unsigned int *);
   bool (*_bfd_find_line) (bfd *, struct bfd_symbol **,
                           struct bfd_symbol *, const char **,
                           unsigned int *);
diff --git a/bfd/bfd.c b/bfd/bfd.c
index 5297177fd0b..0a21db11fd6 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -2050,6 +2050,11 @@ DESCRIPTION
 .	BFD_SEND (abfd, _bfd_find_nearest_line, \
 .		  (abfd, syms, sec, off, file, func, line, NULL))
 .
+.#define bfd_find_nearest_line_with_alt(abfd, alt_filename, sec, syms, off, \
+.					file, func, line, disc) \
+.	BFD_SEND (abfd, _bfd_find_nearest_line_with_alt, \
+.		  (abfd, alt_filename, syms, sec, off, file, func, line, disc))
+.
 .#define bfd_find_nearest_line_discriminator(abfd, sec, syms, off, file, func, \
 .					    line, disc) \
 .	BFD_SEND (abfd, _bfd_find_nearest_line, \
diff --git a/bfd/binary.c b/bfd/binary.c
index 999d41c0611..7abf4611af0 100644
--- a/bfd/binary.c
+++ b/bfd/binary.c
@@ -206,6 +206,7 @@ binary_get_symbol_info (bfd *ignore_abfd ATTRIBUTE_UNUSED,
 #define binary_bfd_is_local_label_name	    bfd_generic_is_local_label_name
 #define binary_get_lineno		   _bfd_nosymbols_get_lineno
 #define binary_find_nearest_line	   _bfd_nosymbols_find_nearest_line
+#define binary_find_nearest_line_with_alt  _bfd_nosymbols_find_nearest_line_with_alt
 #define binary_find_line		   _bfd_nosymbols_find_line
 #define binary_find_inliner_info	   _bfd_nosymbols_find_inliner_info
 #define binary_bfd_make_debug_symbol	   _bfd_nosymbols_bfd_make_debug_symbol
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index 3f0753e5bfc..bfa999d6980 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -4409,6 +4409,8 @@ const struct xcoff_dwsect_name xcoff_dwsect_names[] = {
   coff_bfd_is_target_special_symbol
 #define _bfd_xcoff_get_lineno coff_get_lineno
 #define _bfd_xcoff_find_nearest_line coff_find_nearest_line
+#define _bfd_xcoff_find_nearest_line_with_alt \
+coff_find_nearest_line_with_alt
 #define _bfd_xcoff_find_line coff_find_line
 #define _bfd_xcoff_find_inliner_info coff_find_inliner_info
 #define _bfd_xcoff_bfd_make_debug_symbol coff_bfd_make_debug_symbol
diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c
index c5dc95c1836..fa57910a811 100644
--- a/bfd/coff64-rs6000.c
+++ b/bfd/coff64-rs6000.c
@@ -2667,6 +2667,7 @@ const bfd_target rs6000_xcoff64_vec =
     coff_bfd_is_target_special_symbol,
     coff_get_lineno,
     coff_find_nearest_line,
+    coff_find_nearest_line_with_alt,
     coff_find_line,
     coff_find_inliner_info,
     coff_bfd_make_debug_symbol,
@@ -2939,6 +2940,7 @@ const bfd_target rs6000_xcoff64_aix_vec =
     coff_bfd_is_target_special_symbol,
     coff_get_lineno,
     coff_find_nearest_line,
+    coff_find_nearest_line_with_alt,
     coff_find_line,
     coff_find_inliner_info,
     coff_bfd_make_debug_symbol,
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index c513ef180bc..c55a3624367 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -5699,18 +5699,7 @@ _bfd_dwarf2_find_symbol_bias (asymbol ** symbols, void ** pinfo)
   return result;
 }
 
-/* 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 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.  */
+/* See _bfd_dwarf2_find_nearest_line_with_alt.  */
 
 int
 _bfd_dwarf2_find_nearest_line (bfd *abfd,
@@ -5724,6 +5713,43 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd,
 			       unsigned int *discriminator_ptr,
 			       const struct dwarf_debug_section *debug_sections,
 			       void **pinfo)
+{
+  return _bfd_dwarf2_find_nearest_line_with_alt
+    (abfd, NULL, symbols, symbol, section, offset, filename_ptr,
+     functionname_ptr, linenumber_ptr, discriminator_ptr, debug_sections,
+     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 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.
+   If ALT_FILENAME is given, attempt to open the file and use it
+   as the .gnu_debugaltlink file. Otherwise this file will be
+   searched for when needed.  */
+
+int
+_bfd_dwarf2_find_nearest_line_with_alt
+  (bfd *abfd,
+   const char *alt_filename,
+   asymbol **symbols,
+   asymbol *symbol,
+   asection *section,
+   bfd_vma offset,
+   const char **filename_ptr,
+   const char **functionname_ptr,
+   unsigned int *linenumber_ptr,
+   unsigned int *discriminator_ptr,
+   const struct dwarf_debug_section *debug_sections,
+   void **pinfo)
 {
   /* Read each compilation unit from the section .debug_info, and check
      to see if it contains the address we are searching for.  If yes,
@@ -5755,6 +5781,23 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd,
 
   stash = (struct dwarf2_debug *) *pinfo;
 
+  if (stash->alt.bfd_ptr == NULL && alt_filename != NULL)
+    {
+      bfd *alt_bfd = bfd_openr (alt_filename, NULL);
+
+      if (alt_bfd == NULL)
+	/* bfd_openr will have set the bfd_error.  */
+	return false;
+      if (!bfd_check_format (alt_bfd, bfd_object))
+	{
+	  bfd_set_error (bfd_error_wrong_format);
+	  bfd_close (alt_bfd);
+	  return false;
+	}
+
+      stash->alt.bfd_ptr = alt_bfd;
+    }
+
   do_line = symbol != NULL;
   if (do_line)
     {
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 65bd1128263..f00f87b2779 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -2333,6 +2333,9 @@ extern bool _bfd_elf_set_arch_mach
 extern bool _bfd_elf_find_nearest_line
   (bfd *, asymbol **, asection *, bfd_vma,
    const char **, const char **, unsigned int *, unsigned int *);
+extern bool _bfd_elf_find_nearest_line_with_alt
+  (bfd *, const char *, asymbol **, asection *, bfd_vma,
+   const char **, const char **, unsigned int *, unsigned int *);
 extern bool _bfd_elf_find_line
   (bfd *, asymbol **, asymbol *, const char **, unsigned int *);
 extern bool _bfd_elf_find_inliner_info
diff --git a/bfd/elf.c b/bfd/elf.c
index 8aba36acb3c..1f427e40a44 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -9339,14 +9339,36 @@ _bfd_elf_find_nearest_line (bfd *abfd,
 			    const char **functionname_ptr,
 			    unsigned int *line_ptr,
 			    unsigned int *discriminator_ptr)
+{
+  return _bfd_elf_find_nearest_line_with_alt (abfd, NULL, symbols, section,
+					      offset, filename_ptr,
+					      functionname_ptr, line_ptr,
+					      discriminator_ptr);
+}
+
+/* Find the nearest line to a particular section and offset,
+   for error reporting.  ALT_BFD representing a .gnu_debugaltlink file
+   can be optionally specified.  */
+
+bool
+_bfd_elf_find_nearest_line_with_alt (bfd *abfd,
+				     const char *alt_filename,
+				     asymbol **symbols,
+				     asection *section,
+				     bfd_vma offset,
+				     const char **filename_ptr,
+				     const char **functionname_ptr,
+				     unsigned int *line_ptr,
+				     unsigned int *discriminator_ptr)
 {
   bool found;
 
-  if (_bfd_dwarf2_find_nearest_line (abfd, symbols, NULL, section, offset,
-				     filename_ptr, functionname_ptr,
-				     line_ptr, discriminator_ptr,
-				     dwarf_debug_sections,
-				     &elf_tdata (abfd)->dwarf2_find_line_info))
+  if (_bfd_dwarf2_find_nearest_line_with_alt (abfd, alt_filename, symbols, NULL,
+					      section, offset, filename_ptr,
+					      functionname_ptr, line_ptr,
+					      discriminator_ptr,
+					      dwarf_debug_sections,
+					      &elf_tdata (abfd)->dwarf2_find_line_info))
     return true;
 
   if (_bfd_dwarf1_find_nearest_line (abfd, symbols, section, offset,
diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c
index b611515990d..3f92df6ee11 100644
--- a/bfd/elf32-mips.c
+++ b/bfd/elf32-mips.c
@@ -2573,6 +2573,8 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
 					_bfd_mips_elf_is_target_special_symbol
 #define bfd_elf32_get_synthetic_symtab	_bfd_mips_elf_get_synthetic_symtab
 #define bfd_elf32_find_nearest_line	_bfd_mips_elf_find_nearest_line
+#define bfd_elf32_find_nearest_line_with_alt \
+					_bfd_mips_elf_find_nearest_line_with_alt
 #define bfd_elf32_find_inliner_info	_bfd_mips_elf_find_inliner_info
 #define bfd_elf32_new_section_hook	_bfd_mips_elf_new_section_hook
 #define bfd_elf32_set_section_contents	_bfd_mips_elf_set_section_contents
diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c
index c2c6604ef68..e3ee0b99d97 100644
--- a/bfd/elf64-mips.c
+++ b/bfd/elf64-mips.c
@@ -4792,6 +4792,8 @@ const struct elf_size_info mips_elf64_size_info =
 #define bfd_elf64_bfd_is_target_special_symbol \
 					_bfd_mips_elf_is_target_special_symbol
 #define bfd_elf64_find_nearest_line	_bfd_mips_elf_find_nearest_line
+#define bfd_elf64_find_nearest_line_with_alt \
+				_bfd_mips_elf_find_nearest_line_with_alt
 #define bfd_elf64_find_inliner_info	_bfd_mips_elf_find_inliner_info
 #define bfd_elf64_new_section_hook	_bfd_mips_elf_new_section_hook
 #define bfd_elf64_set_section_contents	_bfd_mips_elf_set_section_contents
diff --git a/bfd/elfn32-mips.c b/bfd/elfn32-mips.c
index af984545796..ac604eda5ea 100644
--- a/bfd/elfn32-mips.c
+++ b/bfd/elfn32-mips.c
@@ -4176,6 +4176,8 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
 #define bfd_elf32_bfd_is_target_special_symbol \
 					_bfd_mips_elf_is_target_special_symbol
 #define bfd_elf32_find_nearest_line	_bfd_mips_elf_find_nearest_line
+#define bfd_elf32_find_nearest_line_with_alt \
+				_bfd_mips_elf_find_nearest_line_with_alt
 #define bfd_elf32_find_inliner_info	_bfd_mips_elf_find_inliner_info
 #define bfd_elf32_new_section_hook	_bfd_mips_elf_new_section_hook
 #define bfd_elf32_set_section_contents	_bfd_mips_elf_set_section_contents
diff --git a/bfd/elfxx-mips.h b/bfd/elfxx-mips.h
index 3be69524c01..af6d14c6ce3 100644
--- a/bfd/elfxx-mips.h
+++ b/bfd/elfxx-mips.h
@@ -92,6 +92,8 @@ extern bool _bfd_mips_elf_is_target_special_symbol
 extern bool _bfd_mips_elf_find_nearest_line
   (bfd *, asymbol **, asection *, bfd_vma,
    const char **, const char **, unsigned int *, unsigned int *);
+#define _bfd_mips_elf_find_nearest_line_with_alt \
+  _bfd_nosymbols_find_nearest_line_with_alt
 extern bool _bfd_mips_elf_find_inliner_info
   (bfd *, const char **, const char **, unsigned int *);
 extern bool _bfd_mips_elf_set_section_contents
diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h
index 0579f64d1a0..feaba84bf2e 100644
--- a/bfd/elfxx-target.h
+++ b/bfd/elfxx-target.h
@@ -52,6 +52,10 @@
 #ifndef bfd_elfNN_find_nearest_line
 #define bfd_elfNN_find_nearest_line	_bfd_elf_find_nearest_line
 #endif
+#ifndef bfd_elfNN_find_nearest_line_with_alt
+#define bfd_elfNN_find_nearest_line_with_alt \
+  _bfd_elf_find_nearest_line_with_alt
+#endif
 #ifndef bfd_elfNN_find_line
 #define bfd_elfNN_find_line		_bfd_elf_find_line
 #endif
diff --git a/bfd/i386msdos.c b/bfd/i386msdos.c
index 8247828eac8..0f6cdec64be 100644
--- a/bfd/i386msdos.c
+++ b/bfd/i386msdos.c
@@ -252,6 +252,7 @@ msdos_set_section_contents (bfd *abfd,
 #define msdos_get_symbol_version_string \
   _bfd_nosymbols_get_symbol_version_string
 #define msdos_find_nearest_line _bfd_nosymbols_find_nearest_line
+#define msdos_find_nearest_line_with_alt _bfd_nosymbols_find_nearest_line_with_alt
 #define msdos_find_line _bfd_nosymbols_find_line
 #define msdos_find_inliner_info _bfd_nosymbols_find_inliner_info
 #define msdos_get_lineno _bfd_nosymbols_get_lineno
diff --git a/bfd/ihex.c b/bfd/ihex.c
index cccec8f164e..3088f7ee1de 100644
--- a/bfd/ihex.c
+++ b/bfd/ihex.c
@@ -942,6 +942,7 @@ ihex_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #define ihex_bfd_is_local_label_name		  _bfd_nosymbols_bfd_is_local_label_name
 #define ihex_get_lineno				  _bfd_nosymbols_get_lineno
 #define ihex_find_nearest_line			  _bfd_nosymbols_find_nearest_line
+#define ihex_find_nearest_line_with_alt		  _bfd_nosymbols_find_nearest_line_with_alt
 #define ihex_find_line				  _bfd_nosymbols_find_line
 #define ihex_find_inliner_info			  _bfd_nosymbols_find_inliner_info
 #define ihex_bfd_make_debug_symbol		  _bfd_nosymbols_bfd_make_debug_symbol
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
index 2905de8ef92..04f343b051b 100644
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -451,6 +451,10 @@ extern bool _bfd_nosymbols_find_nearest_line
   (bfd *, asymbol **, asection *, bfd_vma,
    const char **, const char **, unsigned int *, unsigned int *)
   ATTRIBUTE_HIDDEN;
+extern bool _bfd_nosymbols_find_nearest_line_with_alt
+  (bfd *, const char *, asymbol **, asection *, bfd_vma,
+   const char **, const char **, unsigned int *, unsigned int *)
+  ATTRIBUTE_HIDDEN;
 extern bool _bfd_nosymbols_find_line
   (bfd *, asymbol **, asymbol *, const char **, unsigned int *)
   ATTRIBUTE_HIDDEN;
@@ -586,6 +590,13 @@ extern int _bfd_dwarf2_find_nearest_line
    const char **, const char **, unsigned int *, unsigned int *,
    const struct dwarf_debug_section *, void **) ATTRIBUTE_HIDDEN;
 
+/* Find the nearest line using DWARF 2 debugging information, with
+   the option of specifying a .gnu_debugaltlink file.  */
+extern int _bfd_dwarf2_find_nearest_line_with_alt
+  (bfd *, const char *, asymbol **, asymbol *, asection *, bfd_vma,
+   const char **, const char **, unsigned int *, unsigned int *,
+   const struct dwarf_debug_section *, void **) ATTRIBUTE_HIDDEN;
+
 /* Find the bias between DWARF addresses and real addresses.  */
 extern bfd_signed_vma _bfd_dwarf2_find_symbol_bias
   (asymbol **, void **) ATTRIBUTE_HIDDEN;
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index c766722efb0..68d0c4278b3 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -456,6 +456,10 @@ extern bool _bfd_nosymbols_find_nearest_line
   (bfd *, asymbol **, asection *, bfd_vma,
    const char **, const char **, unsigned int *, unsigned int *)
   ATTRIBUTE_HIDDEN;
+extern bool _bfd_nosymbols_find_nearest_line_with_alt
+  (bfd *, const char *, asymbol **, asection *, bfd_vma,
+   const char **, const char **, unsigned int *, unsigned int *)
+  ATTRIBUTE_HIDDEN;
 extern bool _bfd_nosymbols_find_line
   (bfd *, asymbol **, asymbol *, const char **, unsigned int *)
   ATTRIBUTE_HIDDEN;
@@ -591,6 +595,13 @@ extern int _bfd_dwarf2_find_nearest_line
    const char **, const char **, unsigned int *, unsigned int *,
    const struct dwarf_debug_section *, void **) ATTRIBUTE_HIDDEN;
 
+/* Find the nearest line using DWARF 2 debugging information, with
+   the option of specifying a .gnu_debugaltlink file.  */
+extern int _bfd_dwarf2_find_nearest_line_with_alt
+  (bfd *, const char *, asymbol **, asymbol *, asection *, bfd_vma,
+   const char **, const char **, unsigned int *, unsigned int *,
+   const struct dwarf_debug_section *, void **) ATTRIBUTE_HIDDEN;
+
 /* Find the bias between DWARF addresses and real addresses.  */
 extern bfd_signed_vma _bfd_dwarf2_find_symbol_bias
   (asymbol **, void **) ATTRIBUTE_HIDDEN;
diff --git a/bfd/libcoff-in.h b/bfd/libcoff-in.h
index e1f9e60c527..722fd1e6ba4 100644
--- a/bfd/libcoff-in.h
+++ b/bfd/libcoff-in.h
@@ -358,6 +358,8 @@ extern asymbol *coff_bfd_make_debug_symbol
 extern bool coff_find_nearest_line
   (bfd *, asymbol **, asection *, bfd_vma,
    const char **, const char **, unsigned int *, unsigned int *);
+#define coff_find_nearest_line_with_alt \
+  _bfd_nosymbols_find_nearest_line_with_alt
 #define coff_find_line _bfd_nosymbols_find_line
 struct dwarf_debug_section;
 extern bool coff_find_nearest_line_with_names
diff --git a/bfd/libcoff.h b/bfd/libcoff.h
index a884a804631..21640c11ea6 100644
--- a/bfd/libcoff.h
+++ b/bfd/libcoff.h
@@ -362,6 +362,8 @@ extern asymbol *coff_bfd_make_debug_symbol
 extern bool coff_find_nearest_line
   (bfd *, asymbol **, asection *, bfd_vma,
    const char **, const char **, unsigned int *, unsigned int *);
+#define coff_find_nearest_line_with_alt \
+  _bfd_nosymbols_find_nearest_line_with_alt
 #define coff_find_line _bfd_nosymbols_find_line
 struct dwarf_debug_section;
 extern bool coff_find_nearest_line_with_names
diff --git a/bfd/libecoff.h b/bfd/libecoff.h
index b6c694873e7..073377755a4 100644
--- a/bfd/libecoff.h
+++ b/bfd/libecoff.h
@@ -293,6 +293,8 @@ extern bool _bfd_ecoff_bfd_is_local_label_name
 extern bool _bfd_ecoff_find_nearest_line
   (bfd *, asymbol **, asection *, bfd_vma,
    const char **, const char **, unsigned int *, unsigned int *);
+#define _bfd_ecoff_find_nearest_line_with_alt \
+  _bfd_nosymbols_find_nearest_line_with_alt
 #define _bfd_ecoff_find_line _bfd_nosymbols_find_line
 #define _bfd_ecoff_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
 #define _bfd_ecoff_read_minisymbols _bfd_generic_read_minisymbols
diff --git a/bfd/mach-o.h b/bfd/mach-o.h
index f7418ad8d40..2e9a634df78 100644
--- a/bfd/mach-o.h
+++ b/bfd/mach-o.h
@@ -729,6 +729,8 @@ bool bfd_mach_o_find_nearest_line (bfd *, asymbol **,
 					  asection *, bfd_vma,
 					  const char **, const char **,
 					  unsigned int *, unsigned int *);
+#define bfd_mach_o_find_nearest_line_with_alt \
+  _bfd_nosymbols_find_nearest_line_with_alt
 #define bfd_mach_o_find_line _bfd_nosymbols_find_line
 bool bfd_mach_o_close_and_cleanup (bfd *);
 bool bfd_mach_o_free_cached_info (bfd *);
diff --git a/bfd/mmo.c b/bfd/mmo.c
index 80b5cb6b4ca..fd92a346bc7 100644
--- a/bfd/mmo.c
+++ b/bfd/mmo.c
@@ -3316,6 +3316,7 @@ mmo_write_object_contents (bfd *abfd)
 /* FIXME: We can do better on this one, if we have a dwarf2 .debug_line
    section or if MMO line numbers are implemented.  */
 #define mmo_find_nearest_line _bfd_nosymbols_find_nearest_line
+#define mmo_find_nearest_line_with_alt _bfd_nosymbols_find_nearest_line_with_alt
 #define mmo_find_line _bfd_nosymbols_find_line
 #define mmo_find_inliner_info _bfd_nosymbols_find_inliner_info
 #define mmo_make_empty_symbol _bfd_generic_make_empty_symbol
diff --git a/bfd/pef.c b/bfd/pef.c
index 1dcb1dae40e..d9936f750c1 100644
--- a/bfd/pef.c
+++ b/bfd/pef.c
@@ -41,6 +41,7 @@
 #define bfd_pef_bfd_is_target_special_symbol        _bfd_bool_bfd_asymbol_false
 #define bfd_pef_get_lineno			    _bfd_nosymbols_get_lineno
 #define bfd_pef_find_nearest_line		    _bfd_nosymbols_find_nearest_line
+#define bfd_pef_find_nearest_line_with_alt	    _bfd_nosymbols_find_nearest_line_with_alt
 #define bfd_pef_find_line			    _bfd_nosymbols_find_line
 #define bfd_pef_find_inliner_info		    _bfd_nosymbols_find_inliner_info
 #define bfd_pef_get_symbol_version_string	    _bfd_nosymbols_get_symbol_version_string
diff --git a/bfd/plugin.c b/bfd/plugin.c
index c69fbd7b568..9103e21019d 100644
--- a/bfd/plugin.c
+++ b/bfd/plugin.c
@@ -83,6 +83,7 @@ dlerror (void)
 #define bfd_plugin_bfd_is_target_special_symbol	      _bfd_bool_bfd_asymbol_false
 #define bfd_plugin_get_lineno			      _bfd_nosymbols_get_lineno
 #define bfd_plugin_find_nearest_line		      _bfd_nosymbols_find_nearest_line
+#define bfd_plugin_find_nearest_line_with_alt	      _bfd_nosymbols_find_nearest_line_with_alt
 #define bfd_plugin_find_line			      _bfd_nosymbols_find_line
 #define bfd_plugin_find_inliner_info		      _bfd_nosymbols_find_inliner_info
 #define bfd_plugin_get_symbol_version_string	      _bfd_nosymbols_get_symbol_version_string
diff --git a/bfd/ppcboot.c b/bfd/ppcboot.c
index 4e6cc9abbe2..d52d1a63357 100644
--- a/bfd/ppcboot.c
+++ b/bfd/ppcboot.c
@@ -332,6 +332,7 @@ ppcboot_get_symbol_info (bfd *ignore_abfd ATTRIBUTE_UNUSED,
 #define ppcboot_bfd_is_local_label_name bfd_generic_is_local_label_name
 #define ppcboot_get_lineno _bfd_nosymbols_get_lineno
 #define ppcboot_find_nearest_line _bfd_nosymbols_find_nearest_line
+#define ppcboot_find_nearest_line_with_alt _bfd_nosymbols_find_nearest_line_with_alt
 #define ppcboot_find_line _bfd_nosymbols_find_line
 #define ppcboot_find_inliner_info _bfd_nosymbols_find_inliner_info
 #define ppcboot_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
diff --git a/bfd/som.h b/bfd/som.h
index 6aca4a28760..68b8cc317f4 100644
--- a/bfd/som.h
+++ b/bfd/som.h
@@ -230,6 +230,9 @@ struct som_section_data_struct
 #define R_HPPA_BEGIN_TRY		R_BEGIN_TRY
 #define R_HPPA_END_TRY			R_END_TRY
 
+#define som_find_nearest_line_with_alt \
+  _bfd_nosymbols_find_nearest_line_with_alt
+
 /* Exported functions, mostly for use by GAS.  */
 bool bfd_som_set_section_attributes
   (asection *, int, int, unsigned int, int);
diff --git a/bfd/srec.c b/bfd/srec.c
index abe36bbdbd1..3ef429eca6d 100644
--- a/bfd/srec.c
+++ b/bfd/srec.c
@@ -1249,6 +1249,7 @@ srec_print_symbol (bfd *abfd,
 #define srec_bfd_is_local_label_name		  bfd_generic_is_local_label_name
 #define srec_get_lineno				  _bfd_nosymbols_get_lineno
 #define srec_find_nearest_line			  _bfd_nosymbols_find_nearest_line
+#define srec_find_nearest_line_with_alt		  _bfd_nosymbols_find_nearest_line_with_alt
 #define srec_find_line				  _bfd_nosymbols_find_line
 #define srec_find_inliner_info			  _bfd_nosymbols_find_inliner_info
 #define srec_make_empty_symbol			  _bfd_generic_make_empty_symbol
diff --git a/bfd/syms.c b/bfd/syms.c
index b284cb294ff..7a454c5d7e7 100644
--- a/bfd/syms.c
+++ b/bfd/syms.c
@@ -1504,6 +1504,21 @@ _bfd_nosymbols_find_nearest_line
   return _bfd_bool_bfd_false_error (abfd);
 }
 
+bool
+_bfd_nosymbols_find_nearest_line_with_alt
+    (bfd *abfd,
+     const char *alt_filename ATTRIBUTE_UNUSED,
+     asymbol **symbols ATTRIBUTE_UNUSED,
+     asection *section ATTRIBUTE_UNUSED,
+     bfd_vma offset ATTRIBUTE_UNUSED,
+     const char **filename_ptr ATTRIBUTE_UNUSED,
+     const char **functionname_ptr ATTRIBUTE_UNUSED,
+     unsigned int *line_ptr ATTRIBUTE_UNUSED,
+     unsigned int *discriminator_ptr ATTRIBUTE_UNUSED)
+{
+  return _bfd_bool_bfd_false_error (abfd);
+}
+
 bool
 _bfd_nosymbols_find_line (bfd *abfd,
 			  asymbol **symbols ATTRIBUTE_UNUSED,
diff --git a/bfd/targets.c b/bfd/targets.c
index 8ad3ef366ce..1ec8acdb03f 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -377,6 +377,7 @@ BFD_JUMP_TABLE macros.
 .  NAME##_bfd_is_target_special_symbol, \
 .  NAME##_get_lineno, \
 .  NAME##_find_nearest_line, \
+.  NAME##_find_nearest_line_with_alt, \
 .  NAME##_find_line, \
 .  NAME##_find_inliner_info, \
 .  NAME##_bfd_make_debug_symbol, \
@@ -407,6 +408,11 @@ BFD_JUMP_TABLE macros.
 .				   struct bfd_section *, bfd_vma,
 .				   const char **, const char **,
 .				   unsigned int *, unsigned int *);
+.  bool (*_bfd_find_nearest_line_with_alt) (bfd *, const char *,
+.					    struct bfd_symbol **,
+.					    struct bfd_section *, bfd_vma,
+.					    const char **, const char **,
+.					    unsigned int *, unsigned int *);
 .  bool (*_bfd_find_line) (bfd *, struct bfd_symbol **,
 .			   struct bfd_symbol *, const char **,
 .			   unsigned int *);
diff --git a/bfd/tekhex.c b/bfd/tekhex.c
index 7ff87af8a9d..f2b2db2bd0b 100644
--- a/bfd/tekhex.c
+++ b/bfd/tekhex.c
@@ -966,6 +966,7 @@ tekhex_print_symbol (bfd *abfd,
 #define tekhex_bfd_is_local_label_name		     bfd_generic_is_local_label_name
 #define tekhex_get_lineno			    _bfd_nosymbols_get_lineno
 #define tekhex_find_nearest_line		    _bfd_nosymbols_find_nearest_line
+#define tekhex_find_nearest_line_with_alt	    _bfd_nosymbols_find_nearest_line_with_alt
 #define tekhex_find_line			    _bfd_nosymbols_find_line
 #define tekhex_find_inliner_info		    _bfd_nosymbols_find_inliner_info
 #define tekhex_get_symbol_version_string	    _bfd_nosymbols_get_symbol_version_string
diff --git a/bfd/verilog.c b/bfd/verilog.c
index 4579f05ded3..baf0e044c42 100644
--- a/bfd/verilog.c
+++ b/bfd/verilog.c
@@ -370,6 +370,7 @@ verilog_mkobject (bfd *abfd)
 #define verilog_bfd_is_local_label_name		     bfd_generic_is_local_label_name
 #define verilog_get_lineno			     _bfd_nosymbols_get_lineno
 #define verilog_find_nearest_line		     _bfd_nosymbols_find_nearest_line
+#define verilog_find_nearest_line_with_alt	     _bfd_nosymbols_find_nearest_line_with_alt
 #define verilog_find_inliner_info		     _bfd_nosymbols_find_inliner_info
 #define verilog_make_empty_symbol		     _bfd_generic_make_empty_symbol
 #define verilog_bfd_make_debug_symbol		     _bfd_nosymbols_bfd_make_debug_symbol
diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c
index 5a867f715ea..0ea9ed544f1 100644
--- a/bfd/vms-alpha.c
+++ b/bfd/vms-alpha.c
@@ -9992,6 +9992,8 @@ bfd_vms_get_data (bfd *abfd)
 #define alpha_vms_find_inliner_info	   _bfd_nosymbols_find_inliner_info
 #define alpha_vms_bfd_make_debug_symbol	   _bfd_nosymbols_bfd_make_debug_symbol
 #define alpha_vms_find_nearest_line	   _bfd_vms_find_nearest_line
+#define alpha_vms_find_nearest_line_with_alt \
+   _bfd_nosymbols_find_nearest_line_with_alt
 #define alpha_vms_find_line		   _bfd_nosymbols_find_line
 #define alpha_vms_bfd_is_local_label_name  vms_bfd_is_local_label_name
 
diff --git a/bfd/wasm-module.c b/bfd/wasm-module.c
index f6afa054db0..2c2c6c72863 100644
--- a/bfd/wasm-module.c
+++ b/bfd/wasm-module.c
@@ -784,6 +784,7 @@ wasm_object_p (bfd *abfd)
 #define wasm_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
 #define wasm_get_lineno			  _bfd_nosymbols_get_lineno
 #define wasm_find_nearest_line		  _bfd_nosymbols_find_nearest_line
+#define wasm_find_nearest_line_with_alt	  _bfd_nosymbols_find_nearest_line_with_alt
 #define wasm_find_line			  _bfd_nosymbols_find_line
 #define wasm_find_inliner_info		  _bfd_nosymbols_find_inliner_info
 #define wasm_bfd_make_debug_symbol	  _bfd_nosymbols_bfd_make_debug_symbol
diff --git a/bfd/xsym.c b/bfd/xsym.c
index 8a092f07f9c..b8e3d6c68a6 100644
--- a/bfd/xsym.c
+++ b/bfd/xsym.c
@@ -32,6 +32,7 @@
 #define bfd_sym_bfd_is_target_special_symbol	    _bfd_bool_bfd_asymbol_false
 #define bfd_sym_get_lineno			    _bfd_nosymbols_get_lineno
 #define bfd_sym_find_nearest_line		    _bfd_nosymbols_find_nearest_line
+#define bfd_sym_find_nearest_line_with_alt	    _bfd_nosymbols_find_nearest_line_with_alt
 #define bfd_sym_find_line			    _bfd_nosymbols_find_line
 #define bfd_sym_find_inliner_info		    _bfd_nosymbols_find_inliner_info
 #define bfd_sym_get_symbol_version_string	    _bfd_nosymbols_get_symbol_version_string

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-06 14:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-06 14:54 [binutils-gdb] bfd: Add bfd_find_nearest_line_with_alt Aaron Merey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).