diff options
author | Aaron Merey <amerey@redhat.com> | 2022-03-02 18:46:14 -0500 |
---|---|---|
committer | Aaron Merey <amerey@redhat.com> | 2022-03-21 14:11:51 -0400 |
commit | 39f53acb410c3e303fb25ff823de57eb316515ca (patch) | |
tree | be9ede6479d9008442629295ba7bd685f2ce634f /gdb/linux-tdep.c | |
parent | d37e084783a04c63ae137f953ebdb58bb6f7f704 (diff) | |
download | fsf-binutils-gdb-39f53acb410c3e303fb25ff823de57eb316515ca.zip fsf-binutils-gdb-39f53acb410c3e303fb25ff823de57eb316515ca.tar.gz fsf-binutils-gdb-39f53acb410c3e303fb25ff823de57eb316515ca.tar.bz2 |
gdb: Add soname to build-id mapping for core files
Since commit aa2d5a422 gdb has been able to read executable and shared
library build-ids within core files.
Expand this functionality so that each core file bfd maintains a map of
soname to build-id for each shared library referenced in the core file.
This feature may be used to verify that gdb has found the correct shared
libraries for core files and to facilitate downloading shared libaries via
debuginfod.
Diffstat (limited to 'gdb/linux-tdep.c')
-rw-r--r-- | gdb/linux-tdep.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index d486890..52cdaae 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -44,6 +44,7 @@ #include "solib-svr4.h" #include <ctype.h> +#include <unordered_map> /* This enum represents the values that the user can choose when informing the Linux kernel about which memory mappings will be @@ -1185,6 +1186,22 @@ linux_read_core_file_mappings if (f != descend) warning (_("malformed note - filename area is too big")); + const bfd_build_id *orig_build_id = cbfd->build_id; + std::unordered_map<ULONGEST, const bfd_build_id *> vma_map; + + /* Search for solib build-ids in the core file. Each time one is found, + map the start vma of the corresponding elf header to the build-id. */ + for (bfd_section *sec = cbfd->sections; sec != nullptr; sec = sec->next) + { + cbfd->build_id = nullptr; + + if (sec->flags & SEC_LOAD + && (get_elf_backend_data (cbfd)->elf_backend_core_find_build_id + (cbfd, (bfd_vma) sec->filepos))) + vma_map[sec->vma] = cbfd->build_id; + } + + cbfd->build_id = orig_build_id; pre_loop_cb (count); for (int i = 0; i < count; i++) @@ -1198,8 +1215,13 @@ linux_read_core_file_mappings descdata += addr_size; char * filename = filenames; filenames += strlen ((char *) filenames) + 1; + const bfd_build_id *build_id = nullptr; + auto vma_map_it = vma_map.find (start); + + if (vma_map_it != vma_map.end ()) + build_id = vma_map_it->second; - loop_cb (i, start, end, file_ofs, filename, nullptr); + loop_cb (i, start, end, file_ofs, filename, build_id); } } |