aboutsummaryrefslogtreecommitdiff
path: root/lib/asan/lit_tests/TestCases/Linux/zero-base-shadow64.cc
blob: 1db725c95752a45ed76306f6168e291faf488bd6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// RUN: %clangxx_asan -O0 -fsanitize-address-zero-base-shadow -fPIE -pie %s -o %t
// RUN: not %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O1 -fsanitize-address-zero-base-shadow -fPIE -pie %s -o %t
// RUN: not %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O2 -fsanitize-address-zero-base-shadow -fPIE -pie %s -o %t
// RUN: not %t 2>&1 | FileCheck %s

// Zero-base shadow only works on x86_64 and i386.
// REQUIRES: x86_64-supported-target, asan-64-bits

#include <string.h>
int main(int argc, char **argv) {
  char x[10];
  memset(x, 0, 10);
  int res = x[argc * 10];  // BOOOM
  // CHECK: {{READ of size 1 at 0x.* thread T0}}
  // CHECK: {{    #0 0x.* in main .*zero-base-shadow64.cc:}}[[@LINE-2]]
  // CHECK: {{Address 0x.* is .* frame}}
  // CHECK: main

  // Check that shadow for stack memory occupies lower part of address space.
  // CHECK: =>0x0f
  return res;
}