summaryrefslogtreecommitdiffstats
path: root/lldb/source/Symbol/ObjectFile.cpp
diff options
context:
space:
mode:
authorEd Maste <emaste@freebsd.org>2017-10-02 14:35:07 +0000
committerEd Maste <emaste@freebsd.org>2017-10-02 14:35:07 +0000
commitd13f691f41c94b8681829c85ecb7a23fcbb9caf1 (patch)
tree42395ba6f8765094749b3337d444e2fbc1aa11d9 /lldb/source/Symbol/ObjectFile.cpp
parente2aa5b2ace432d24be067044a333128514b46faf (diff)
downloadbcm5719-llvm-d13f691f41c94b8681829c85ecb7a23fcbb9caf1.tar.gz
bcm5719-llvm-d13f691f41c94b8681829c85ecb7a23fcbb9caf1.zip
Improve FreeBSD kernel debugging
FreeBSD kernel modules are actually relocatable (.o) ELF files and this previously caused some issues for LLDB. This change addresses these when using lldb to symbolicate FreeBSD kernel backtraces. The major problems: - Relocations were not being applied to the DWARF debug info despite there being code to do this. Several issues prevented it from working: - Relocations are computed at the same time as the symbol table, but in the case of split debug files, symbol table parsing always redirects to the primary object file, meaning that relocations would never be applied in the debug file. - There's actually no guarantee that the symbol table has been parsed yet when trying to parse debug information. - When actually applying relocations, it will segfault because the object files are not mapped with MAP_PRIVATE and PROT_WRITE. - LLDB returned invalid results when performing ordinary address-to- symbol resolution. It turned out that the addresses specified in the section headers were all 0, so LLDB believed all the sections had overlapping "file addresses" and would sometimes return a symbol from the wrong section. Patch by Brian Koropoff Differential Revision: https://reviews.llvm.org/D38142 llvm-svn: 314672
Diffstat (limited to 'lldb/source/Symbol/ObjectFile.cpp')
-rw-r--r--lldb/source/Symbol/ObjectFile.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/lldb/source/Symbol/ObjectFile.cpp b/lldb/source/Symbol/ObjectFile.cpp
index c2e2be9cfb7..39593bc6e2b 100644
--- a/lldb/source/Symbol/ObjectFile.cpp
+++ b/lldb/source/Symbol/ObjectFile.cpp
@@ -483,9 +483,9 @@ size_t ObjectFile::CopyData(lldb::offset_t offset, size_t length,
return m_data.CopyData(offset, length, dst);
}
-size_t ObjectFile::ReadSectionData(const Section *section,
+size_t ObjectFile::ReadSectionData(Section *section,
lldb::offset_t section_offset, void *dst,
- size_t dst_len) const {
+ size_t dst_len) {
assert(section);
section_offset *= section->GetTargetByteSize();
@@ -505,6 +505,9 @@ size_t ObjectFile::ReadSectionData(const Section *section,
dst_len, error);
}
} else {
+ if (!section->IsRelocated())
+ RelocateSection(section);
+
const lldb::offset_t section_file_size = section->GetFileSize();
if (section_offset < section_file_size) {
const size_t section_bytes_left = section_file_size - section_offset;
@@ -531,8 +534,8 @@ size_t ObjectFile::ReadSectionData(const Section *section,
//----------------------------------------------------------------------
// Get the section data the file on disk
//----------------------------------------------------------------------
-size_t ObjectFile::ReadSectionData(const Section *section,
- DataExtractor &section_data) const {
+size_t ObjectFile::ReadSectionData(Section *section,
+ DataExtractor &section_data) {
// If some other objectfile owns this data, pass this to them.
if (section->GetObjectFile() != this)
return section->GetObjectFile()->ReadSectionData(section, section_data);
@@ -562,8 +565,8 @@ size_t ObjectFile::ReadSectionData(const Section *section,
}
}
-size_t ObjectFile::MemoryMapSectionData(const Section *section,
- DataExtractor &section_data) const {
+size_t ObjectFile::MemoryMapSectionData(Section *section,
+ DataExtractor &section_data) {
// If some other objectfile owns this data, pass this to them.
if (section->GetObjectFile() != this)
return section->GetObjectFile()->MemoryMapSectionData(section,
@@ -572,6 +575,9 @@ size_t ObjectFile::MemoryMapSectionData(const Section *section,
if (IsInMemory()) {
return ReadSectionData(section, section_data);
} else {
+ if (!section->IsRelocated())
+ RelocateSection(section);
+
// The object file now contains a full mmap'ed copy of the object file data,
// so just use this
return GetData(section->GetFileOffset(), section->GetFileSize(),
@@ -694,3 +700,7 @@ Status ObjectFile::LoadInMemory(Target &target, bool set_pc) {
}
return error;
}
+
+void ObjectFile::RelocateSection(lldb_private::Section *section)
+{
+}
OpenPOWER on IntegriCloud