1 // Check that --gc-sections does not throw away (or localize) parts of sanitizer
3 // RUN: %clang_asan %s -Wl,--gc-sections -ldl -o %t
4 // RUN: %clang_asan %s -DBUILD_SO -fPIC -o %t-so.so -shared
7 // REQUIRES: asan-64-bits
15 int main(int argc
, char *argv
[]) {
17 snprintf(path
, sizeof(path
), "%s-so.so", argv
[0]);
19 void *handle
= dlopen(path
, RTLD_LAZY
);
20 if (!handle
) fprintf(stderr
, "%s\n", dlerror());
24 F f
= (F
)dlsym(handle
, "call_rtl_from_dso");
25 printf("%s\n", dlerror());
26 assert(dlerror() == 0);
35 #include <sanitizer/asan_interface.h>
36 extern "C" void call_rtl_from_dso() {
38 volatile int32_t y
= __sanitizer_unaligned_load32((void *)&x
);