aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp2
-rw-r--r--lib/Analysis/NaCl/PNaClABIVerifyModule.cpp4
-rw-r--r--test/NaCl/PNaClABI/abi-addrspace.ll16
3 files changed, 22 insertions, 0 deletions
diff --git a/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp b/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp
index edb0e5fad2..43eef2f6c0 100644
--- a/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp
+++ b/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp
@@ -82,6 +82,8 @@ bool PNaClABIVerifyFunctions::IsWhitelistedMetadata(unsigned MDKind) {
// * a function pointer (with valid argument and return types).
static bool isValidPointerType(Type *Ty) {
if (PointerType *PtrTy = dyn_cast<PointerType>(Ty)) {
+ if (PtrTy->getAddressSpace() != 0)
+ return false;
if (PNaClABITypeChecker::isValidScalarType(PtrTy->getElementType()))
return true;
if (FunctionType *FTy = dyn_cast<FunctionType>(PtrTy->getElementType()))
diff --git a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp
index cbe7eb833f..364614f9a2 100644
--- a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp
+++ b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp
@@ -121,6 +121,10 @@ void PNaClABIVerifyModule::checkGlobalValueCommon(const GlobalValue *GV) {
Reporter->addError() << GVTypeName << GV->getName() <<
" has disallowed \"section\" attribute\n";
}
+ if (GV->getType()->getAddressSpace() != 0) {
+ Reporter->addError() << GVTypeName << GV->getName()
+ << " has addrspace attribute (disallowed)\n";
+ }
}
static bool TypeAcceptable(const Type *T,
diff --git a/test/NaCl/PNaClABI/abi-addrspace.ll b/test/NaCl/PNaClABI/abi-addrspace.ll
new file mode 100644
index 0000000000..e574a726e4
--- /dev/null
+++ b/test/NaCl/PNaClABI/abi-addrspace.ll
@@ -0,0 +1,16 @@
+; RUN: pnacl-abicheck < %s | FileCheck %s
+
+; This test checks that the "addrspace" pointer attribute is rejected
+; by the PNaCl ABI verifier. The only allowed address space value is
+; 0 (the default).
+
+@var = addrspace(1) global [4 x i8] c"xxxx"
+; CHECK: Variable var has addrspace attribute (disallowed)
+
+define void @func() {
+ inttoptr i32 0 to i32 addrspace(2)*
+; CHECK: disallowed: bad result type: {{.*}} inttoptr {{.*}} addrspace
+ ret void
+}
+
+; CHECK-NOT: disallowed