summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp11
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.h3
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfUnit.h16
-rw-r--r--test/DebugInfo/X86/arange.ll5
-rw-r--r--test/DebugInfo/X86/fission-cu.ll3
5 files changed, 31 insertions, 7 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index f1ae89e93a..1aae6abad0 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -825,11 +825,7 @@ DwarfCompileUnit *DwarfDebug::constructDwarfCompileUnit(DICompileUnit DIUnit) {
NewCU->initSection(
useSplitDwarf() ? Asm->getObjFileLowering().getDwarfInfoDWOSection()
: Asm->getObjFileLowering().getDwarfInfoSection(),
- // FIXME: This is subtle (using the info section even when
- // this CU is in the dwo section) and necessary for the
- // current arange code - ideally it should iterate
- // skeleton units, not full units, if it's going to reference skeletons
- DwarfInfoSectionSym);
+ useSplitDwarf() ? DwarfInfoDWOSectionSym : DwarfInfoSectionSym);
// If we're splitting the dwarf then construct the skeleton CU now.
if (useSplitDwarf())
@@ -2010,6 +2006,9 @@ void DwarfDebug::emitSectionLabels() {
// Dwarf sections base addresses.
DwarfInfoSectionSym =
emitSectionSym(Asm, TLOF.getDwarfInfoSection(), "section_info");
+ if (useSplitDwarf())
+ DwarfInfoDWOSectionSym =
+ emitSectionSym(Asm, TLOF.getDwarfInfoDWOSection(), "section_info_dwo");
DwarfAbbrevSectionSym =
emitSectionSym(Asm, TLOF.getDwarfAbbrevSection(), "section_abbrev");
if (useSplitDwarf())
@@ -2875,7 +2874,7 @@ void DwarfDebug::emitDebugARanges() {
Asm->OutStreamer.AddComment("DWARF Arange version number");
Asm->EmitInt16(dwarf::DW_ARANGES_VERSION);
Asm->OutStreamer.AddComment("Offset Into Debug Info Section");
- Asm->EmitSectionOffset(CU->getLabelBegin(), CU->getSectionSym());
+ Asm->EmitSectionOffset(CU->getLocalLabelBegin(), CU->getLocalSectionSym());
Asm->OutStreamer.AddComment("Address Size (in bytes)");
Asm->EmitInt8(PtrSize);
Asm->OutStreamer.AddComment("Segment Size (in bytes)");
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h
index 10ce17fa2d..b81688ea3f 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -429,7 +429,8 @@ class DwarfDebug : public AsmPrinterHandler {
MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym;
MCSymbol *DwarfDebugLocSectionSym, *DwarfLineSectionSym, *DwarfAddrSectionSym;
MCSymbol *FunctionBeginSym, *FunctionEndSym;
- MCSymbol *DwarfAbbrevDWOSectionSym, *DwarfStrDWOSectionSym;
+ MCSymbol *DwarfInfoDWOSectionSym, *DwarfAbbrevDWOSectionSym;
+ MCSymbol *DwarfStrDWOSectionSym;
MCSymbol *DwarfGnuPubNamesSectionSym, *DwarfGnuPubTypesSectionSym;
// As an optimization, there is no need to emit an entry in the directory
diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.h b/lib/CodeGen/AsmPrinter/DwarfUnit.h
index 49c9b0cedc..d5cb9b4f0e 100644
--- a/lib/CodeGen/AsmPrinter/DwarfUnit.h
+++ b/lib/CodeGen/AsmPrinter/DwarfUnit.h
@@ -180,11 +180,27 @@ public:
return Section;
}
+ /// If there's a skeleton then return the section symbol for the skeleton
+ /// unit, otherwise return the section symbol for this unit.
+ MCSymbol *getLocalSectionSym() const {
+ if (Skeleton)
+ return Skeleton->getSectionSym();
+ return SectionSym;
+ }
+
MCSymbol *getSectionSym() const {
assert(Section);
return SectionSym;
}
+ /// If there's a skeleton then return the begin label for the skeleton unit,
+ /// otherwise return the local label for this unit.
+ MCSymbol *getLocalLabelBegin() const {
+ if (Skeleton)
+ return Skeleton->getLabelBegin();
+ return LabelBegin;
+ }
+
MCSymbol *getLabelBegin() const {
assert(Section);
return LabelBegin;
diff --git a/test/DebugInfo/X86/arange.ll b/test/DebugInfo/X86/arange.ll
index fd0d0a3e08..819f9863bc 100644
--- a/test/DebugInfo/X86/arange.ll
+++ b/test/DebugInfo/X86/arange.ll
@@ -1,6 +1,7 @@
; REQUIRES: object-emission
; RUN: llc -mtriple=x86_64-linux -O0 -filetype=obj < %s | llvm-dwarfdump -debug-dump=aranges - | FileCheck %s
+; RUN: llc -mtriple=x86_64-linux -O0 -filetype=obj < %s | llvm-readobj --relocations - | FileCheck --check-prefix=OBJ %s
; extern int i;
; template<int *x>
@@ -15,6 +16,10 @@
; CHECK-NEXT: [0x
; CHECK-NOT: [0x
+; Check that we have a relocation back to the debug_info section from the debug_aranges section
+; OBJ: debug_aranges
+; OBJ-NEXT: R_X86_64_32 .debug_info 0x0
+
%struct.foo = type { i8 }
@f = global %struct.foo zeroinitializer, align 1
diff --git a/test/DebugInfo/X86/fission-cu.ll b/test/DebugInfo/X86/fission-cu.ll
index 1d0ec27af0..135c78029a 100644
--- a/test/DebugInfo/X86/fission-cu.ll
+++ b/test/DebugInfo/X86/fission-cu.ll
@@ -112,4 +112,7 @@
; OBJ-NEXT: R_X86_64_32 .debug_str
; OBJ-NEXT: R_X86_64_64 .text 0x0
; OBJ-NEXT: }
+; OBJ: .debug_aranges
+; OBJ-NEXT: R_X86_64_32 .debug_info 0x0
+
!9 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}