aboutsummaryrefslogtreecommitdiff
path: root/src/common/linux/dump_symbols.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/linux/dump_symbols.cc')
-rw-r--r--src/common/linux/dump_symbols.cc44
1 files changed, 28 insertions, 16 deletions
diff --git a/src/common/linux/dump_symbols.cc b/src/common/linux/dump_symbols.cc
index 40bb3ff2..660f133e 100644
--- a/src/common/linux/dump_symbols.cc
+++ b/src/common/linux/dump_symbols.cc
@@ -921,6 +921,7 @@ bool SanitizeDebugFile(const typename ElfClass::Ehdr* debug_elf_header,
template<typename ElfClass>
bool InitModuleForElfClass(const typename ElfClass::Ehdr* elf_header,
const string& obj_filename,
+ const string& obj_os,
scoped_ptr<Module>& module) {
PageAllocator allocator;
wasteful_vector<uint8_t> identifier(&allocator, kDefaultBuildIdSize);
@@ -945,7 +946,6 @@ bool InitModuleForElfClass(const typename ElfClass::Ehdr* elf_header,
? 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
// really used or necessary on other platforms, but be consistent.
@@ -953,7 +953,7 @@ bool InitModuleForElfClass(const typename ElfClass::Ehdr* elf_header,
// This is just the raw Build ID in hex.
string code_id = FileID::ConvertIdentifierToString(identifier);
- module.reset(new Module(name, os, architecture, id, code_id));
+ module.reset(new Module(name, obj_os, architecture, id, code_id));
return true;
}
@@ -961,6 +961,7 @@ bool InitModuleForElfClass(const typename ElfClass::Ehdr* elf_header,
template<typename ElfClass>
bool ReadSymbolDataElfClass(const typename ElfClass::Ehdr* elf_header,
const string& obj_filename,
+ const string& obj_os,
const std::vector<string>& debug_dirs,
const DumpOptions& options,
Module** out_module) {
@@ -969,7 +970,8 @@ bool ReadSymbolDataElfClass(const typename ElfClass::Ehdr* elf_header,
*out_module = NULL;
scoped_ptr<Module> module;
- if (!InitModuleForElfClass<ElfClass>(elf_header, obj_filename, module)) {
+ if (!InitModuleForElfClass<ElfClass>(elf_header, obj_filename, obj_os,
+ module)) {
return false;
}
@@ -1017,6 +1019,7 @@ namespace google_breakpad {
// Not explicitly exported, but not static so it can be used in unit tests.
bool ReadSymbolDataInternal(const uint8_t* obj_file,
const string& obj_filename,
+ const string& obj_os,
const std::vector<string>& debug_dirs,
const DumpOptions& options,
Module** module) {
@@ -1028,24 +1031,27 @@ bool ReadSymbolDataInternal(const uint8_t* obj_file,
int elfclass = ElfClass(obj_file);
if (elfclass == ELFCLASS32) {
return ReadSymbolDataElfClass<ElfClass32>(
- reinterpret_cast<const Elf32_Ehdr*>(obj_file), obj_filename, debug_dirs,
- options, module);
+ reinterpret_cast<const Elf32_Ehdr*>(obj_file), obj_filename, obj_os,
+ debug_dirs, options, module);
}
if (elfclass == ELFCLASS64) {
return ReadSymbolDataElfClass<ElfClass64>(
- reinterpret_cast<const Elf64_Ehdr*>(obj_file), obj_filename, debug_dirs,
- options, module);
+ reinterpret_cast<const Elf64_Ehdr*>(obj_file), obj_filename, obj_os,
+ debug_dirs, options, module);
}
return false;
}
-bool WriteSymbolFile(const string &obj_file,
+bool WriteSymbolFile(const string &load_path,
+ const string &obj_file,
+ const string &obj_os,
const std::vector<string>& debug_dirs,
const DumpOptions& options,
std::ostream &sym_stream) {
Module* module;
- if (!ReadSymbolData(obj_file, debug_dirs, options, &module))
+ if (!ReadSymbolData(load_path, obj_file, obj_os, debug_dirs, options,
+ &module))
return false;
bool result = module->Write(sym_stream, options.symbol_data);
@@ -1056,11 +1062,13 @@ bool WriteSymbolFile(const string &obj_file,
// Read the selected object file's debugging information, and write out the
// header only to |stream|. Return true on success; if an error occurs, report
// it and return false.
-bool WriteSymbolFileHeader(const string& obj_file,
+bool WriteSymbolFileHeader(const string& load_path,
+ const string& obj_file,
+ const string& obj_os,
std::ostream &sym_stream) {
MmapWrapper map_wrapper;
void* elf_header = NULL;
- if (!LoadELF(obj_file, &map_wrapper, &elf_header)) {
+ if (!LoadELF(load_path, &map_wrapper, &elf_header)) {
fprintf(stderr, "Could not load ELF file: %s\n", obj_file.c_str());
return false;
}
@@ -1074,13 +1082,15 @@ bool WriteSymbolFileHeader(const string& obj_file,
scoped_ptr<Module> module;
if (elfclass == ELFCLASS32) {
if (!InitModuleForElfClass<ElfClass32>(
- reinterpret_cast<const Elf32_Ehdr*>(elf_header), obj_file, module)) {
+ reinterpret_cast<const Elf32_Ehdr*>(elf_header), obj_file, obj_os,
+ module)) {
fprintf(stderr, "Failed to load ELF module: %s\n", obj_file.c_str());
return false;
}
} else if (elfclass == ELFCLASS64) {
if (!InitModuleForElfClass<ElfClass64>(
- reinterpret_cast<const Elf64_Ehdr*>(elf_header), obj_file, module)) {
+ reinterpret_cast<const Elf64_Ehdr*>(elf_header), obj_file, obj_os,
+ module)) {
fprintf(stderr, "Failed to load ELF module: %s\n", obj_file.c_str());
return false;
}
@@ -1092,17 +1102,19 @@ bool WriteSymbolFileHeader(const string& obj_file,
return module->Write(sym_stream, ALL_SYMBOL_DATA);
}
-bool ReadSymbolData(const string& obj_file,
+bool ReadSymbolData(const string& load_path,
+ const string& obj_file,
+ const string& obj_os,
const std::vector<string>& debug_dirs,
const DumpOptions& options,
Module** module) {
MmapWrapper map_wrapper;
void* elf_header = NULL;
- if (!LoadELF(obj_file, &map_wrapper, &elf_header))
+ if (!LoadELF(load_path, &map_wrapper, &elf_header))
return false;
return ReadSymbolDataInternal(reinterpret_cast<uint8_t*>(elf_header),
- obj_file, debug_dirs, options, module);
+ obj_file, obj_os, debug_dirs, options, module);
}
} // namespace google_breakpad