[llvm-commits] [llvm] r163854 - in /llvm/trunk: lib/MC/MCELFStreamer.cpp lib/MC/MCParser/AsmParser.cpp test/MC/MachO/absolute.s
Jim Grosbach
grosbach at apple.com
Thu Sep 13 16:11:31 PDT 2012
Author: grosbach
Date: Thu Sep 13 18:11:31 2012
New Revision: 163854
URL: http://llvm.org/viewvc/llvm-project?rev=163854&view=rev
Log:
Assembler: Darwin variables defined via .set are no-dead-strip.
For gas compatibility.
rdar://12219394
Added:
llvm/trunk/test/MC/MachO/absolute.s
Modified:
llvm/trunk/lib/MC/MCELFStreamer.cpp
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
Modified: llvm/trunk/lib/MC/MCELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCELFStreamer.cpp?rev=163854&r1=163853&r2=163854&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCELFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCELFStreamer.cpp Thu Sep 13 18:11:31 2012
@@ -247,7 +247,6 @@
switch (Attribute) {
case MCSA_LazyReference:
case MCSA_Reference:
- case MCSA_NoDeadStrip:
case MCSA_SymbolResolver:
case MCSA_PrivateExtern:
case MCSA_WeakDefinition:
@@ -256,6 +255,7 @@
case MCSA_IndirectSymbol:
llvm_unreachable("Invalid symbol attribute for ELF!");
+ case MCSA_NoDeadStrip:
case MCSA_ELF_TypeGnuUniqueObject:
// Ignore for now.
break;
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=163854&r1=163853&r2=163854&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Thu Sep 13 18:11:31 2012
@@ -221,7 +221,8 @@
/// return the contents from the current token up to the end or comma.
StringRef ParseStringToComma();
- bool ParseAssignment(StringRef Name, bool allow_redef);
+ bool ParseAssignment(StringRef Name, bool allow_redef,
+ bool NoDeadStrip = false);
bool ParsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc);
bool ParseBinOpRHS(unsigned Precedence, const MCExpr *&Res, SMLoc &EndLoc);
@@ -1697,7 +1698,8 @@
llvm_unreachable("Unknown expr kind!");
}
-bool AsmParser::ParseAssignment(StringRef Name, bool allow_redef) {
+bool AsmParser::ParseAssignment(StringRef Name, bool allow_redef,
+ bool NoDeadStrip) {
// FIXME: Use better location, we should use proper tokens.
SMLoc EqualLoc = Lexer.getLoc();
@@ -1752,6 +1754,9 @@
// Do the assignment.
Out.EmitAssignment(Sym, Value);
+ if (NoDeadStrip)
+ Out.EmitSymbolAttribute(Sym, MCSA_NoDeadStrip);
+
return false;
}
@@ -1809,7 +1814,7 @@
return TokError("unexpected token in '" + Twine(IDVal) + "'");
Lex();
- return ParseAssignment(Name, allow_redef);
+ return ParseAssignment(Name, allow_redef, true);
}
bool AsmParser::ParseEscapedString(std::string &Data) {
Added: llvm/trunk/test/MC/MachO/absolute.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/absolute.s?rev=163854&view=auto
==============================================================================
--- llvm/trunk/test/MC/MachO/absolute.s (added)
+++ llvm/trunk/test/MC/MachO/absolute.s Thu Sep 13 18:11:31 2012
@@ -0,0 +1,158 @@
+// RUN: llvm-mc -triple x86_64-apple-darwin10 %s -filetype=obj -o - | macho-dump | FileCheck %s
+
+_bar:
+ nop
+_foo:
+ nop
+
+ .set foo_set1, (_foo + 0xffff0000)
+ .set foo_set2, (_foo - _bar + 0xffff0000)
+
+foo_equals = (_foo + 0xffff0000)
+foo_equals2 = (_foo - _bar + 0xffff0000)
+
+ .globl foo_set1_global;
+ .set foo_set1_global, (_foo + 0xffff0000)
+
+ .globl foo_set2_global;
+ .set foo_set2_global, (_foo - _bar + 0xffff0000)
+
+// CHECK: ('cputype', 16777223)
+// CHECK: ('cpusubtype', 3)
+// CHECK: ('filetype', 1)
+// CHECK: ('num_load_commands', 3)
+// CHECK: ('load_commands_size', 256)
+// CHECK: ('flag', 0)
+// CHECK: ('reserved', 0)
+// CHECK: ('load_commands', [
+// CHECK: # Load Command 0
+// CHECK: (('command', 25)
+// CHECK: ('size', 152)
+// CHECK: ('segment_name', '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
+// CHECK: ('vm_addr', 0)
+// CHECK: ('vm_size', 2)
+// CHECK: ('file_offset', 288)
+// CHECK: ('file_size', 2)
+// CHECK: ('maxprot', 7)
+// CHECK: ('initprot', 7)
+// CHECK: ('num_sections', 1)
+// CHECK: ('flags', 0)
+// CHECK: ('sections', [
+// CHECK: # Section 0
+// CHECK: (('section_name', '__text\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
+// CHECK: ('segment_name', '__TEXT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
+// CHECK: ('address', 0)
+// CHECK: ('size', 2)
+// CHECK: ('offset', 288)
+// CHECK: ('alignment', 0)
+// CHECK: ('reloc_offset', 0)
+// CHECK: ('num_reloc', 0)
+// CHECK: ('flags', 0x80000400)
+// CHECK: ('reserved1', 0)
+// CHECK: ('reserved2', 0)
+// CHECK: ('reserved3', 0)
+// CHECK: ),
+// CHECK: ('_relocations', [
+// CHECK: ])
+// CHECK: ])
+// CHECK: ),
+// CHECK: # Load Command 1
+// CHECK: (('command', 2)
+// CHECK: ('size', 24)
+// CHECK: ('symoff', 292)
+// CHECK: ('nsyms', 8)
+// CHECK: ('stroff', 420)
+// CHECK: ('strsize', 84)
+// CHECK: ('_string_data', '\x00foo_set1_global\x00foo_set2_global\x00_bar\x00_foo\x00foo_set1\x00foo_set2\x00foo_equals\x00foo_equals2\x00')
+// CHECK: ('_symbols', [
+// CHECK: # Symbol 0
+// CHECK: (('n_strx', 33)
+// CHECK: ('n_type', 0xe)
+// CHECK: ('n_sect', 1)
+// CHECK: ('n_desc', 0)
+// CHECK: ('n_value', 0)
+// CHECK: ('_string', '_bar')
+// CHECK: ),
+// CHECK: # Symbol 1
+// CHECK: (('n_strx', 38)
+// CHECK: ('n_type', 0xe)
+// CHECK: ('n_sect', 1)
+// CHECK: ('n_desc', 0)
+// CHECK: ('n_value', 1)
+// CHECK: ('_string', '_foo')
+// CHECK: ),
+// CHECK: # Symbol 2
+// CHECK: (('n_strx', 43)
+// CHECK: ('n_type', 0xe)
+// CHECK: ('n_sect', 1)
+// CHECK: ('n_desc', 32)
+// CHECK: ('n_value', 4294901761)
+// CHECK: ('_string', 'foo_set1')
+// CHECK: ),
+// CHECK: # Symbol 3
+// CHECK: (('n_strx', 52)
+// CHECK: ('n_type', 0x2)
+// CHECK: ('n_sect', 0)
+// CHECK: ('n_desc', 32)
+// CHECK: ('n_value', 4294901761)
+// CHECK: ('_string', 'foo_set2')
+// CHECK: ),
+// CHECK: # Symbol 4
+// CHECK: (('n_strx', 61)
+// CHECK: ('n_type', 0xe)
+// CHECK: ('n_sect', 1)
+// CHECK: ('n_desc', 0)
+// CHECK: ('n_value', 4294901761)
+// CHECK: ('_string', 'foo_equals')
+// CHECK: ),
+// CHECK: # Symbol 5
+// CHECK: (('n_strx', 72)
+// CHECK: ('n_type', 0x2)
+// CHECK: ('n_sect', 0)
+// CHECK: ('n_desc', 0)
+// CHECK: ('n_value', 4294901761)
+// CHECK: ('_string', 'foo_equals2')
+// CHECK: ),
+// CHECK: # Symbol 6
+// CHECK: (('n_strx', 1)
+// CHECK: ('n_type', 0xf)
+// CHECK: ('n_sect', 1)
+// CHECK: ('n_desc', 32)
+// CHECK: ('n_value', 4294901761)
+// CHECK: ('_string', 'foo_set1_global')
+// CHECK: ),
+// CHECK: # Symbol 7
+// CHECK: (('n_strx', 17)
+// CHECK: ('n_type', 0x3)
+// CHECK: ('n_sect', 0)
+// CHECK: ('n_desc', 32)
+// CHECK: ('n_value', 4294901761)
+// CHECK: ('_string', 'foo_set2_global')
+// CHECK: ),
+// CHECK: ])
+// CHECK: ),
+// CHECK: # Load Command 2
+// CHECK: (('command', 11)
+// CHECK: ('size', 80)
+// CHECK: ('ilocalsym', 0)
+// CHECK: ('nlocalsym', 6)
+// CHECK: ('iextdefsym', 6)
+// CHECK: ('nextdefsym', 2)
+// CHECK: ('iundefsym', 8)
+// CHECK: ('nundefsym', 0)
+// CHECK: ('tocoff', 0)
+// CHECK: ('ntoc', 0)
+// CHECK: ('modtaboff', 0)
+// CHECK: ('nmodtab', 0)
+// CHECK: ('extrefsymoff', 0)
+// CHECK: ('nextrefsyms', 0)
+// CHECK: ('indirectsymoff', 0)
+// CHECK: ('nindirectsyms', 0)
+// CHECK: ('extreloff', 0)
+// CHECK: ('nextrel', 0)
+// CHECK: ('locreloff', 0)
+// CHECK: ('nlocrel', 0)
+// CHECK: ('_indirect_symbols', [
+// CHECK: ])
+// CHECK: ),
+// CHECK: ])
More information about the llvm-commits
mailing list