Reid Kleckner | 7a36896 | 2018-09-06 18:25:39 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=address -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefix=LINUX |
| 2 | // RUN: %clang_cc1 -triple x86_64-windows-msvc -fsanitize=address -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefix=WINDOWS |
| 3 | // RUN: %clang_cc1 -triple x86_64-windows-msvc -fsanitize=address -fwritable-strings -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefix=WINWRITE |
| 4 | |
| 5 | // On Linux (and basically every non-MS target) string literals are emitted with |
| 6 | // private linkage, which means ASan can freely instrument them. On Windows, |
| 7 | // they are emitted with comdats. ASan's global instrumentation code for COFF |
| 8 | // knows how to make the metadata comdat associative, so the string literal |
| 9 | // global is only registered if the instrumented global prevails during linking. |
| 10 | |
| 11 | const char *foo() { return "asdf"; } |
| 12 | |
| 13 | // LINUX: @.str = private unnamed_addr constant [5 x i8] c"asdf\00", align 1 |
| 14 | |
| 15 | // WINDOWS: @"??_C@_04JIHMPGLA@asdf?$AA@" = linkonce_odr dso_local unnamed_addr constant [5 x i8] c"asdf\00", comdat, align 1 |
| 16 | |
| 17 | // WINWRITE: @.str = private unnamed_addr global [5 x i8] c"asdf\00", align 1 |