diff options
-rw-r--r-- | lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp | 4 | ||||
-rw-r--r-- | lib/Analysis/NaCl/PNaClABIVerifyModule.cpp | 5 | ||||
-rw-r--r-- | test/NaCl/PNaClABI/instructions.ll | 7 | ||||
-rw-r--r-- | test/NaCl/PNaClABI/module-asm.ll | 4 |
4 files changed, 20 insertions, 0 deletions
diff --git a/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp b/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp index 2c9a6a17b9..2082c85d01 100644 --- a/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp +++ b/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp @@ -161,6 +161,10 @@ bool PNaClABIVerifyFunctions::runOnFunction(Function &F) { case Instruction::Select: break; case Instruction::Call: + if (cast<CallInst>(BBI)->isInlineAsm()) { + Reporter->addError() << "Function " << F.getName() << + " contains disallowed inline assembly\n"; + } // Pointers to varargs function types are not yet // disallowed, but we do disallow defining or calling // functions of varargs types. diff --git a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp index eacb4031b3..2b29c196f1 100644 --- a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp +++ b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp @@ -242,6 +242,11 @@ bool PNaClABIVerifyModule::isWhitelistedMetadata(const NamedMDNode *MD) { } bool PNaClABIVerifyModule::runOnModule(Module &M) { + if (!M.getModuleInlineAsm().empty()) { + Reporter->addError() << + "Module contains disallowed top-level inline assembly\n"; + } + for (Module::const_global_iterator MI = M.global_begin(), ME = M.global_end(); MI != ME; ++MI) { // Check types of global variables and their initializers diff --git a/test/NaCl/PNaClABI/instructions.ll b/test/NaCl/PNaClABI/instructions.ll index 765bae6d6f..72134e76c5 100644 --- a/test/NaCl/PNaClABI/instructions.ll +++ b/test/NaCl/PNaClABI/instructions.ll @@ -142,5 +142,12 @@ define i32* @constantexpr() { ; CHECK-NOT: disallowed ; CHECK: Function constantexpr contains disallowed ConstantExpr +define void @inline_asm() { + call void asm "foo", ""() + ret void +} +; CHECK-NOT: disallowed +; CHECK: Function inline_asm contains disallowed inline assembly + ; CHECK-NOT: disallowed ; If another check is added, there should be a check-not in between each check diff --git a/test/NaCl/PNaClABI/module-asm.ll b/test/NaCl/PNaClABI/module-asm.ll new file mode 100644 index 0000000000..aab7c709e8 --- /dev/null +++ b/test/NaCl/PNaClABI/module-asm.ll @@ -0,0 +1,4 @@ +; RUN: pnacl-abicheck < %s | FileCheck %s + +module asm "foo" +; CHECK: Module contains disallowed top-level inline assembly |