[llvm-commits] [llvm] r120866 - in /llvm/trunk: include/llvm/MC/MCAsmInfo.h include/llvm/MC/MCDwarf.h lib/MC/MCAsmInfo.cpp lib/MC/MCAsmInfoDarwin.cpp lib/MC/MCAsmStreamer.cpp lib/MC/MCDwarf.cpp test/MC/ELF/empty-dwarf-lines.s test/MC/MachO/empty-dwarf-lines.s
Rafael Espindola
rafael.espindola at gmail.com
Fri Dec 3 16:31:13 PST 2010
Author: rafael
Date: Fri Dec 3 18:31:13 2010
New Revision: 120866
URL: http://llvm.org/viewvc/llvm-project?rev=120866&view=rev
Log:
Next step: Only pad debug_line when the target is darwin. Add a FIXME to avoid
doing that if the target is darwin10 or newer.
This fixes
*) Direct object emission was producing objects without the workaround on
darwin9.
*) Assembly printing was producing objects with the workaround on linux.
Added:
llvm/trunk/test/MC/ELF/empty-dwarf-lines.s
llvm/trunk/test/MC/MachO/empty-dwarf-lines.s
Modified:
llvm/trunk/include/llvm/MC/MCAsmInfo.h
llvm/trunk/include/llvm/MC/MCDwarf.h
llvm/trunk/lib/MC/MCAsmInfo.cpp
llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp
llvm/trunk/lib/MC/MCAsmStreamer.cpp
llvm/trunk/lib/MC/MCDwarf.cpp
Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmInfo.h?rev=120866&r1=120865&r2=120866&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAsmInfo.h (original)
+++ llvm/trunk/include/llvm/MC/MCAsmInfo.h Fri Dec 3 18:31:13 2010
@@ -51,6 +51,11 @@
/// emitted in Static relocation model.
bool HasStaticCtorDtorReferenceInStaticMode; // Default is false.
+ /// LinkerRequiresNonEmptyDwarfLines - True if the linker has a bug and
+ /// requires that the debug_line section be of a minimum size. In practice
+ /// such a linker requires a non empty line sequence if a file is present.
+ bool LinkerRequiresNonEmptyDwarfLines; // Default to false.
+
/// MaxInstLength - This is the maximum possible length of an instruction,
/// which is needed to compute the size of an inline asm.
unsigned MaxInstLength; // Defaults to 4.
@@ -322,6 +327,9 @@
bool hasStaticCtorDtorReferenceInStaticMode() const {
return HasStaticCtorDtorReferenceInStaticMode;
}
+ bool getLinkerRequiresNonEmptyDwarfLines() const {
+ return LinkerRequiresNonEmptyDwarfLines;
+ }
unsigned getMaxInstLength() const {
return MaxInstLength;
}
Modified: llvm/trunk/include/llvm/MC/MCDwarf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCDwarf.h?rev=120866&r1=120865&r2=120866&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCDwarf.h (original)
+++ llvm/trunk/include/llvm/MC/MCDwarf.h Fri Dec 3 18:31:13 2010
@@ -208,8 +208,7 @@
//
// This emits the Dwarf file and the line tables.
//
- static void Emit(MCStreamer *MCOS, const MCSection *DwarfLineSection,
- const MCSection *TextSection = NULL);
+ static void Emit(MCStreamer *MCOS, const MCSection *DwarfLineSection);
};
class MCDwarfLineAddr {
Modified: llvm/trunk/lib/MC/MCAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfo.cpp?rev=120866&r1=120865&r2=120866&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmInfo.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmInfo.cpp Fri Dec 3 18:31:13 2010
@@ -23,6 +23,7 @@
HasMachoZeroFillDirective = false;
HasMachoTBSSDirective = false;
HasStaticCtorDtorReferenceInStaticMode = false;
+ LinkerRequiresNonEmptyDwarfLines = false;
MaxInstLength = 4;
PCSymbol = "$";
SeparatorChar = ';';
Modified: llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp?rev=120866&r1=120865&r2=120866&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp Fri Dec 3 18:31:13 2010
@@ -37,6 +37,9 @@
HasMachoZeroFillDirective = true; // Uses .zerofill
HasMachoTBSSDirective = true; // Uses .tbss
HasStaticCtorDtorReferenceInStaticMode = true;
+
+ // FIXME: Darwin 10 and newer don't need this.
+ LinkerRequiresNonEmptyDwarfLines = true;
HiddenVisibilityAttr = MCSA_PrivateExtern;
// Doesn't support protected visibility.
Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=120866&r1=120865&r2=120866&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Fri Dec 3 18:31:13 2010
@@ -896,8 +896,7 @@
void MCAsmStreamer::Finish() {
// Dump out the dwarf file & directory tables and line tables.
if (getContext().hasDwarfFiles() && TLOF)
- MCDwarfFileTable::Emit(this, TLOF->getDwarfLineSection(),
- TLOF->getTextSection());
+ MCDwarfFileTable::Emit(this, TLOF->getDwarfLineSection());
}
MCStreamer *llvm::createAsmStreamer(MCContext &Context,
Modified: llvm/trunk/lib/MC/MCDwarf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=120866&r1=120865&r2=120866&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCDwarf.cpp (original)
+++ llvm/trunk/lib/MC/MCDwarf.cpp Fri Dec 3 18:31:13 2010
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCStreamer.h"
@@ -198,8 +199,7 @@
// This emits the Dwarf file and the line tables.
//
void MCDwarfFileTable::Emit(MCStreamer *MCOS,
- const MCSection *DwarfLineSection,
- const MCSection *TextSection) {
+ const MCSection *DwarfLineSection) {
// Switch to the section where the table will be emitted into.
MCOS->SwitchSection(DwarfLineSection);
@@ -296,7 +296,8 @@
delete Line;
}
- if (TextSection && MCLineSectionOrder.begin() == MCLineSectionOrder.end()) {
+ if (MCOS->getContext().getAsmInfo().getLinkerRequiresNonEmptyDwarfLines()
+ && MCLineSectionOrder.begin() == MCLineSectionOrder.end()) {
// The darwin9 linker has a bug (see PR8715). For for 32-bit architectures
// it requires:
// total_length >= prologue_length + 10
Added: llvm/trunk/test/MC/ELF/empty-dwarf-lines.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/empty-dwarf-lines.s?rev=120866&view=auto
==============================================================================
--- llvm/trunk/test/MC/ELF/empty-dwarf-lines.s (added)
+++ llvm/trunk/test/MC/ELF/empty-dwarf-lines.s Fri Dec 3 18:31:13 2010
@@ -0,0 +1,21 @@
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump | FileCheck %s
+
+// Test that the dwarf debug_line section contains no line directives.
+
+ .file 1 "test.c"
+ .globl c
+c:
+ .asciz "hi\n"
+
+// CHECK: # Section 0x00000004
+// CHECK-NEXT: (('sh_name', 0x00000012) # '.debug_line'
+// CHECK-NEXT: ('sh_type', 0x00000000)
+// CHECK-NEXT: ('sh_flags', 0x00000000)
+// CHECK-NEXT: ('sh_addr', 0x00000000)
+// CHECK-NEXT: ('sh_offset', 0x00000044)
+// CHECK-NEXT: ('sh_size', 0x00000027)
+// CHECK-NEXT: ('sh_link', 0x00000000)
+// CHECK-NEXT: ('sh_info', 0x00000000)
+// CHECK-NEXT: ('sh_addralign', 0x00000001)
+// CHECK-NEXT: ('sh_entsize', 0x00000000)
+// CHECK-NEXT: ),
Added: llvm/trunk/test/MC/MachO/empty-dwarf-lines.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/empty-dwarf-lines.s?rev=120866&view=auto
==============================================================================
--- llvm/trunk/test/MC/MachO/empty-dwarf-lines.s (added)
+++ llvm/trunk/test/MC/MachO/empty-dwarf-lines.s Fri Dec 3 18:31:13 2010
@@ -0,0 +1,25 @@
+// RUN: llvm-mc -triple x86_64-apple-darwin9 %s -filetype=obj -o - | macho-dump | FileCheck %s
+
+// This tests that when producing files for darwin9 or older we make sure
+// that debug_line sections are of a minimum size to avoid the linker bug
+// described in PR8715.
+
+ .section __DATA,__data
+ .file 1 "test.c"
+ .globl _c ## @c
+_c:
+ .asciz "hi\n"
+
+// CHECK: (('section_name', '__debug_line\x00\x00\x00\x00')
+// CHECK-NEXT: ('segment_name', '__DWARF\x00\x00\x00\x00\x00\x00\x00\x00\x00')
+// CHECK-NEXT: ('address', 4)
+// CHECK-NEXT: ('size', 44)
+// CHECK-NEXT: ('offset', 452)
+// CHECK-NEXT: ('alignment', 0)
+// CHECK-NEXT: ('reloc_offset', 496)
+// CHECK-NEXT: ('num_reloc', 4)
+// CHECK-NEXT: ('flags', 0x2000000)
+// CHECK-NEXT: ('reserved1', 0)
+// CHECK-NEXT: ('reserved2', 0)
+// CHECK-NEXT: ('reserved3', 0)
+// CHECK-NEXT: ),
More information about the llvm-commits
mailing list