Skip to content

Commit

Permalink
Fix aranges and split dwarf by ensuring that the symbol and relocation
Browse files Browse the repository at this point in the history
back to the compile unit from the aranges section is to the skeleton
unit and not the one in the dwo.

Do this by adding a method to grab a forwarded on local sym and local
section by querying the skeleton if one exists and using that. Add
a few tests to verify the relocations are back to the correct section.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198202 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
echristo committed Dec 30, 2013
1 parent 8e58e03 commit 782b70f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
11 changes: 5 additions & 6 deletions lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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)");
Expand Down
3 changes: 2 additions & 1 deletion lib/CodeGen/AsmPrinter/DwarfDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions lib/CodeGen/AsmPrinter/DwarfUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,27 @@ class DwarfUnit {
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;
Expand Down
5 changes: 5 additions & 0 deletions test/DebugInfo/X86/arange.ll
Original file line number Diff line number Diff line change
@@ -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>
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/DebugInfo/X86/fission-cu.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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}

0 comments on commit 782b70f

Please sign in to comment.