[llvm] r328154 - Handle abbr_offset with relocations.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 21 14:31:26 PDT 2018
Author: rafael
Date: Wed Mar 21 14:31:25 2018
New Revision: 328154
URL: http://llvm.org/viewvc/llvm-project?rev=328154&view=rev
Log:
Handle abbr_offset with relocations.
This is mostly just plumbing to get a DWARFDataExtractor where we
compute abbr_offset so we can use getRelocatedValue.
This is part of PR36793.
Added:
llvm/trunk/test/DebugInfo/X86/abbr_offset.s
Modified:
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h
llvm/trunk/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp
llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h?rev=328154&r1=328153&r2=328154&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h Wed Mar 21 14:31:25 2018
@@ -46,7 +46,8 @@ public:
static const DWARFSectionKind Section = DW_SECT_TYPES;
protected:
- bool extractImpl(DataExtractor debug_info, uint32_t *offset_ptr) override;
+ bool extractImpl(const DWARFDataExtractor &debug_info,
+ uint32_t *offset_ptr) override;
};
} // end namespace llvm
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h?rev=328154&r1=328153&r2=328154&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h Wed Mar 21 14:31:25 2018
@@ -56,7 +56,8 @@ public:
protected:
~DWARFUnitSectionBase() = default;
- virtual void parseImpl(DWARFContext &Context, const DWARFSection &Section,
+ virtual void parseImpl(DWARFContext &Context, const DWARFObject &Obj,
+ const DWARFSection &Section,
const DWARFDebugAbbrev *DA, const DWARFSection *RS,
StringRef SS, const DWARFSection &SOS,
const DWARFSection *AOS, const DWARFSection &LS,
@@ -116,14 +117,14 @@ public:
}
private:
- void parseImpl(DWARFContext &Context, const DWARFSection &Section,
- const DWARFDebugAbbrev *DA, const DWARFSection *RS,
- StringRef SS, const DWARFSection &SOS, const DWARFSection *AOS,
- const DWARFSection &LS, bool LE, bool IsDWO,
- bool Lazy) override {
+ void parseImpl(DWARFContext &Context, const DWARFObject &Obj,
+ const DWARFSection &Section, const DWARFDebugAbbrev *DA,
+ const DWARFSection *RS, StringRef SS, const DWARFSection &SOS,
+ const DWARFSection *AOS, const DWARFSection &LS, bool LE,
+ bool IsDWO, bool Lazy) override {
if (Parsed)
return;
- DataExtractor Data(Section.Data, LE, 0);
+ DWARFDataExtractor Data(Obj, Section, LE, 0);
if (!Parser) {
const DWARFUnitIndex *Index = nullptr;
if (IsDWO)
@@ -239,7 +240,8 @@ class DWARFUnit {
}
protected:
- virtual bool extractImpl(DataExtractor debug_info, uint32_t *offset_ptr);
+ virtual bool extractImpl(const DWARFDataExtractor &debug_info,
+ uint32_t *offset_ptr);
/// Size in bytes of the unit header.
virtual uint32_t getHeaderSize() const { return getVersion() <= 4 ? 11 : 12; }
@@ -299,7 +301,7 @@ public:
return DataExtractor(StringSection, false, 0);
}
- bool extract(DataExtractor debug_info, uint32_t* offset_ptr);
+ bool extract(const DWARFDataExtractor &debug_info, uint32_t *offset_ptr);
/// extractRangeList - extracts the range list referenced by this compile
/// unit from .debug_ranges section. Returns true on success.
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp?rev=328154&r1=328153&r2=328154&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp Wed Mar 21 14:31:25 2018
@@ -18,7 +18,7 @@
using namespace llvm;
-bool DWARFTypeUnit::extractImpl(DataExtractor debug_info,
+bool DWARFTypeUnit::extractImpl(const DWARFDataExtractor &debug_info,
uint32_t *offset_ptr) {
if (!DWARFUnit::extractImpl(debug_info, offset_ptr))
return false;
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp?rev=328154&r1=328153&r2=328154&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp Wed Mar 21 14:31:25 2018
@@ -31,7 +31,7 @@ using namespace dwarf;
void DWARFUnitSectionBase::parse(DWARFContext &C, const DWARFSection &Section) {
const DWARFObject &D = C.getDWARFObj();
- parseImpl(C, Section, C.getDebugAbbrev(), &D.getRangeSection(),
+ parseImpl(C, D, Section, C.getDebugAbbrev(), &D.getRangeSection(),
D.getStringSection(), D.getStringOffsetSection(),
&D.getAddrSection(), D.getLineSection(), D.isLittleEndian(), false,
false);
@@ -40,7 +40,7 @@ void DWARFUnitSectionBase::parse(DWARFCo
void DWARFUnitSectionBase::parseDWO(DWARFContext &C,
const DWARFSection &DWOSection, bool Lazy) {
const DWARFObject &D = C.getDWARFObj();
- parseImpl(C, DWOSection, C.getDebugAbbrevDWO(), &D.getRangeDWOSection(),
+ parseImpl(C, D, DWOSection, C.getDebugAbbrevDWO(), &D.getRangeDWOSection(),
D.getStringDWOSection(), D.getStringOffsetDWOSection(),
&D.getAddrSection(), D.getLineDWOSection(), C.isLittleEndian(),
true, Lazy);
@@ -91,7 +91,8 @@ bool DWARFUnit::getStringOffsetSectionIt
return true;
}
-bool DWARFUnit::extractImpl(DataExtractor debug_info, uint32_t *offset_ptr) {
+bool DWARFUnit::extractImpl(const DWARFDataExtractor &debug_info,
+ uint32_t *offset_ptr) {
Length = debug_info.getU32(offset_ptr);
// FIXME: Support DWARF64.
FormParams.Format = DWARF32;
@@ -101,7 +102,7 @@ bool DWARFUnit::extractImpl(DataExtracto
FormParams.AddrSize = debug_info.getU8(offset_ptr);
AbbrOffset = debug_info.getU32(offset_ptr);
} else {
- AbbrOffset = debug_info.getU32(offset_ptr);
+ AbbrOffset = debug_info.getRelocatedValue(4, offset_ptr);
FormParams.AddrSize = debug_info.getU8(offset_ptr);
}
if (IndexEntry) {
@@ -128,7 +129,8 @@ bool DWARFUnit::extractImpl(DataExtracto
return true;
}
-bool DWARFUnit::extract(DataExtractor debug_info, uint32_t *offset_ptr) {
+bool DWARFUnit::extract(const DWARFDataExtractor &debug_info,
+ uint32_t *offset_ptr) {
clear();
Offset = *offset_ptr;
Added: llvm/trunk/test/DebugInfo/X86/abbr_offset.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/abbr_offset.s?rev=328154&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/abbr_offset.s (added)
+++ llvm/trunk/test/DebugInfo/X86/abbr_offset.s Wed Mar 21 14:31:25 2018
@@ -0,0 +1,51 @@
+# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj -o - | \
+# RUN: llvm-dwarfdump - | FileCheck %s
+
+# This test simulates the result of ld -r. That produces files where
+# abbr_offset is not zero.
+
+# CHECK: abbr_offset = 0x0000
+# CHECK: abbr_offset = 0x0008
+
+ .section .debug_abbrev,"", at progbits
+.Labbrev1:
+ .byte 1 # Abbreviation Code
+ .byte 17 # DW_TAG_compile_unit
+ .byte 0 # DW_CHILDREN_no
+ .byte 16 # DW_AT_stmt_list
+ .byte 23 # DW_FORM_sec_offset
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 0 # EOM(3)
+
+.Labbrev2:
+ .byte 1 # Abbreviation Code
+ .byte 17 # DW_TAG_compile_unit
+ .byte 0 # DW_CHILDREN_no
+ .byte 16 # DW_AT_stmt_list
+ .byte 23 # DW_FORM_sec_offset
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 0 # EOM(3)
+
+ .section .debug_info,"", at progbits
+ .long .Lend0 - .Lbegin0 # Length of Unit
+.Lbegin0:
+ .short 4 # DWARF version number
+ .long .Labbrev1 # Offset Into Abbrev. Section
+ .byte 8 # Address Size (in bytes)
+ .byte 1 # Abbrev [1] 0xb:0x1f DW_TAG_compile_unit
+ .long .Lline_table_start0 # DW_AT_stmt_list
+.Lend0:
+
+ .long .Lend1 - .Lbegin1 # Length of Unit
+.Lbegin1:
+ .short 4 # DWARF version number
+ .long .Labbrev2 # Offset Into Abbrev. Section
+ .byte 8 # Address Size (in bytes)
+ .byte 1 # Abbrev [1] 0xb:0x1f DW_TAG_compile_unit
+ .long .Lline_table_start0 # DW_AT_stmt_list
+.Lend1:
+
+ .section .debug_line,"", at progbits
+.Lline_table_start0:
More information about the llvm-commits
mailing list