[Object] Make .alt_entry directive parsing MachO specific.

ELF and COFF will now treat .alt_entry like any other unrecognized directive.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265975 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Lang Hames 2016-04-11 18:33:45 +00:00
parent 5362126448
commit 90ae214a17
4 changed files with 25 additions and 6 deletions

View File

@ -285,7 +285,7 @@ bool MCELFStreamer::EmitSymbolAttribute(MCSymbol *S, MCSymbolAttr Attribute) {
break;
case MCSA_AltEntry:
report_fatal_error("ELF doesn't support the .alt_entry attribute");
llvm_unreachable("ELF doesn't support the .alt_entry attribute");
}
return true;

View File

@ -350,7 +350,7 @@ private:
DK_BALIGNL, DK_P2ALIGN, DK_P2ALIGNW, DK_P2ALIGNL, DK_ORG, DK_FILL, DK_ENDR,
DK_BUNDLE_ALIGN_MODE, DK_BUNDLE_LOCK, DK_BUNDLE_UNLOCK,
DK_ZERO, DK_EXTERN, DK_GLOBL, DK_GLOBAL,
DK_LAZY_REFERENCE, DK_NO_DEAD_STRIP, DK_SYMBOL_RESOLVER, DK_ALT_ENTRY,
DK_LAZY_REFERENCE, DK_NO_DEAD_STRIP, DK_SYMBOL_RESOLVER,
DK_PRIVATE_EXTERN, DK_REFERENCE, DK_WEAK_DEFINITION, DK_WEAK_REFERENCE,
DK_WEAK_DEF_CAN_BE_HIDDEN, DK_COMM, DK_COMMON, DK_LCOMM, DK_ABORT,
DK_INCLUDE, DK_INCBIN, DK_CODE16, DK_CODE16GCC, DK_REPT, DK_IRP, DK_IRPC,
@ -1598,8 +1598,6 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info,
return parseDirectiveSymbolAttribute(MCSA_NoDeadStrip);
case DK_SYMBOL_RESOLVER:
return parseDirectiveSymbolAttribute(MCSA_SymbolResolver);
case DK_ALT_ENTRY:
return parseDirectiveSymbolAttribute(MCSA_AltEntry);
case DK_PRIVATE_EXTERN:
return parseDirectiveSymbolAttribute(MCSA_PrivateExtern);
case DK_REFERENCE:
@ -4627,7 +4625,6 @@ void AsmParser::initializeDirectiveKindMap() {
DirectiveKindMap[".lazy_reference"] = DK_LAZY_REFERENCE;
DirectiveKindMap[".no_dead_strip"] = DK_NO_DEAD_STRIP;
DirectiveKindMap[".symbol_resolver"] = DK_SYMBOL_RESOLVER;
DirectiveKindMap[".alt_entry"] = DK_ALT_ENTRY;
DirectiveKindMap[".private_extern"] = DK_PRIVATE_EXTERN;
DirectiveKindMap[".reference"] = DK_REFERENCE;
DirectiveKindMap[".weak_definition"] = DK_WEAK_DEFINITION;

View File

@ -50,6 +50,7 @@ public:
// Call the base implementation.
this->MCAsmParserExtension::Initialize(Parser);
addDirectiveHandler<&DarwinAsmParser::parseDirectiveAltEntry>(".alt_entry");
addDirectiveHandler<&DarwinAsmParser::parseDirectiveDesc>(".desc");
addDirectiveHandler<&DarwinAsmParser::parseDirectiveIndirectSymbol>(
".indirect_symbol");
@ -179,6 +180,7 @@ public:
LastVersionMinDirective = SMLoc();
}
bool parseDirectiveAltEntry(StringRef, SMLoc);
bool parseDirectiveDesc(StringRef, SMLoc);
bool parseDirectiveIndirectSymbol(StringRef, SMLoc);
bool parseDirectiveDumpOrLoad(StringRef, SMLoc);
@ -408,6 +410,26 @@ bool DarwinAsmParser::parseSectionSwitch(const char *Segment,
return false;
}
/// parseDirectiveAltEntry
/// ::= .alt_entry identifier
bool DarwinAsmParser::parseDirectiveAltEntry(StringRef, SMLoc) {
StringRef Name;
if (getParser().parseIdentifier(Name))
return TokError("expected identifier in directive");
// Look up symbol.
MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
if (Sym->isDefined())
return TokError(".alt_entry must preceed symbol definition");
if (!getStreamer().EmitSymbolAttribute(Sym, MCSA_AltEntry))
return TokError("unable to emit symbol attribute");
Lex();
return false;
}
/// parseDirectiveDesc
/// ::= .desc identifier , expression
bool DarwinAsmParser::parseDirectiveDesc(StringRef, SMLoc) {

View File

@ -108,7 +108,7 @@ bool MCWinCOFFStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
Symbol->setExternal(true);
break;
case MCSA_AltEntry:
report_fatal_error("COFF doesn't support the .alt_entry attribute");
llvm_unreachable("COFF doesn't support the .alt_entry attribute");
}
return true;