diff options
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp index a224db84004..895898594eb 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp @@ -39,17 +39,23 @@ DwarfPrinter::DwarfPrinter(AsmPrinter *A) void DwarfPrinter::EmitSectionOffset(const MCSymbol *Label, - const MCSymbol *Section) { - if (!MAI->isAbsoluteDebugSectionOffsets()) - return Asm->EmitLabelDifference(Label, Section, 4); - - // On COFF targets, we have to emit the weird .secrel32 directive. + const char *SectionLabel) { + // On COFF targets, we have to emit the special .secrel32 directive. if (const char *SecOffDir = MAI->getDwarfSectionOffsetDirective()) { // FIXME: MCize. Asm->OutStreamer.EmitRawText(SecOffDir + Twine(Label->getName())); - } else { + return; + } + + // If the section in question will end up with an address of 0 anyway, we can + // just emit an absolute reference to save a relocation. + if (MAI->isAbsoluteDebugSectionOffsets()) { Asm->OutStreamer.EmitSymbolValue(Label, 4, 0/*AddrSpace*/); + return; } + + MCSymbol *SectionSym = Asm->GetTempSymbol(SectionLabel); + Asm->EmitLabelDifference(Label, SectionSym, 4); } /// EmitFrameMoves - Emit frame instructions to describe the layout of the |