Use DW_AT_high_pc and DW_AT_low_pc for the high and low pc for a

compile unit. Make these relocations on the platforms that need
relocations and add a routine to ensure that we don't put the
addresses in an offset table for split dwarf.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199990 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Christopher
2014-01-24 11:40:29 +00:00
parent 45cd8c8ac1
commit a268ba84d7
6 changed files with 46 additions and 17 deletions

View File

@ -187,6 +187,7 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M)
DwarfAddrSectionSym = 0; DwarfAddrSectionSym = 0;
DwarfAbbrevDWOSectionSym = DwarfStrDWOSectionSym = 0; DwarfAbbrevDWOSectionSym = DwarfStrDWOSectionSym = 0;
FunctionBeginSym = FunctionEndSym = 0; FunctionBeginSym = FunctionEndSym = 0;
TextSectionBeginSym = TextSectionEndSym = 0;
CurFn = 0; CurFn = 0;
CurMI = 0; CurMI = 0;
@ -1061,9 +1062,12 @@ void DwarfDebug::finalizeModuleInfo() {
addSectionLabel(Asm, U, U->getUnitDie(), dwarf::DW_AT_ranges, addSectionLabel(Asm, U, U->getUnitDie(), dwarf::DW_AT_ranges,
Asm->GetTempSymbol("cu_ranges", U->getUniqueID()), Asm->GetTempSymbol("cu_ranges", U->getUniqueID()),
DwarfDebugRangeSectionSym); DwarfDebugRangeSectionSym);
else else {
U->addUInt(U->getUnitDie(), dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, U->addLocalLabelAddress(U->getUnitDie(), dwarf::DW_AT_low_pc,
0); TextSectionBeginSym);
U->addLocalLabelAddress(U->getUnitDie(), dwarf::DW_AT_high_pc,
TextSectionEndSym);
}
} }
} }
@ -1117,6 +1121,10 @@ void DwarfDebug::endSections() {
Sym = Asm->GetTempSymbol("debug_end", ID); Sym = Asm->GetTempSymbol("debug_end", ID);
Asm->OutStreamer.SwitchSection(Section); Asm->OutStreamer.SwitchSection(Section);
Asm->OutStreamer.EmitLabel(Sym); Asm->OutStreamer.EmitLabel(Sym);
// If this is the end of the text section keep track of where the end of
// the section is so that we can use it later.
if (Section == Asm->getObjFileLowering().getTextSection())
TextSectionEndSym = Sym;
} }
// Insert a final terminator. // Insert a final terminator.
@ -2012,6 +2020,8 @@ void DwarfDebug::emitSectionLabels() {
DwarfDebugLocSectionSym = DwarfDebugLocSectionSym =
emitSectionSym(Asm, TLOF.getDwarfLocSection(), "section_debug_loc"); emitSectionSym(Asm, TLOF.getDwarfLocSection(), "section_debug_loc");
TextSectionBeginSym = emitSectionSym(Asm, TLOF.getTextSection(), "text_begin");
} }
// Recursively emits a debug information entry. // Recursively emits a debug information entry.

View File

