1 //===-- main.cpp ------------------------------------------------*- C++ -*-===//
3 //// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 //// See https://llvm.org/LICENSE.txt for license information.
5 //// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 ////===----------------------------------------------------------------------===//
11 #include <sys/prctl.h>
13 static void violate_upper_bound(int *ptr, int size)
19 static void violate_lower_bound (int *ptr, int size)
26 main(int argc, char const *argv[])
28 unsigned int rax, rbx, rcx, rdx;
31 // PR_MPX_ENABLE_MANAGEMENT won't be defined on linux kernel versions below 3.19
32 #ifndef PR_MPX_ENABLE_MANAGEMENT
36 // This call returns 0 only if the CPU and the kernel support Intel(R) MPX.
37 if (prctl(PR_MPX_ENABLE_MANAGEMENT, 0, 0, 0, 0) != 0)
40 violate_upper_bound(array, 5);
41 violate_lower_bound(array, 5);