]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/elfread.c: Use bfd filename instead of objfile->original_name
authorAaron Merey <amerey@redhat.com>
Wed, 31 Aug 2022 00:18:11 +0000 (20:18 -0400)
committerAaron Merey <amerey@redhat.com>
Wed, 31 Aug 2022 00:20:28 +0000 (20:20 -0400)
The call to debuginfod_debuginfo_query in elf_symfile_read is given
objfile->original_name as the filename to print when downloading the
objfile's debuginfo.

In some cases original_name is prefixed with gdb's working directory
even though the objfile is not located in the working directory. This
causes debuginfod to display the wrong path of the objfile during a download.

Fix this by using the objfile's bfd filename instead.

gdb/elfread.c

index 08db208ebbb83aa708364d2eb238d023b2f8c1b3..13dbaf0227aa82dda0c01c9d77ed58e14f09334e 100644 (file)
@@ -1279,13 +1279,14 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
          has_dwarf2 = false;
          const struct bfd_build_id *build_id
            = build_id_bfd_get (objfile->obfd.get ());
+         const char *filename = bfd_get_filename (objfile->obfd.get ());
 
          if (build_id != nullptr)
            {
              gdb::unique_xmalloc_ptr<char> symfile_path;
              scoped_fd fd (debuginfod_debuginfo_query (build_id->data,
                                                        build_id->size,
-                                                       objfile->original_name,
+                                                       filename,
                                                        &symfile_path));
 
              if (fd.get () >= 0)
@@ -1295,7 +1296,7 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
 
                  if (debug_bfd == nullptr)
                    warning (_("File \"%s\" from debuginfod cannot be opened as bfd"),
-                            objfile->original_name);
+                            filename);
                  else if (build_id_verify (debug_bfd.get (), build_id->size, build_id->data))
                    {
                      symbol_file_add_separate (debug_bfd, symfile_path.get (),