diff options
author | Dmitry Mikulin <dmitry.mikulin@sony.com> | 2019-10-16 17:51:40 +0000 |
---|---|---|
committer | Dmitry Mikulin <dmitry.mikulin@sony.com> | 2019-10-16 17:51:40 +0000 |
commit | 4da6acb783d62e0d65c3543e874fd8e883ed3370 (patch) | |
tree | 83b93ab16e001ffebf3816b4c8e0fb0637776ad7 /test | |
parent | 88700afba7f6176b9c437a6b66d81fd484ad845d (diff) | |
download | clang-4da6acb783d62e0d65c3543e874fd8e883ed3370.tar.gz |
Tag CFI-generated data structures with "#pragma clang section" attributes.
Differential Revision: https://reviews.llvm.org/D68808
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375022 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/CodeGen/cfi-pragma-section.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/CodeGen/cfi-pragma-section.c b/test/CodeGen/cfi-pragma-section.c new file mode 100644 index 0000000000..c2aae39cd9 --- /dev/null +++ b/test/CodeGen/cfi-pragma-section.c @@ -0,0 +1,32 @@ +// Check that CFI-generated data structures are tagged with +// "#pragma clang section" attributes + +// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-icall \ +// RUN: -fno-sanitize-trap=cfi-icall -emit-llvm -o - %s | FileCheck %s + +// CHECK-DAG: attributes [[ATTR:#[0-9]+]]{{.*}}bss-section{{.*}}data-section{{.*}}rodata-section +// CHECK-DAG: @.src = private unnamed_addr constant{{.*}}cfi-pragma-section.c{{.*}}[[ATTR]] +// CHECK-DAG: @{{[0-9]+}} = private unnamed_addr constant{{.*}}int (int){{.*}}[[ATTR]] +// CHECK-DAG: @{{[0-9]+}} = private unnamed_addr global{{.*}}@.src{{.*}}[[ATTR]] + +typedef int (*int_arg_fn)(int); + +static int int_arg1(int arg) { + return 0; +} + +static int int_arg2(int arg) { + return 1; +} + +int_arg_fn int_funcs[2] = {int_arg1, int_arg2}; + +#pragma clang section bss = ".bss.mycfi" +#pragma clang section data = ".data.mycfi" +#pragma clang section rodata = ".rodata.mycfi" + +int main(int argc, const char *argv[]) { + + int idx = argv[1][0] - '0'; + return int_funcs[argc](idx); +} |