linux, dump_syms: set module name from DT_SONAME

The Breakpad and Crashpad clients will use an object's DT_SONAME as
the name for a module if it exists. Previously, linux dump_syms would
assume the basename of an input elf file matches that value, causing
symbol lookups to fail if they were mismatched. This patch updates
dump_syms to use DT_SONAME as the module name, if present.

Bug: 1016924
Change-Id: I5eff0cf06c703841df3fb552cb5a8e1e50a20c64
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1876763
Reviewed-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Joshua Peraza 2019-10-24 11:41:44 -07:00
parent db1cda2653
commit 3e56ef9d4e
4 changed files with 78 additions and 44 deletions

View file

@ -45,6 +45,7 @@ namespace google_breakpad {
// with specific ELF bits.
struct ElfClass32 {
typedef Elf32_Addr Addr;
typedef Elf32_Dyn Dyn;
typedef Elf32_Ehdr Ehdr;
typedef Elf32_Nhdr Nhdr;
typedef Elf32_Phdr Phdr;
@ -62,6 +63,7 @@ struct ElfClass32 {
struct ElfClass64 {
typedef Elf64_Addr Addr;
typedef Elf64_Dyn Dyn;
typedef Elf64_Ehdr Ehdr;
typedef Elf64_Nhdr Nhdr;
typedef Elf64_Phdr Phdr;
@ -122,6 +124,12 @@ const T*
GetOffset(const typename ElfClass::Ehdr* elf_header,
typename ElfClass::Off offset);
// Read the value of DT_SONAME from the elf file mapped at |elf_base|. Returns
// true and fills |soname| with the result if found.
bool ElfFileSoNameFromMappedFile(const void* elf_base,
char* soname,
size_t soname_size);
} // namespace google_breakpad
#endif // COMMON_LINUX_ELFUTILS_H_