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

@@ -38,6 +38,7 @@
#include <elf.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <link.h>
#include <stdint.h>
#include <stdio.h>
@@ -936,7 +937,14 @@ bool InitModuleForElfClass(const typename ElfClass::Ehdr* elf_header,
return false;
}
string name = google_breakpad::BaseName(obj_filename);
string name;
char name_buf[NAME_MAX];
memset(name_buf, 0, sizeof(name_buf));
name = google_breakpad::ElfFileSoNameFromMappedFile(elf_header, name_buf,
sizeof(name_buf))
? name_buf
: google_breakpad::BaseName(obj_filename);
string os = "Linux";
// Add an extra "0" at the end. PDB files on Windows have an 'age'
// number appended to the end of the file identifier; this isn't