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
This commit is contained in:
Daniel Dunbar 2010-05-05 19:01:05 +00:00
parent c304718fd8
commit 2d7fd61e94
5 changed files with 32 additions and 19 deletions

View File

@ -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);
}

View File

@ -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));
}

View File

@ -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 {

View File

@ -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))

View File

@ -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)