@ -432,6 +432,7 @@ class DwarfDebug : public AsmPrinterHandler {
MCSymbol *DwarfInfoDWOSectionSym, *DwarfAbbrevDWOSectionSym; MCSymbol *DwarfInfoDWOSectionSym, *DwarfAbbrevDWOSectionSym;
MCSymbol *DwarfStrDWOSectionSym; MCSymbol *DwarfStrDWOSectionSym;
MCSymbol *DwarfGnuPubNamesSectionSym, *DwarfGnuPubTypesSectionSym; MCSymbol *DwarfGnuPubNamesSectionSym, *DwarfGnuPubTypesSectionSym;
MCSymbol *TextSectionBeginSym, *TextSectionEndSym;
// As an optimization, there is no need to emit an entry in the directory // As an optimization, there is no need to emit an entry in the directory
// table for the same directory as DW_AT_comp_dir. // table for the same directory as DW_AT_comp_dir.

View File

@ -266,10 +266,26 @@ void DwarfUnit::addSectionOffset(DIE *Die, dwarf::Attribute Attribute,
/// ///
void DwarfCompileUnit::addLabelAddress(DIE *Die, dwarf::Attribute Attribute, void DwarfCompileUnit::addLabelAddress(DIE *Die, dwarf::Attribute Attribute,
MCSymbol *Label) { MCSymbol *Label) {
if (!DD->useSplitDwarf())
return addLocalLabelAddress(Die, Attribute, Label);
if (Label)
DD->addArangeLabel(SymbolCU(this, Label));
unsigned idx = DU->getAddrPoolIndex(Label);
DIEValue *Value = new (DIEValueAllocator) DIEInteger(idx);
Die->addValue(Attribute, dwarf::DW_FORM_GNU_addr_index, Value);
}
/// addLocalLabelAddress - Add a dwarf label attribute data and value using
/// DW_FORM_addr only.
///
void DwarfCompileUnit::addLocalLabelAddress(DIE *Die,
dwarf::Attribute Attribute,
MCSymbol *Label) {
if (Label) if (Label)
DD->addArangeLabel(SymbolCU(this, Label)); DD->addArangeLabel(SymbolCU(this, Label));
if (!DD->useSplitDwarf()) {
if (Label) { if (Label) {
DIEValue *Value = new (DIEValueAllocator) DIELabel(Label); DIEValue *Value = new (DIEValueAllocator) DIELabel(Label);
Die->addValue(Attribute, dwarf::DW_FORM_addr, Value); Die->addValue(Attribute, dwarf::DW_FORM_addr, Value);
@ -277,11 +293,6 @@ void DwarfCompileUnit::addLabelAddress(DIE *Die, dwarf::Attribute Attribute,
DIEValue *Value = new (DIEValueAllocator) DIEInteger(0); DIEValue *Value = new (DIEValueAllocator) DIEInteger(0);
Die->addValue(Attribute, dwarf::DW_FORM_addr, Value); Die->addValue(Attribute, dwarf::DW_FORM_addr, Value);
} }
} else {
unsigned idx = DU->getAddrPoolIndex(Label);
DIEValue *Value = new (DIEValueAllocator) DIEInteger(idx);
Die->addValue(Attribute, dwarf::DW_FORM_GNU_addr_index, Value);
}
} }
/// addOpAddress - Add a dwarf op address data and value using the /// addOpAddress - Add a dwarf op address data and value using the

View File

@ -545,6 +545,11 @@ public:
/// addLabelAddress - Add a dwarf label attribute data and value using /// addLabelAddress - Add a dwarf label attribute data and value using
/// either DW_FORM_addr or DW_FORM_GNU_addr_index. /// either DW_FORM_addr or DW_FORM_GNU_addr_index.
void addLabelAddress(DIE *Die, dwarf::Attribute Attribute, MCSymbol *Label); void addLabelAddress(DIE *Die, dwarf::Attribute Attribute, MCSymbol *Label);
/// addLocalLabelAddress - Add a dwarf label attribute data and value using
/// DW_FORM_addr only.
void addLocalLabelAddress(DIE *Die, dwarf::Attribute Attribute,
MCSymbol *Label);
}; };
class DwarfTypeUnit : public DwarfUnit { class DwarfTypeUnit : public DwarfUnit {

View File

@ -7,15 +7,15 @@
; first check that we have a TAG_subprogram at a given offset and it has ; first check that we have a TAG_subprogram at a given offset and it has
; AT_inline. ; AT_inline.
; CHECK: 0x0000011c: DW_TAG_subprogram [17] ; CHECK: 0x00000124: DW_TAG_subprogram [17]
; CHECK-NEXT: DW_AT_specification ; CHECK-NEXT: DW_AT_specification
; CHECK-NEXT: DW_AT_inline ; CHECK-NEXT: DW_AT_inline
; and then that a TAG_subprogram refers to it with AT_abstract_origin. ; and then that a TAG_subprogram refers to it with AT_abstract_origin.
; CHECK: 0x0000015d: DW_TAG_subprogram [19] ; CHECK: 0x00000165: DW_TAG_subprogram [19]
; CHECK-NEXT: DW_AT_abstract_origin [DW_FORM_ref4] (cu + 0x011c => {0x0000011c}) ; CHECK-NEXT: DW_AT_abstract_origin [DW_FORM_ref4] (cu + 0x0124 => {0x00000124})
define i32 @_ZN17nsAutoRefCnt7ReleaseEv() { define i32 @_ZN17nsAutoRefCnt7ReleaseEv() {
entry: entry:

View File

@ -109,6 +109,8 @@
; OBJ-NEXT: R_X86_64_32 .debug_str ; OBJ-NEXT: R_X86_64_32 .debug_str
; OBJ-NEXT: R_X86_64_32 .debug_addr ; OBJ-NEXT: R_X86_64_32 .debug_addr
; OBJ-NEXT: R_X86_64_32 .debug_str ; OBJ-NEXT: R_X86_64_32 .debug_str
; OBJ-NEXT: R_X86_64_64 .text 0x0
; OBJ-NEXT: R_X86_64_64 .text 0x0
; OBJ-NEXT: } ; OBJ-NEXT: }
; OBJ: .debug_aranges ; OBJ: .debug_aranges
; OBJ-NEXT: R_X86_64_32 .debug_info 0x0 ; OBJ-NEXT: R_X86_64_32 .debug_info 0x0