brintos

brintos / llvm-project-archived public Read only

0
0
Text · 767 B · e11bd62 Raw
31 lines · cpp
1// Test that non-sanitized executables work with sanitized shared libs2// and preloaded runtime.3//4// RUN: %clangxx -DBUILD_SO=1 -fPIC -shared %s -o %t.so5// RUN: %clangxx %s %t.so -o %t6//7// RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %t.so8// RUN: env LD_PRELOAD=%shared_libasan not %run %t 2>&1 | FileCheck %s9 10// REQUIRES: asan-dynamic-runtime11 12// This way of setting LD_PRELOAD does not work with Android test runner.13// REQUIRES: !android14 15#if BUILD_SO16char dummy;17void do_access(const void *p) {18  // CHECK: AddressSanitizer: heap-buffer-overflow19  dummy = ((const char *)p)[1];20}21#else22#include <stdlib.h>23extern void do_access(const void *p);24int main(int argc, char **argv) {25  void *p = malloc(1);26  do_access(p);27  free(p);28  return 0;29}30#endif31