Re: r266005 - Allow simultaneous safestack and stackprotector attributes.

2016-04-12 Thread Evgenii Stepanov via cfe-commits
Thanks, fixed in r266095

On Tue, Apr 12, 2016 at 10:15 AM, Robinson, Paul
 wrote:
>
>
>> -Original Message-
>> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of
>> Evgeniy Stepanov via cfe-commits
>> Sent: Monday, April 11, 2016 3:28 PM
>> To: cfe-commits@lists.llvm.org
>> Subject: r266005 - Allow simultaneous safestack and stackprotector
>> attributes.
>>
>> Author: eugenis
>> Date: Mon Apr 11 17:27:55 2016
>> New Revision: 266005
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=266005&view=rev
>> Log:
>> Allow simultaneous safestack and stackprotector attributes.
>>
>> This is the clang part of http://reviews.llvm.org/D18846.
>> SafeStack instrumentation pass adds stack protector canaries if both
>> attributes are present on a function. StackProtector pass will step
>> back if the function has a safestack attribute.
>>
>> Modified:
>> cfe/trunk/lib/Driver/Tools.cpp
>> cfe/trunk/test/CodeGen/stack-protector.c
>> cfe/trunk/test/Driver/fsanitize.c
>>
>> Modified: cfe/trunk/lib/Driver/Tools.cpp
>> URL: http://llvm.org/viewvc/llvm-
>> project/cfe/trunk/lib/Driver/Tools.cpp?rev=266005&r1=266004&r2=266005&view
>> =diff
>> ==
>> 
>> --- cfe/trunk/lib/Driver/Tools.cpp (original)
>> +++ cfe/trunk/lib/Driver/Tools.cpp Mon Apr 11 17:27:55 2016
>> @@ -4878,15 +4878,10 @@ void Clang::ConstructJob(Compilation &C,
>>
>>// -stack-protector=0 is default.
>>unsigned StackProtectorLevel = 0;
>> -  if (getToolChain().getSanitizerArgs().needsSafeStackRt()) {
>> -Args.ClaimAllArgs(options::OPT_fno_stack_protector);
>> -Args.ClaimAllArgs(options::OPT_fstack_protector_all);
>> -Args.ClaimAllArgs(options::OPT_fstack_protector_strong);
>> -Args.ClaimAllArgs(options::OPT_fstack_protector);
>> -  } else if (Arg *A = Args.getLastArg(options::OPT_fno_stack_protector,
>> -  options::OPT_fstack_protector_all,
>> -
>> options::OPT_fstack_protector_strong,
>> -  options::OPT_fstack_protector)) {
>> +  if (Arg *A = Args.getLastArg(options::OPT_fno_stack_protector,
>> +   options::OPT_fstack_protector_all,
>> +   options::OPT_fstack_protector_strong,
>> +   options::OPT_fstack_protector)) {
>>  if (A->getOption().matches(options::OPT_fstack_protector)) {
>>StackProtectorLevel = std::max(
>>LangOptions::SSPOn,
>>
>> Modified: cfe/trunk/test/CodeGen/stack-protector.c
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/stack-
>> protector.c?rev=266005&r1=266004&r2=266005&view=diff
>> ==
>> 
>> --- cfe/trunk/test/CodeGen/stack-protector.c (original)
>> +++ cfe/trunk/test/CodeGen/stack-protector.c Mon Apr 11 17:27:55 2016
>> @@ -1,13 +1,13 @@
>> -// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 0 | FileCheck -
>> check-prefix=NOSSP %s
>> -// NOSSP: define {{.*}}void @test1(i8* %msg) #0 {
>> -// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 1 | FileCheck -
>> check-prefix=WITHSSP %s
>> -// WITHSSP: define {{.*}}void @test1(i8* %msg) #0 {
>> -// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 2 | FileCheck -
>> check-prefix=SSPSTRONG %s
>> -// SSPSTRONG: define {{.*}}void @test1(i8* %msg) #0 {
>> -// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 3 | FileCheck -
>> check-prefix=SSPREQ %s
>> -// SSPREQ: define {{.*}}void @test1(i8* %msg) #0 {
>> -// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=safe-stack | FileCheck -
>> check-prefix=SAFESTACK %s
>> -// SAFESTACK: define {{.*}}void @test1(i8* %msg) #0 {
>> +// 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
>>
>>  typedef 

RE: r266005 - Allow simultaneous safestack and stackprotector attributes.

2016-04-12 Thread Robinson, Paul via cfe-commits


> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of
> Evgeniy Stepanov via cfe-commits
> Sent: Monday, April 11, 2016 3:28 PM
> To: cfe-commits@lists.llvm.org
> Subject: r266005 - Allow simultaneous safestack and stackprotector
> attributes.
> 
> Author: eugenis
> Date: Mon Apr 11 17:27:55 2016
> New Revision: 266005
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=266005&view=rev
> Log:
> Allow simultaneous safestack and stackprotector attributes.
> 
> This is the clang part of http://reviews.llvm.org/D18846.
> SafeStack instrumentation pass adds stack protector canaries if both
> attributes are present on a function. StackProtector pass will step
> back if the function has a safestack attribute.
> 
> Modified:
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/test/CodeGen/stack-protector.c
> cfe/trunk/test/Driver/fsanitize.c
> 
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/lib/Driver/Tools.cpp?rev=266005&r1=266004&r2=266005&view
> =diff
> ==
> 
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Mon Apr 11 17:27:55 2016
> @@ -4878,15 +4878,10 @@ void Clang::ConstructJob(Compilation &C,
> 
>// -stack-protector=0 is default.
>unsigned StackProtectorLevel = 0;
> -  if (getToolChain().getSanitizerArgs().needsSafeStackRt()) {
> -Args.ClaimAllArgs(options::OPT_fno_stack_protector);
> -Args.ClaimAllArgs(options::OPT_fstack_protector_all);
> -Args.ClaimAllArgs(options::OPT_fstack_protector_strong);
> -Args.ClaimAllArgs(options::OPT_fstack_protector);
> -  } else if (Arg *A = Args.getLastArg(options::OPT_fno_stack_protector,
> -  options::OPT_fstack_protector_all,
> -
> options::OPT_fstack_protector_strong,
> -  options::OPT_fstack_protector)) {
> +  if (Arg *A = Args.getLastArg(options::OPT_fno_stack_protector,
> +   options::OPT_fstack_protector_all,
> +   options::OPT_fstack_protector_strong,
> +   options::OPT_fstack_protector)) {
>  if (A->getOption().matches(options::OPT_fstack_protector)) {
>StackProtectorLevel = std::max(
>LangOptions::SSPOn,
> 
> Modified: cfe/trunk/test/CodeGen/stack-protector.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/stack-
> protector.c?rev=266005&r1=266004&r2=266005&view=diff
> ==
> 
> --- cfe/trunk/test/CodeGen/stack-protector.c (original)
> +++ cfe/trunk/test/CodeGen/stack-protector.c Mon Apr 11 17:27:55 2016
> @@ -1,13 +1,13 @@
> -// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 0 | FileCheck -
> check-prefix=NOSSP %s
> -// NOSSP: define {{.*}}void @test1(i8* %msg) #0 {
> -// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 1 | FileCheck -
> check-prefix=WITHSSP %s
> -// WITHSSP: define {{.*}}void @test1(i8* %msg) #0 {
> -// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 2 | FileCheck -
> check-prefix=SSPSTRONG %s
> -// SSPSTRONG: define {{.*}}void @test1(i8* %msg) #0 {
> -// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 3 | FileCheck -
> check-prefix=SSPREQ %s
> -// SSPREQ: define {{.*}}void @test1(i8* %msg) #0 {
> -// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=safe-stack | FileCheck -
> check-prefix=SAFESTACK %s
> -// SAFESTACK: define {{.*}}void @test1(i8* %msg) #0 {
> +// 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
> 
>  typedef __SIZE_TYPE__ size_t;
> 
> @@ -15,18 +15,21 @@ int printf(const char * _Format, ...);
>  size_t strlen(const char *s);
>  char *strcpy(char *s1, const char *s2);
> 
> +// DEF: def