diff options
author | Mark Seaborn <mseaborn@chromium.org> | 2013-05-28 11:49:59 -0700 |
---|---|---|
committer | Mark Seaborn <mseaborn@chromium.org> | 2013-05-28 11:49:59 -0700 |
commit | 7b1d0b48c95f7b9861b890c650f039d5cc636e89 (patch) | |
tree | 124702ea552a93292a8e43ace8364a77a4886e51 | |
parent | ffc13bcb40d4257202295fc0ffe25b38bdf64263 (diff) |
PNaCl ABI checker: Disallow inline assembly
Reject module-level assembly and inline assembly within functions.
BUG=https://code.google.com/p/nativeclient/issues/detail?id=2345
TEST=*.ll tests + trybots + GCC torture tests
Review URL: https://codereview.chromium.org/16123005
-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 |