diff options
author | Mark Seaborn <mseaborn@chromium.org> | 2013-04-10 09:37:34 -0700 |
---|---|---|
committer | Mark Seaborn <mseaborn@chromium.org> | 2013-04-10 09:37:34 -0700 |
commit | 76cd6aea1dd6e7a446f1e21ac05bc822a50d48ac (patch) | |
tree | 6c471fcadfa73d4b4a4ef463200bf1d186d1adb4 | |
parent | 7ff3c9d24918270e4a001c712e2e153d7e27da5e (diff) |
PNaCl ABI checker: Disallow "section", "thread_local" and "gc" attributes
* Disallow "section" on functions and global variables.
* Disallow "thread_local" on global variables.
* Disallow "gc" on functions.
BUG= https://code.google.com/p/nativeclient/issues/detail?id=2837
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3126
TEST=test/NaCl/PNaClABI/global-attributes.ll + PNaCl toolchain trybots
Review URL: https://codereview.chromium.org/14063007
-rw-r--r-- | lib/Analysis/NaCl/PNaClABIVerifyModule.cpp | 18 | ||||
-rw-r--r-- | test/NaCl/PNaClABI/global-attributes.ll | 38 |
2 files changed, 56 insertions, 0 deletions
diff --git a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp index 23699860b0..d98868f53c 100644 --- a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp +++ b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp @@ -112,6 +112,15 @@ bool PNaClABIVerifyModule::runOnModule(Module &M) { " has disallowed linkage type: " << linkageName(MI->getLinkage()) << "\n"; } + + if (MI->hasSection()) { + Reporter->addError() << "Variable " << MI->getName() << + " has disallowed \"section\" attribute\n"; + } + if (MI->isThreadLocal()) { + Reporter->addError() << "Variable " << MI->getName() << + " has disallowed \"thread_local\" attribute\n"; + } } // No aliases allowed for now. for (Module::alias_iterator MI = M.alias_begin(), @@ -136,6 +145,15 @@ bool PNaClABIVerifyModule::runOnModule(Module &M) { PNaClABITypeChecker::getTypeName(PT) << "\n"; } } + + if (MI->hasSection()) { + Reporter->addError() << "Function " << MI->getName() << + " has disallowed \"section\" attribute\n"; + } + if (MI->hasGC()) { + Reporter->addError() << "Function " << MI->getName() << + " has disallowed \"gc\" attribute\n"; + } } // Check named metadata nodes diff --git a/test/NaCl/PNaClABI/global-attributes.ll b/test/NaCl/PNaClABI/global-attributes.ll new file mode 100644 index 0000000000..255e1f8a02 --- /dev/null +++ b/test/NaCl/PNaClABI/global-attributes.ll @@ -0,0 +1,38 @@ +; RUN: pnacl-abicheck < %s | FileCheck %s + +; Global variable attributes + +; CHECK: Variable var_with_section has disallowed "section" attribute +@var_with_section = global i32 99, section ".some_section" + +; PNaCl programs can depend on data alignments in general, so we allow +; "align" on global variables. +; CHECK-NOT: var_with_alignment +@var_with_alignment = global i32 99, align 8 + +; TLS variables must be expanded out by ExpandTls. +; CHECK-NEXT: Variable tls_var has disallowed "thread_local" attribute +@tls_var = thread_local global i32 99 + + +; Function attributes + +; CHECK-NEXT: Function func_with_section has disallowed "section" attribute +define void @func_with_section() section ".some_section" { + ret void +} + +; TODO(mseaborn): PNaCl programs don't know what alignment is +; reasonable for a function, so we should disallow this. +; CHECK-NOT: func_with_alignment +define void @func_with_alignment() align 1 { + ret void +} + +; CHECK-NEXT: Function func_with_gc has disallowed "gc" attribute +define void @func_with_gc() gc "my_gc_func" { + ret void +} + +; CHECK-NOT: disallowed +; If another check is added, there should be a check-not in between each check |