[llvm-commits] [llvm] r103112 - in /llvm/trunk: lib/MC/MCAsmStreamer.cpp lib/MC/MCMachOStreamer.cpp lib/MC/MCSymbol.cpp lib/MC/MachObjectWriter.cpp test/MC/MachO/reloc.s
Daniel Dunbar
daniel at zuster.org
Wed May 5 12:01:05 PDT 2010
Author: ddunbar
Date: Wed May 5 14:01:05 2010
New Revision: 103112
URL: http://llvm.org/viewvc/llvm-project?rev=103112&view=rev
Log:
MC/Mach-O: Mark absolute variable's appropriately, and add Mach-O support for
writing them.
- <rdar://problem/7885351> integrated assembler broken for i386 objc code
Modified:
llvm/trunk/lib/MC/MCAsmStreamer.cpp
llvm/trunk/lib/MC/MCMachOStreamer.cpp
llvm/trunk/lib/MC/MCSymbol.cpp
llvm/trunk/lib/MC/MachObjectWriter.cpp
llvm/trunk/test/MC/MachO/reloc.s
Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=103112&r1=103111&r2=103112&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Wed May 5 14:01:05 2010
@@ -239,7 +239,6 @@
EmitEOL();
// FIXME: Lift context changes into super class.
- // FIXME: Set associated section.
Symbol->setVariableValue(Value);
}
Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=103112&r1=103111&r2=103112&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Wed May 5 14:01:05 2010
@@ -193,7 +193,6 @@
void MCMachOStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
// FIXME: Lift context changes into super class.
- // FIXME: Set associated section.
Symbol->setVariableValue(AddValueSymbols(Value));
}
Modified: llvm/trunk/lib/MC/MCSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCSymbol.cpp?rev=103112&r1=103111&r2=103112&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCSymbol.cpp (original)
+++ llvm/trunk/lib/MC/MCSymbol.cpp Wed May 5 14:01:05 2010
@@ -44,6 +44,10 @@
assert((isUndefined() || (isAbsolute() && isa<MCConstantExpr>(Value))) &&
"Invalid redefinition!");
this->Value = Value;
+
+ // Mark the variable as absolute as appropriate.
+ if (isa<MCConstantExpr>(Value))
+ setAbsolute();
}
void MCSymbol::print(raw_ostream &OS) const {
Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=103112&r1=103111&r2=103112&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/MachObjectWriter.cpp Wed May 5 14:01:05 2010
@@ -404,7 +404,7 @@
// Compute the symbol address.
if (Symbol.isDefined()) {
if (Symbol.isAbsolute()) {
- llvm_unreachable("FIXME: Not yet implemented!");
+ Address = cast<MCConstantExpr>(Symbol.getVariableValue())->getValue();
} else {
Address = Layout.getSymbolAddress(&Data);
}
@@ -552,7 +552,7 @@
// possible. This seems to be done because the debugger doesn't fully
// understand x86_64 relocation entries, and expects to find values that
// have already been fixed up.
- if (Symbol->isDefined()) {
+ if (Symbol->isInSection()) {
const MCSectionMachO &Section = static_cast<const MCSectionMachO&>(
Fragment->getParent()->getSection());
if (Section.hasAttribute(MCSectionMachO::S_ATTR_DEBUG))
Modified: llvm/trunk/test/MC/MachO/reloc.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/reloc.s?rev=103112&r1=103111&r2=103112&view=diff
==============================================================================
--- llvm/trunk/test/MC/MachO/reloc.s (original)
+++ llvm/trunk/test/MC/MachO/reloc.s Wed May 5 14:01:05 2010
@@ -41,6 +41,9 @@
jmp L1
ret
+ .objc_class_name_A=0
+ .globl .objc_class_name_A
+
// CHECK: ('cputype', 7)
// CHECK: ('cpusubtype', 3)
// CHECK: ('filetype', 1)
@@ -117,10 +120,10 @@
// CHECK: ('word-1', 0x4000002)),
// CHECK: # Relocation 7
// CHECK: (('word-0', 0x4),
-// CHECK: ('word-1', 0xc000007)),
+// CHECK: ('word-1', 0xc000008)),
// CHECK: # Relocation 8
// CHECK: (('word-0', 0x0),
-// CHECK: ('word-1', 0xc000007)),
+// CHECK: ('word-1', 0xc000008)),
// CHECK: ])
// CHECK: ('_section_data', '\x00\x00\x00\x00\x04\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xed\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x19\x00\x00\x00"\x00\x00\x00,\x00q')
// CHECK: # Section 2
@@ -157,13 +160,13 @@
// CHECK: (('command', 2)
// CHECK: ('size', 24)
// CHECK: ('symoff', 568)
-// CHECK: ('nsyms', 8)
-// CHECK: ('stroff', 664)
-// CHECK: ('strsize', 64)
-// CHECK: ('_string_data', '\x00undef\x00local_a_ext\x00local_a\x00local_a_elt\x00local_b\x00local_c\x00bar\x00_f0\x00\x00')
+// CHECK: ('nsyms', 9)
+// CHECK: ('stroff', 676)
+// CHECK: ('strsize', 84)
+// CHECK: ('_string_data', '\x00undef\x00local_a_ext\x00.objc_class_name_A\x00local_a\x00local_a_elt\x00local_b\x00local_c\x00bar\x00_f0\x00\x00\x00')
// CHECK: ('_symbols', [
// CHECK: # Symbol 0
-// CHECK: (('n_strx', 19)
+// CHECK: (('n_strx', 38)
// CHECK: ('n_type', 0xe)
// CHECK: ('n_sect', 2)
// CHECK: ('n_desc', 0)
@@ -171,7 +174,7 @@
// CHECK: ('_string', 'local_a')
// CHECK: ),
// CHECK: # Symbol 1
-// CHECK: (('n_strx', 27)
+// CHECK: (('n_strx', 46)
// CHECK: ('n_type', 0xe)
// CHECK: ('n_sect', 2)
// CHECK: ('n_desc', 0)
@@ -179,7 +182,7 @@
// CHECK: ('_string', 'local_a_elt')
// CHECK: ),
// CHECK: # Symbol 2
-// CHECK: (('n_strx', 39)
+// CHECK: (('n_strx', 58)
// CHECK: ('n_type', 0xe)
// CHECK: ('n_sect', 2)
// CHECK: ('n_desc', 0)
@@ -187,7 +190,7 @@
// CHECK: ('_string', 'local_b')
// CHECK: ),
// CHECK: # Symbol 3
-// CHECK: (('n_strx', 47)
+// CHECK: (('n_strx', 66)
// CHECK: ('n_type', 0xe)
// CHECK: ('n_sect', 2)
// CHECK: ('n_desc', 0)
@@ -195,7 +198,7 @@
// CHECK: ('_string', 'local_c')
// CHECK: ),
// CHECK: # Symbol 4
-// CHECK: (('n_strx', 55)
+// CHECK: (('n_strx', 74)
// CHECK: ('n_type', 0xe)
// CHECK: ('n_sect', 3)
// CHECK: ('n_desc', 0)
@@ -203,7 +206,7 @@
// CHECK: ('_string', 'bar')
// CHECK: ),
// CHECK: # Symbol 5
-// CHECK: (('n_strx', 59)
+// CHECK: (('n_strx', 78)
// CHECK: ('n_type', 0xe)
// CHECK: ('n_sect', 1)
// CHECK: ('n_desc', 0)
@@ -211,6 +214,14 @@
// CHECK: ('_string', '_f0')
// CHECK: ),
// CHECK: # Symbol 6
+// CHECK: (('n_strx', 19)
+// CHECK: ('n_type', 0x3)
+// CHECK: ('n_sect', 0)
+// CHECK: ('n_desc', 0)
+// CHECK: ('n_value', 0)
+// CHECK: ('_string', '.objc_class_name_A')
+// CHECK: ),
+// CHECK: # Symbol 7
// CHECK: (('n_strx', 7)
// CHECK: ('n_type', 0xf)
// CHECK: ('n_sect', 2)
@@ -218,7 +229,7 @@
// CHECK: ('n_value', 16)
// CHECK: ('_string', 'local_a_ext')
// CHECK: ),
-// CHECK: # Symbol 7
+// CHECK: # Symbol 8
// CHECK: (('n_strx', 1)
// CHECK: ('n_type', 0x1)
// CHECK: ('n_sect', 0)
@@ -234,8 +245,8 @@
// CHECK: ('ilocalsym', 0)
// CHECK: ('nlocalsym', 6)
// CHECK: ('iextdefsym', 6)
-// CHECK: ('nextdefsym', 1)
-// CHECK: ('iundefsym', 7)
+// CHECK: ('nextdefsym', 2)
+// CHECK: ('iundefsym', 8)
// CHECK: ('nundefsym', 1)
// CHECK: ('tocoff', 0)
// CHECK: ('ntoc', 0)
More information about the llvm-commits
mailing list