brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.4 KiB · aa0b351 Raw
101 lines · cpp
1// RUN: %clangxx_asan -arch x86_64 -arch x86_64h -g -O0 %s -c -o %t.o.fat2// RUN: %clangxx_asan -arch x86_64 -arch x86_64h -g %t.o.fat -o %t.fat3 4// RUN: lipo %t.fat -thin    x86_64  -output %t.thin.x86_64  && lipo %t.thin.x86_64  -info | FileCheck %s --check-prefix=CHECK-LIPO-THIN-X86_645// RUN: lipo %t.fat -thin    x86_64h -output %t.thin.x86_64h && lipo %t.thin.x86_64h -info | FileCheck %s --check-prefix=CHECK-LIPO-THIN-X86_64H6// RUN: lipo %t.fat -extract x86_64  -output %t.fat.x86_64   && lipo %t.fat.x86_64   -info | FileCheck %s --check-prefix=CHECK-LIPO-FAT-X86_647// RUN: lipo %t.fat -extract x86_64h -output %t.fat.x86_64h  && lipo %t.fat.x86_64h  -info | FileCheck %s --check-prefix=CHECK-LIPO-FAT-X86_64H8 9// CHECK-LIPO-THIN-X86_64:  Non-fat file: {{.*}} is architecture: x86_6410// CHECK-LIPO-THIN-X86_64H: Non-fat file: {{.*}} is architecture: x86_64h11// CHECK-LIPO-FAT-X86_64:   Architectures in the fat file: {{.*}} are: x86_6412// CHECK-LIPO-FAT-X86_64H:  Architectures in the fat file: {{.*}} are: x86_64h13 14// RUN: dsymutil %t.thin.x86_6415// RUN: dsymutil %t.thin.x86_64h16// RUN: dsymutil %t.fat.x86_6417// RUN: dsymutil %t.fat.x86_64h18 19// Check LLVM symbolizer20// RUN: %env_asan_opts=external_symbolizer_path=$(which llvm-symbolizer) not %run %t.thin.x86_64  2>&1 | FileCheck %s --check-prefixes CHECK,CHECK-LI,CHECK-DATA21// RUN: %env_asan_opts=external_symbolizer_path=$(which llvm-symbolizer) not %run %t.thin.x86_64h 2>&1 | FileCheck %s --check-prefixes CHECK,CHECK-LI,CHECK-DATA22// RUN: %env_asan_opts=external_symbolizer_path=$(which llvm-symbolizer) not %run %t.fat.x86_64   2>&1 | FileCheck %s --check-prefixes CHECK,CHECK-LI,CHECK-DATA23// RUN: %env_asan_opts=external_symbolizer_path=$(which llvm-symbolizer) not %run %t.fat.x86_64h  2>&1 | FileCheck %s --check-prefixes CHECK,CHECK-LI,CHECK-DATA24 25// Check atos26// RUN: %env_asan_opts=external_symbolizer_path=$(which atos) not %run %t.thin.x86_64  2>&1 | FileCheck %s --check-prefixes CHECK,CHECK-LI,CHECK-DATA27// RUN: %env_asan_opts=external_symbolizer_path=$(which atos) not %run %t.thin.x86_64h 2>&1 | FileCheck %s --check-prefixes CHECK,CHECK-LI,CHECK-DATA28// RUN: %env_asan_opts=external_symbolizer_path=$(which atos) not %run %t.fat.x86_64   2>&1 | FileCheck %s --check-prefixes CHECK,CHECK-LI,CHECK-DATA29// RUN: %env_asan_opts=external_symbolizer_path=$(which atos) not %run %t.fat.x86_64h  2>&1 | FileCheck %s --check-prefixes CHECK,CHECK-LI,CHECK-DATA30 31// Check dladdr32// RUN: %env_asan_opts=external_symbolizer_path= not %run %t.thin.x86_64  2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-NOLI,CHECK-DATA33// RUN: %env_asan_opts=external_symbolizer_path= not %run %t.thin.x86_64h 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-NOLI,CHECK-DATA34// RUN: %env_asan_opts=external_symbolizer_path= not %run %t.fat.x86_64   2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-NOLI,CHECK-DATA35// RUN: %env_asan_opts=external_symbolizer_path= not %run %t.fat.x86_64h  2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-NOLI,CHECK-DATA36 37// Check asan_symbolize.py with llvm-symbolizer38// RUN: %env_asan_opts=symbolize=0 not %run %t.thin.x86_64  2>&1 | %asan_symbolize | FileCheck %s --check-prefixes CHECK,CHECK-LI39// RUN: %env_asan_opts=symbolize=0 not %run %t.thin.x86_64h 2>&1 | %asan_symbolize | FileCheck %s --check-prefixes CHECK,CHECK-LI40// RUN: %env_asan_opts=symbolize=0 not %run %t.fat.x86_64   2>&1 | %asan_symbolize | FileCheck %s --check-prefixes CHECK,CHECK-LI41// RUN: %env_asan_opts=symbolize=0 not %run %t.fat.x86_64h  2>&1 | %asan_symbolize | FileCheck %s --check-prefixes CHECK,CHECK-LI42 43// Check asan_symbolize.py with atos44// RUN: %env_asan_opts=symbolize=0 not %run %t.thin.x86_64  2>&1 | %asan_symbolize --force-system-symbolizer | FileCheck %s --check-prefixes CHECK,CHECK-LI45// RUN: %env_asan_opts=symbolize=0 not %run %t.thin.x86_64h 2>&1 | %asan_symbolize --force-system-symbolizer | FileCheck %s --check-prefixes CHECK,CHECK-LI46// RUN: %env_asan_opts=symbolize=0 not %run %t.fat.x86_64   2>&1 | %asan_symbolize --force-system-symbolizer | FileCheck %s --check-prefixes CHECK,CHECK-LI47// RUN: %env_asan_opts=symbolize=0 not %run %t.fat.x86_64h  2>&1 | %asan_symbolize --force-system-symbolizer | FileCheck %s --check-prefixes CHECK,CHECK-LI48 49// REQUIRES: x86-target-arch50// REQUIRES: x86_64h51// UNSUPPORTED: ios52 53#include <sanitizer/common_interface_defs.h>54#include <stdio.h>55#include <stdlib.h>56 57#if __x86_64h__58// Unused functions and globals, just to mess up the offsets in x86_64h.59void dummy(char *a, char *b) {60  while (*a == *b) {61    a[0] = b[0];62    a[1] = b[1];63    a[2] = b[2];64    a[3] = b[3];65    fprintf(stderr, "dummy\n");66  }67  fprintf(stderr, "dummy\n");68}69long dummy_global;70long dummy_global2[100];71#endif72 73extern "C"74long faulty_global = 10;75 76void check_data_symbolication() {77  char data[100];78  __sanitizer_symbolize_global(&faulty_global, "%g", data, sizeof(data));79  fprintf(stderr, "symbolized global: %s\n", data);80  // CHECK-DATA: symbolized global: faulty_global81}82 83extern "C"84void faulty_func(char *p) {85  *p = 'x';  // BOOM86  // CHECK: AddressSanitizer: global-buffer-overflow87  // CHECK-LI: #0 0x{{.*}} in faulty_func{{.*}} {{.*}}haswell-symbolication.cpp:[[@LINE-2]]88  // CHECK-NOLI: #0 0x{{.*}} in faulty_func{{.*}} {{.*}}haswell-symbolication89  // CHECK: is located 2 bytes after global variable 'faulty_global'90  // CHECK-NOT: LLVMSymbolizer: error reading file91}92 93int main() {94  check_data_symbolication();95 96  char *p = (char *)(void *)&faulty_global;97  p += 10;98  faulty_func(p);99  return 0;100}101