diff options
| author | Bill Wendling <isanbard@gmail.com> | 2009-06-28 07:36:13 +0000 |
|---|---|---|
| committer | Bill Wendling <isanbard@gmail.com> | 2009-06-28 07:36:13 +0000 |
| commit | d63bbadbef6d8b1b9dbc9a5e024c275b0a9897e9 (patch) | |
| tree | 1b5305469985b27a4317fd886765b1ffbdea5424 /clang/test | |
| parent | bd956c429040a41c7e9e4fdd3063ec0ab98457cb (diff) | |
| download | bcm5719-llvm-d63bbadbef6d8b1b9dbc9a5e024c275b0a9897e9.tar.gz bcm5719-llvm-d63bbadbef6d8b1b9dbc9a5e024c275b0a9897e9.zip | |
Add stack protector support to clang. This generates the 'ssp' and 'sspreq'
function attributes. There are predefined macros that are defined when stack
protectors are used: __SSP__=1 with -fstack-protector and __SSP_ALL__=2 with
-fstack-protector-all.
llvm-svn: 74405
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/CodeGen/stack-protector.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/clang/test/CodeGen/stack-protector.c b/clang/test/CodeGen/stack-protector.c new file mode 100644 index 00000000000..bdac853aed6 --- /dev/null +++ b/clang/test/CodeGen/stack-protector.c @@ -0,0 +1,22 @@ +// RUN: clang-cc -triple i686-unknown-unknown -emit-llvm -o %t %s && +// RUN: not grep 'ssp' %t && +// RUN: clang-cc -triple i686-apple-darwin9 -emit-llvm -o %t %s && +// RUN: not grep 'ssp' %t && +// RUN: clang-cc -triple i686-apple-darwin10 -emit-llvm -o %t %s && +// RUN: grep 'ssp' %t && +// RUN: clang -fstack-protector-all -emit-llvm -S -o %t %s && +// RUN: grep 'sspreq' %t && +// RUN: clang -fstack-protector -emit-llvm -S -o %t %s && +// RUN: grep 'ssp' %t && +// RUN: clang -fno-stack-protector -emit-llvm -S -o %t %s && +// RUN: not grep 'ssp' %t && +// RUN: true + +#include <stdio.h> +#include <string.h> + +void test1(const char *msg) { + char a[strlen(msg) + 1]; + strcpy(a, msg); + printf("%s\n", a); +} |

