2016-04-12 06:27:55 +08:00
|
|
|
// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 0 | FileCheck -check-prefix=DEF -check-prefix=NOSSP %s
|
|
|
|
// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 1 | FileCheck -check-prefix=DEF -check-prefix=SSP %s
|
|
|
|
// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 2 | FileCheck -check-prefix=DEF -check-prefix=SSPSTRONG %s
|
|
|
|
// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 3 | FileCheck -check-prefix=DEF -check-prefix=SSPREQ %s
|
|
|
|
|
|
|
|
// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=safe-stack | FileCheck -check-prefix=DEF -check-prefix=SAFESTACK-NOSSP %s
|
|
|
|
// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=safe-stack -stack-protector 0 | FileCheck -check-prefix=DEF -check-prefix=SAFESTACK-NOSSP %s
|
|
|
|
// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=safe-stack -stack-protector 1 | FileCheck -check-prefix=DEF -check-prefix=SAFESTACK-SSP %s
|
|
|
|
// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=safe-stack -stack-protector 2 | FileCheck -check-prefix=DEF -check-prefix=SAFESTACK-SSPSTRONG %s
|
|
|
|
// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=safe-stack -stack-protector 3 | FileCheck -check-prefix=DEF -check-prefix=SAFESTACK-SSPREQ %s
|
2013-02-17 11:06:16 +08:00
|
|
|
|
|
|
|
typedef __SIZE_TYPE__ size_t;
|
2009-06-28 15:36:13 +08:00
|
|
|
|
2009-10-09 07:05:06 +08:00
|
|
|
int printf(const char * _Format, ...);
|
2013-02-17 11:06:16 +08:00
|
|
|
size_t strlen(const char *s);
|
|
|
|
char *strcpy(char *s1, const char *s2);
|
2009-06-28 15:36:13 +08:00
|
|
|
|
2021-10-15 18:26:07 +08:00
|
|
|
// DEF: define {{.*}}void @test1(i8* noundef %msg) #[[A:.*]] {
|
2009-06-28 15:36:13 +08:00
|
|
|
void test1(const char *msg) {
|
|
|
|
char a[strlen(msg) + 1];
|
|
|
|
strcpy(a, msg);
|
|
|
|
printf("%s\n", a);
|
|
|
|
}
|
2013-02-20 15:22:19 +08:00
|
|
|
|
2021-10-15 18:26:07 +08:00
|
|
|
// DEF: define {{.*}}void @test2(i8* noundef %msg) #[[B:.*]] {
|
2018-05-10 05:41:18 +08:00
|
|
|
__attribute__((no_stack_protector))
|
|
|
|
void test2(const char *msg) {
|
|
|
|
char a[strlen(msg) + 1];
|
|
|
|
strcpy(a, msg);
|
|
|
|
printf("%s\n", a);
|
|
|
|
}
|
|
|
|
|
2016-04-12 06:27:55 +08:00
|
|
|
// NOSSP-NOT: attributes #[[A]] = {{.*}} ssp
|
2016-04-13 01:51:59 +08:00
|
|
|
// SSP: attributes #[[A]] = {{.*}} ssp{{ }}
|
2016-04-12 06:27:55 +08:00
|
|
|
// SSPSTRONG: attributes #[[A]] = {{.*}} sspstrong
|
|
|
|
// SSPREQ: attributes #[[A]] = {{.*}} sspreq
|
2014-02-11 09:35:14 +08:00
|
|
|
|
2016-04-12 06:27:55 +08:00
|
|
|
// SAFESTACK-NOSSP: attributes #[[A]] = {{.*}} safestack
|
2020-11-18 09:17:44 +08:00
|
|
|
// SAFESTACK-NOSSP-NOT: ssp
|
2015-06-16 05:08:13 +08:00
|
|
|
|
2016-04-13 01:51:59 +08:00
|
|
|
// SAFESTACK-SSP: attributes #[[A]] = {{.*}} safestack ssp{{ }}
|
2016-04-12 06:27:55 +08:00
|
|
|
// SAFESTACK-SSPSTRONG: attributes #[[A]] = {{.*}} safestack sspstrong
|
|
|
|
// SAFESTACK-SSPREQ: attributes #[[A]] = {{.*}} safestack sspreq
|
2018-05-10 05:41:18 +08:00
|
|
|
|
|
|
|
// NOSSP-NOT: attributes #[[B]] = {{.*}} ssp
|
|
|
|
// SSP-NOT: attributes #[[B]] = {{.*}} ssp{{ }}
|
|
|
|
// SSPSTRONG-NOT: attributes #[[B]] = {{.*}} sspstrong
|
|
|
|
// SSPREQ-NOT: attributes #[[B]] = {{.*}} sspreq
|
|
|
|
|
|
|
|
// SAFESTACK-SSP: attributes #[[B]] = {{.*}} safestack
|
|
|
|
// SAFESTACK-SSP-NOT: attributes #[[B]] = {{.*}} safestack ssp{{ }}
|
|
|
|
// SAFESTACK-SSPSTRONG: attributes #[[B]] = {{.*}} safestack
|
|
|
|
// SAFESTACK-SSPSTRONG-NOT: attributes #[[B]] = {{.*}} safestack sspstrong
|
|
|
|
// SAFESTACK-SSPREQ: attributes #[[B]] = {{.*}} safestack
|
|
|
|
// SAFESTACK-SSPREQ-NOT: attributes #[[B]] = {{.*}} safestack sspreq
|