aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-05-05 19:01:05 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-05-05 19:01:05 +0000
commit2d7fd61e94e2db0586ad9d5d26c1e7c5510a006d (patch)
treea2454219fc120589f4fd74786a1b24437b223159
parentc304718fd8fa25f3f36f47f3de0e0cfe7578bc9e (diff)
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103112 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/MC/MCAsmStreamer.cpp1
-rw-r--r--lib/MC/MCMachOStreamer.cpp1
-rw-r--r--lib/MC/MCSymbol.cpp4
-rw-r--r--lib/MC/MachObjectWriter.cpp4
-rw-r--r--test/MC/MachO/reloc.s41
5 files changed, 32 insertions, 19 deletions
diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp
index 1d231bbffa..22b1a376e3 100644
--- a/lib/MC/MCAsmStreamer.cpp
+++ b/lib/MC/MCAsmStreamer.cpp
@@ -239,7 +239,6 @@ void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
EmitEOL();
// FIXME: Lift context changes into super class.
- // FIXME: Set associated section.
Symbol->setVariableValue(Value);
}
diff --git a/lib/MC/MCMachOStreamer.cpp b/lib/MC/MCMachOStreamer.cpp
index b4bd557535..5ca31943f1 100644
--- a/lib/MC/MCMachOStreamer.cpp
+++ b/lib/MC/MCMachOStreamer.cpp
@@ -193,7 +193,6 @@ void MCMachOStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
void MCMachOStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
// FIXME: Lift context changes into super class.
- // FIXME: Set associated section.
Symbol->setVariableValue(AddValueSymbols(Value));
}
diff --git a/lib/MC/MCSymbol.cpp b/lib/MC/MCSymbol.cpp
index 82d72a3e95..07751f7298 100644
--- a/lib/MC/MCSymbol.cpp
+++ b/lib/MC/MCSymbol.cpp
@@ -44,6 +44,10 @@ void MCSymbol::setVariableValue(const MCExpr *Value) {
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 {
diff --git a/lib/MC/MachObjectWriter.cpp b/lib/MC/MachObjectWriter.cpp
index f4aef96e30..bb8eb10a48 100644
--- a/lib/MC/MachObjectWriter.cpp
+++ b/lib/MC/MachObjectWriter.cpp
@@ -404,7 +404,7 @@ public:
// 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 @@ public:
// 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))
diff --git a/test/MC/MachO/reloc.s b/test/MC/MachO/reloc.s
index c305eeb723..73a69c3cc5 100644
--- a/test/MC/MachO/reloc.s
+++ b/test/MC/MachO/reloc.s
@@ -41,6 +41,9 @@ L1:
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 @@ L1:
// 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 @@ L1:
// 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 @@ L1:
// 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 @@ L1:
// 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 @@ L1:
// 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 @@ L1:
// 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 @@ L1:
// 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 @@ L1:
// 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 @@ L1:
// 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 @@ L1:
// 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)