[llvm-commits] [llvm] r131149 - in /llvm/trunk: lib/MC/MCDwarf.cpp test/MC/MachO/debug_frame.s
Rafael Espindola
rafael.espindola at gmail.com
Tue May 10 13:59:42 PDT 2011
Author: rafael
Date: Tue May 10 15:59:42 2011
New Revision: 131149
URL: http://llvm.org/viewvc/llvm-project?rev=131149&view=rev
Log:
On MachO, unlike ELF, there should be no relocation to produce the CIE pointer.
Added:
llvm/trunk/test/MC/MachO/debug_frame.s
Modified:
llvm/trunk/lib/MC/MCDwarf.cpp
Modified: llvm/trunk/lib/MC/MCDwarf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=131149&r1=131148&r2=131149&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCDwarf.cpp (original)
+++ llvm/trunk/lib/MC/MCDwarf.cpp Tue May 10 15:59:42 2011
@@ -502,11 +502,12 @@
int CIENum;
bool UsingCFI;
bool IsEH;
+ const MCSymbol *SectionStart;
public:
- FrameEmitterImpl(bool usingCFI, bool isEH) : CFAOffset(0), CIENum(0),
- UsingCFI(usingCFI),
- IsEH(isEH) {
+ FrameEmitterImpl(bool usingCFI, bool isEH, const MCSymbol *sectionStart) :
+ CFAOffset(0), CIENum(0), UsingCFI(usingCFI), IsEH(isEH),
+ SectionStart(sectionStart) {
}
const MCSymbol &EmitCIE(MCStreamer &streamer,
@@ -737,9 +738,9 @@
MCContext &context = streamer.getContext();
MCSymbol *fdeStart = context.CreateTempSymbol();
MCSymbol *fdeEnd = context.CreateTempSymbol();
- const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
+ const TargetAsmInfo &TAsmInfo = context.getTargetAsmInfo();
- if (!asmInfo.isFunctionEHFrameSymbolPrivate() && IsEH) {
+ if (!TAsmInfo.isFunctionEHFrameSymbolPrivate() && IsEH) {
MCSymbol *EHSym = context.GetOrCreateSymbol(
frame.Function->getName() + Twine(".eh"));
streamer.EmitEHSymAttributes(frame.Function, EHSym);
@@ -751,15 +752,21 @@
streamer.EmitAbsValue(Length, 4);
streamer.EmitLabel(fdeStart);
+
// CIE Pointer
+ const MCAsmInfo &asmInfo = context.getAsmInfo();
if (IsEH) {
const MCExpr *offset = MakeStartMinusEndExpr(streamer, cieStart, *fdeStart,
0);
streamer.EmitAbsValue(offset, 4);
+ } else if (!asmInfo.doesDwarfRequireRelocationForSectionOffset()) {
+ const MCExpr *offset = MakeStartMinusEndExpr(streamer, *SectionStart,
+ cieStart, 0);
+ streamer.EmitAbsValue(offset, 4);
} else {
streamer.EmitSymbolValue(&cieStart, 4);
}
- unsigned fdeEncoding = asmInfo.getFDEEncoding(UsingCFI);
+ unsigned fdeEncoding = TAsmInfo.getFDEEncoding(UsingCFI);
unsigned size = getSizeForEncoding(streamer, fdeEncoding);
// PC Begin
@@ -840,15 +847,17 @@
void MCDwarfFrameEmitter::Emit(MCStreamer &streamer,
bool usingCFI,
bool isEH) {
- const MCContext &context = streamer.getContext();
+ MCContext &context = streamer.getContext();
const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
const MCSection §ion = isEH ?
*asmInfo.getEHFrameSection() : *asmInfo.getDwarfFrameSection();
streamer.SwitchSection(§ion);
+ MCSymbol *SectionStart = context.CreateTempSymbol();
+ streamer.EmitLabel(SectionStart);
MCSymbol *fdeEnd = NULL;
DenseMap<CIEKey, const MCSymbol*> CIEStarts;
- FrameEmitterImpl Emitter(usingCFI, isEH);
+ FrameEmitterImpl Emitter(usingCFI, isEH, SectionStart);
const MCSymbol *DummyDebugKey = NULL;
for (unsigned i = 0, n = streamer.getNumFrameInfos(); i < n; ++i) {
Added: llvm/trunk/test/MC/MachO/debug_frame.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/debug_frame.s?rev=131149&view=auto
==============================================================================
--- llvm/trunk/test/MC/MachO/debug_frame.s (added)
+++ llvm/trunk/test/MC/MachO/debug_frame.s Tue May 10 15:59:42 2011
@@ -0,0 +1,38 @@
+// RUN: llvm-mc -triple i386-apple-darwin %s -filetype=obj -o - | macho-dump | FileCheck %s
+
+// Check that we don't produce a relocation for the CIE pointer and therefore
+// we have only one relocation in __debug_frame.
+
+ .section __TEXT,__text,regular,pure_instructions
+ .globl _f
+ .align 4, 0x90
+_f: ## @f
+Ltmp0:
+ .cfi_startproc
+## BB#0: ## %entry
+ movl $42, %eax
+ ret
+Ltmp1:
+ .cfi_endproc
+Leh_func_end0:
+
+ .cfi_sections .debug_frame
+Ltext_end:
+
+// CHECK: (('section_name', '__debug_frame\x00\x00\x00')
+// CHECK-NEXT: ('segment_name', '__DWARF\x00\x00\x00\x00\x00\x00\x00\x00\x00')
+// CHECK-NEXT: ('address', 8)
+// CHECK-NEXT: ('size', 36)
+// CHECK-NEXT: ('offset', 332)
+// CHECK-NEXT: ('alignment', 2)
+// CHECK-NEXT: ('reloc_offset', 368)
+// CHECK-NEXT: ('num_reloc', 1)
+// CHECK-NEXT: ('flags', 0x2000000)
+// CHECK-NEXT: ('reserved1', 0)
+// CHECK-NEXT: ('reserved2', 0)
+// CHECK-NEXT: ),
+// CHECK-NEXT: ('_relocations', [
+// CHECK-NEXT: # Relocation 0
+// CHECK-NEXT: (('word-0', 0x1c),
+// CHECK-NEXT: ('word-1', 0x4000001)),
+// CHECK-NEXT: ])
More information about the llvm-commits
mailing list