stack-protector.c revision b6d6993e6e6d3daf4d9876794254d20a134e37c2
1a5728872c7702ddd09537c95bc3cbd20e1f2fb09Daniel Dunbar// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 0 | FileCheck -check-prefix=NOSSP %s 2f7a9da053f5bd6c18450c1796d953b42c3b7ad3aBill Wendling// NOSSP: define void @test1(i8* %msg) #0 { 3a5728872c7702ddd09537c95bc3cbd20e1f2fb09Daniel Dunbar// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 1 | FileCheck -check-prefix=WITHSSP %s 4f7a9da053f5bd6c18450c1796d953b42c3b7ad3aBill Wendling// WITHSSP: define void @test1(i8* %msg) #0 { 5651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 2 | FileCheck -check-prefix=SSPSTRONG %s 6651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines// SSPSTRONG: define void @test1(i8* %msg) #0 { 7651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 3 | FileCheck -check-prefix=SSPREQ %s 8f7a9da053f5bd6c18450c1796d953b42c3b7ad3aBill Wendling// SSPREQ: define void @test1(i8* %msg) #0 { 9b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=safe-stack | FileCheck -check-prefix=SAFESTACK %s 10b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar// SAFESTACK: define void @test1(i8* %msg) #0 { 1197e948e9c9cc2db9f0cdc13e708fe1bd8c6d05a2Dmitri Gribenko 1297e948e9c9cc2db9f0cdc13e708fe1bd8c6d05a2Dmitri Gribenkotypedef __SIZE_TYPE__ size_t; 1345483f7a1b3e57b4603b141bee80596b2d4dd443Bill Wendling 1476bee4b756badefda61ce867c757cc31b7afa12fMike Stumpint printf(const char * _Format, ...); 1597e948e9c9cc2db9f0cdc13e708fe1bd8c6d05a2Dmitri Gribenkosize_t strlen(const char *s); 1697e948e9c9cc2db9f0cdc13e708fe1bd8c6d05a2Dmitri Gribenkochar *strcpy(char *s1, const char *s2); 1745483f7a1b3e57b4603b141bee80596b2d4dd443Bill Wendling 1845483f7a1b3e57b4603b141bee80596b2d4dd443Bill Wendlingvoid test1(const char *msg) { 1945483f7a1b3e57b4603b141bee80596b2d4dd443Bill Wendling char a[strlen(msg) + 1]; 2045483f7a1b3e57b4603b141bee80596b2d4dd443Bill Wendling strcpy(a, msg); 2145483f7a1b3e57b4603b141bee80596b2d4dd443Bill Wendling printf("%s\n", a); 2245483f7a1b3e57b4603b141bee80596b2d4dd443Bill Wendling} 23f7a9da053f5bd6c18450c1796d953b42c3b7ad3aBill Wendling 243bba3efba0e57071d60b355ed62639f93e37711cBill Wendling// NOSSP: attributes #{{.*}} = { nounwind{{.*}} } 25f7a9da053f5bd6c18450c1796d953b42c3b7ad3aBill Wendling 263bba3efba0e57071d60b355ed62639f93e37711cBill Wendling// WITHSSP: attributes #{{.*}} = { nounwind ssp{{.*}} } 27f7a9da053f5bd6c18450c1796d953b42c3b7ad3aBill Wendling 28651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines// SSPSTRONG: attributes #{{.*}} = { nounwind sspstrong{{.*}} } 29651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines 303bba3efba0e57071d60b355ed62639f93e37711cBill Wendling// SSPREQ: attributes #{{.*}} = { nounwind sspreq{{.*}} } 31b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar 32b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar// SAFESTACK: attributes #{{.*}} = { nounwind safestack{{.*}} } 33