mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
Fix crashes when assembler directives are used that are not
for Mach-O object files by generating an error instead. rdar://16335232 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204687 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
66124f9e89
commit
4a88cd08da
@ -8297,6 +8297,14 @@ bool ARMAsmParser::parseDirectiveUnreq(SMLoc L) {
|
||||
/// parseDirectiveArch
|
||||
/// ::= .arch token
|
||||
bool ARMAsmParser::parseDirectiveArch(SMLoc L) {
|
||||
const MCAsmInfo *MAI = getParser().getStreamer().getContext().getAsmInfo();
|
||||
bool isMachO = MAI->hasSubsectionsViaSymbols();
|
||||
if (isMachO) {
|
||||
Error(L, ".arch directive not valid for Mach-O");
|
||||
Parser.eatToEndOfStatement();
|
||||
return false;
|
||||
}
|
||||
|
||||
StringRef Arch = getParser().parseStringToEndOfStatement().trim();
|
||||
|
||||
unsigned ID = StringSwitch<unsigned>(Arch)
|
||||
@ -8320,9 +8328,16 @@ bool ARMAsmParser::parseDirectiveArch(SMLoc L) {
|
||||
/// ::= .eabi_attribute int, int [, "str"]
|
||||
/// ::= .eabi_attribute Tag_name, int [, "str"]
|
||||
bool ARMAsmParser::parseDirectiveEabiAttr(SMLoc L) {
|
||||
const MCAsmInfo *MAI = getParser().getStreamer().getContext().getAsmInfo();
|
||||
bool isMachO = MAI->hasSubsectionsViaSymbols();
|
||||
if (isMachO) {
|
||||
Error(L, ".eabi_attribute directive not valid for Mach-O");
|
||||
Parser.eatToEndOfStatement();
|
||||
return false;
|
||||
}
|
||||
|
||||
int64_t Tag;
|
||||
SMLoc TagLoc;
|
||||
|
||||
TagLoc = Parser.getTok().getLoc();
|
||||
if (Parser.getTok().is(AsmToken::Identifier)) {
|
||||
StringRef Name = Parser.getTok().getIdentifier();
|
||||
@ -8426,6 +8441,14 @@ bool ARMAsmParser::parseDirectiveEabiAttr(SMLoc L) {
|
||||
/// parseDirectiveCPU
|
||||
/// ::= .cpu str
|
||||
bool ARMAsmParser::parseDirectiveCPU(SMLoc L) {
|
||||
const MCAsmInfo *MAI = getParser().getStreamer().getContext().getAsmInfo();
|
||||
bool isMachO = MAI->hasSubsectionsViaSymbols();
|
||||
if (isMachO) {
|
||||
Error(L, ".cpu directive not valid for Mach-O");
|
||||
Parser.eatToEndOfStatement();
|
||||
return false;
|
||||
}
|
||||
|
||||
StringRef CPU = getParser().parseStringToEndOfStatement().trim();
|
||||
getTargetStreamer().emitTextAttribute(ARMBuildAttrs::CPU_name, CPU);
|
||||
return false;
|
||||
@ -8434,6 +8457,14 @@ bool ARMAsmParser::parseDirectiveCPU(SMLoc L) {
|
||||
/// parseDirectiveFPU
|
||||
/// ::= .fpu str
|
||||
bool ARMAsmParser::parseDirectiveFPU(SMLoc L) {
|
||||
const MCAsmInfo *MAI = getParser().getStreamer().getContext().getAsmInfo();
|
||||
bool isMachO = MAI->hasSubsectionsViaSymbols();
|
||||
if (isMachO) {
|
||||
Error(L, ".fpu directive not valid for Mach-O");
|
||||
Parser.eatToEndOfStatement();
|
||||
return false;
|
||||
}
|
||||
|
||||
StringRef FPU = getParser().parseStringToEndOfStatement().trim();
|
||||
|
||||
unsigned ID = StringSwitch<unsigned>(FPU)
|
||||
@ -8453,6 +8484,14 @@ bool ARMAsmParser::parseDirectiveFPU(SMLoc L) {
|
||||
/// parseDirectiveFnStart
|
||||
/// ::= .fnstart
|
||||
bool ARMAsmParser::parseDirectiveFnStart(SMLoc L) {
|
||||
const MCAsmInfo *MAI = getParser().getStreamer().getContext().getAsmInfo();
|
||||
bool isMachO = MAI->hasSubsectionsViaSymbols();
|
||||
if (isMachO) {
|
||||
Error(L, ".fnstart directive not valid for Mach-O");
|
||||
Parser.eatToEndOfStatement();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (UC.hasFnStart()) {
|
||||
Error(L, ".fnstart starts before the end of previous one");
|
||||
UC.emitFnStartLocNotes();
|
||||
@ -8732,6 +8771,14 @@ bool ARMAsmParser::parseDirectiveRegSave(SMLoc L, bool IsVector) {
|
||||
/// ::= .inst.n opcode [, ...]
|
||||
/// ::= .inst.w opcode [, ...]
|
||||
bool ARMAsmParser::parseDirectiveInst(SMLoc Loc, char Suffix) {
|
||||
const MCAsmInfo *MAI = getParser().getStreamer().getContext().getAsmInfo();
|
||||
bool isMachO = MAI->hasSubsectionsViaSymbols();
|
||||
if (isMachO) {
|
||||
Error(Loc, ".inst directive not valid for Mach-O");
|
||||
Parser.eatToEndOfStatement();
|
||||
return false;
|
||||
}
|
||||
|
||||
int Width;
|
||||
|
||||
if (isThumb()) {
|
||||
@ -8980,6 +9027,14 @@ bool ARMAsmParser::parseDirectiveUnwindRaw(SMLoc L) {
|
||||
/// parseDirectiveTLSDescSeq
|
||||
/// ::= .tlsdescseq tls-variable
|
||||
bool ARMAsmParser::parseDirectiveTLSDescSeq(SMLoc L) {
|
||||
const MCAsmInfo *MAI = getParser().getStreamer().getContext().getAsmInfo();
|
||||
bool isMachO = MAI->hasSubsectionsViaSymbols();
|
||||
if (isMachO) {
|
||||
Error(L, ".tlsdescseq directive not valid for Mach-O");
|
||||
Parser.eatToEndOfStatement();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getLexer().isNot(AsmToken::Identifier)) {
|
||||
TokError("expected variable after '.tlsdescseq' directive");
|
||||
Parser.eatToEndOfStatement();
|
||||
@ -9067,6 +9122,14 @@ bool ARMAsmParser::parseDirectiveMovSP(SMLoc L) {
|
||||
/// parseDirectiveObjectArch
|
||||
/// ::= .object_arch name
|
||||
bool ARMAsmParser::parseDirectiveObjectArch(SMLoc L) {
|
||||
const MCAsmInfo *MAI = getParser().getStreamer().getContext().getAsmInfo();
|
||||
bool isMachO = MAI->hasSubsectionsViaSymbols();
|
||||
if (isMachO) {
|
||||
Error(L, ".object_arch directive not valid for Mach-O");
|
||||
Parser.eatToEndOfStatement();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getLexer().isNot(AsmToken::Identifier)) {
|
||||
Error(getLexer().getLoc(), "unexpected token");
|
||||
Parser.eatToEndOfStatement();
|
||||
|
24
test/MC/MachO/ARM/bad-darwin-directives.s
Normal file
24
test/MC/MachO/ARM/bad-darwin-directives.s
Normal file
@ -0,0 +1,24 @@
|
||||
@ RUN: not llvm-mc -n -triple armv7-apple-darwin10 %s -filetype=obj -o - 2> %t.err > %t
|
||||
@ RUN: FileCheck --check-prefix=CHECK-ERROR < %t.err %s
|
||||
@ rdar://16335232
|
||||
|
||||
.eabi_attribute 8, 1
|
||||
@ CHECK-ERROR: error: .eabi_attribute directive not valid for Mach-O
|
||||
|
||||
.cpu
|
||||
@ CHECK-ERROR: error: .cpu directive not valid for Mach-O
|
||||
|
||||
.fpu neon
|
||||
@ CHECK-ERROR: error: .fpu directive not valid for Mach-O
|
||||
|
||||
.arch armv7
|
||||
@ CHECK-ERROR: error: .arch directive not valid for Mach-O
|
||||
|
||||
.fnstart
|
||||
@ CHECK-ERROR: error: .fnstart directive not valid for Mach-O
|
||||
|
||||
.tlsdescseq
|
||||
@ CHECK-ERROR: error: .tlsdescseq directive not valid for Mach-O
|
||||
|
||||
.object_arch armv7
|
||||
@ CHECK-ERROR: error: .object_arch directive not valid for Mach-O
|
Loading…
Reference in New Issue
Block a user