Files
clang-p2996/compiler-rt/test/hwasan/TestCases/preinit_array.c
Matt Morehouse 95d609b549 [HWASan] Add __hwasan_init to .preinit_array.
Fixes segfaults on x86_64 caused by instrumented code running before
shadow is set up.

Reviewed By: pcc

Differential Revision: https://reviews.llvm.org/D118171
2022-02-03 13:07:58 -08:00

13 lines
325 B
C

// Test that HWASan shadow is initialized before .preinit_array functions run.
// RUN: %clang_hwasan %s -o %t
// RUN: %run %t
volatile int Global;
void StoreToGlobal() { Global = 42; }
__attribute__((section(".preinit_array"), used))
void (*__StoreToGlobal_preinit)() = StoreToGlobal;
int main() { return Global != 42; }