aboutsummaryrefslogtreecommitdiffstats
path: root/lib/MC/MCDwarf.cpp
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2012-11-14 09:55:38 +0000
committerAlexey Samsonov <samsonov@google.com>2012-11-14 09:55:38 +0000
commit15ab115df57949fa55d92ffdfba491f7d02ed60f (patch)
tree14092148386f5a8934fbf41a657e29a3fff9e6a5 /lib/MC/MCDwarf.cpp
parent1e65676a12c61815acb65990d9269611ad544c78 (diff)
downloadexternal_llvm-15ab115df57949fa55d92ffdfba491f7d02ed60f.zip
external_llvm-15ab115df57949fa55d92ffdfba491f7d02ed60f.tar.gz
external_llvm-15ab115df57949fa55d92ffdfba491f7d02ed60f.tar.bz2
Emit relocations from .debug_aranges to .debug_info for asm files
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167926 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCDwarf.cpp')
-rw-r--r--lib/MC/MCDwarf.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/lib/MC/MCDwarf.cpp b/lib/MC/MCDwarf.cpp
index f71b266..bb9ed49 100644
--- a/lib/MC/MCDwarf.cpp
+++ b/lib/MC/MCDwarf.cpp
@@ -484,7 +484,8 @@ static void EmitGenDwarfAbbrev(MCStreamer *MCOS) {
// .debug_aranges section. Which contains a header and a table of pairs of
// PointerSize'ed values for the address and size of section(s) with line table
// entries (just the default .text in our case) and a terminating pair of zeros.
-static void EmitGenDwarfAranges(MCStreamer *MCOS) {
+static void EmitGenDwarfAranges(MCStreamer *MCOS,
+ const MCSymbol *InfoSectionSymbol) {
MCContext &context = MCOS->getContext();
// Create a symbol at the end of the section that we are creating the dwarf
@@ -523,8 +524,11 @@ static void EmitGenDwarfAranges(MCStreamer *MCOS) {
// The 2 byte version, which is 2.
MCOS->EmitIntValue(2, 2);
// The 4 byte offset to the compile unit in the .debug_info from the start
- // of the .debug_info, it is at the start of that section so this is zero.
- MCOS->EmitIntValue(0, 4);
+ // of the .debug_info.
+ if (InfoSectionSymbol)
+ MCOS->EmitSymbolValue(InfoSectionSymbol, 4);
+ else
+ MCOS->EmitIntValue(0, 4);
// The 1 byte size of an address.
MCOS->EmitIntValue(AddrSize, 1);
// The 1 byte size of a segment descriptor, we use a value of zero.
@@ -705,15 +709,21 @@ void MCGenDwarfInfo::Emit(MCStreamer *MCOS, const MCSymbol *LineSectionSymbol) {
// Create the dwarf sections in this order (.debug_line already created).
MCContext &context = MCOS->getContext();
const MCAsmInfo &AsmInfo = context.getAsmInfo();
+ bool CreateDwarfSectionSymbols =
+ AsmInfo.doesDwarfUseRelocationsAcrossSections();
+ if (!CreateDwarfSectionSymbols)
+ LineSectionSymbol = NULL;
+ MCSymbol *AbbrevSectionSymbol = NULL;
+ MCSymbol *InfoSectionSymbol = NULL;
MCOS->SwitchSection(context.getObjectFileInfo()->getDwarfInfoSection());
+ if (CreateDwarfSectionSymbols) {
+ InfoSectionSymbol = context.CreateTempSymbol();
+ MCOS->EmitLabel(InfoSectionSymbol);
+ }
MCOS->SwitchSection(context.getObjectFileInfo()->getDwarfAbbrevSection());
- MCSymbol *AbbrevSectionSymbol;
- if (AsmInfo.doesDwarfUseRelocationsAcrossSections()) {
+ if (CreateDwarfSectionSymbols) {
AbbrevSectionSymbol = context.CreateTempSymbol();
MCOS->EmitLabel(AbbrevSectionSymbol);
- } else {
- AbbrevSectionSymbol = NULL;
- LineSectionSymbol = NULL;
}
MCOS->SwitchSection(context.getObjectFileInfo()->getDwarfARangesSection());
@@ -722,7 +732,7 @@ void MCGenDwarfInfo::Emit(MCStreamer *MCOS, const MCSymbol *LineSectionSymbol) {
return;
// Output the data for .debug_aranges section.
- EmitGenDwarfAranges(MCOS);
+ EmitGenDwarfAranges(MCOS, InfoSectionSymbol);
// Output the data for .debug_abbrev section.
EmitGenDwarfAbbrev(MCOS);