memcheck/tests/sh-mem-random.c: Set huge_addr to 240GB
[valgrind.git] / memcheck / tests / amd64-linux / access_below_sp.c
blobb6d0d2973230963056c9ff6654a9e6034c359076
2 #include <stdio.h>
5 #define COMPILER_BARRIER __asm__ __volatile("":::"cc","memory")
7 /* force the kernel to map in 15k below SP, so we can safely poke
8 around there. */
9 __attribute__((noinline)) void make_below_sp_safe ( void )
11 const int N = 15000;
12 unsigned char a[N];
13 int i;
15 for (i = 0; i < N; i++) {
16 a[i] = i & 0xFF;
19 COMPILER_BARRIER;
21 unsigned int r = 0;
22 for (i = 0; i < N; i++) {
23 r = (r << 1) | (r >> 31);
24 r ^= (unsigned int)a[i];
26 fprintf(stderr, "Checksum: %08x\n", r);
30 int main ( void )
32 make_below_sp_safe();
34 unsigned int res;
35 __asm__ __volatile__("movl -8192(%%rsp), %0"
36 : "=r"(res) : : "memory","cc");
37 fprintf(stderr, "Got %08x\n", res);
38 return 0;