[lldb-dev] [Bug 18648] New: Section's m_file_addr left unset after Mach-O parsing
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Jan 28 15:35:44 PST 2014
http://llvm.org/bugs/show_bug.cgi?id=18648
Bug ID: 18648
Summary: Section's m_file_addr left unset after Mach-O parsing
Product: lldb
Version: unspecified
Hardware: All
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: lldb-dev at cs.uiuc.edu
Reporter: josharian at gmail.com
Classification: Unclassified
Created attachment 11965
--> http://llvm.org/bugs/attachment.cgi?id=11965&action=edit
Compiled executable (simple.go)
I found this while digging into golang.org/issue/7070.
Reproduce:
(1) Compile http://play.golang.org/p/i_6zF3EoLG using Go 1.2. I have attached a
compiled version for reference, called just simple.
(2) lldb simple
(3) breakpoint set -a 0x2000
(4) run
Result:
Assertion failed: (sizeof(arangeDescriptor.address) >= m_header.addr_size),
function Extract, file
/SourceCache/lldb/lldb-300.2.53/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp,
line 208.
Diagnosis:
In the executable attached, __debug_aranges is at offset 514379. The data being
parsed to construct m_header in DWARFDebugArangeSet::Extract, however, is at
offset 360448, which is the beginning of the DWARF segment, not the
__debug_aranges section. This junk data causes the assertion failure.
The aranges data is prepared in SymbolFileDWARF::GetCachedSectionData, at
SymbolFileDWARF.cpp:716. The data offset calculation uses
section_sp->GetOffset(), which should be the offset of the __debug_aranges
section relative to the containing DWARF segment. That is, it should return
153931. In this case, however, it returns 0.
This is because Section::GetOffset returns m_file_addr, which is documented to
be the file offset relative to the parent. However, m_file_addr never gets set
in ObjectFileMachO::CreateSections (or anywhere else). There is one call to
Section::SetFileAddress, at line 1124, but it does not get hit during parsing
of the attached executable.
The following patch fixes the problem by using m_file_offset in
Section::GetOffset. I suspect, however, that the correct fix is to populate
m_file_addr during Mach-O parsing.
diff --git a/source/Core/Section.cpp b/source/Core/Section.cpp
index 28d7d93..f6f6fe2 100644
--- a/source/Core/Section.cpp
+++ b/source/Core/Section.cpp
@@ -123,7 +123,7 @@ Section::GetOffset () const
// This section has a parent which means m_file_addr is an offset.
SectionSP parent_sp (GetParent ());
if (parent_sp)
- return m_file_addr;
+ return m_file_offset - parent_sp->m_file_offset;
// This section has no parent, so there is no offset to be had
return 0;
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20140128/2ddd3441/attachment.html>
More information about the lldb-dev
mailing list