2018-04-10 04:18:10 +08:00
|
|
|
// Test that a stack overflow fails as expected
|
Add simple runtime tests for shadowcallstack
Summary:
ShadowCallStack does not yet have a runtime provided by compiler-rt, but
this change includes simple tests that make use of a very minimal
runtime in test/shadowcallstack/minimal_runtime.h
Reviewers: pcc, kcc, delcypher, eugenis, filcab
Reviewed By: pcc
Subscribers: kubamracek, mgorny, delcypher, llvm-commits, #sanitizers, kcc
Differential Revision: https://reviews.llvm.org/D44803
llvm-svn: 329210
2018-04-05 01:53:33 +08:00
|
|
|
|
2018-04-10 04:18:10 +08:00
|
|
|
// RUN: %clang_noscs %s -o %t -DITERATIONS=3
|
|
|
|
// RUN: %run %t | FileCheck %s
|
|
|
|
// RUN: %clang_noscs %s -o %t -DITERATIONS=12
|
|
|
|
// RUN: %run %t | FileCheck -check-prefix=OVERFLOW_SUCCESS %s
|
Add simple runtime tests for shadowcallstack
Summary:
ShadowCallStack does not yet have a runtime provided by compiler-rt, but
this change includes simple tests that make use of a very minimal
runtime in test/shadowcallstack/minimal_runtime.h
Reviewers: pcc, kcc, delcypher, eugenis, filcab
Reviewed By: pcc
Subscribers: kubamracek, mgorny, delcypher, llvm-commits, #sanitizers, kcc
Differential Revision: https://reviews.llvm.org/D44803
llvm-svn: 329210
2018-04-05 01:53:33 +08:00
|
|
|
|
2018-04-10 04:18:10 +08:00
|
|
|
// RUN: %clang_scs %s -o %t -DITERATIONS=3
|
|
|
|
// RUN: %run %t | FileCheck %s
|
|
|
|
|
|
|
|
// The behavioral check for SCS + overflow lives in the tests overflow-x86_64.c
|
|
|
|
// and overflow-aarch64.c. This is because the expected behavior is different
|
|
|
|
// between the two platforms. On x86_64 we crash because the comparison between
|
|
|
|
// the shadow call stack and the regular stack fails. On aarch64 there is no
|
|
|
|
// comparison, we just load the return address from the shadow call stack. So we
|
|
|
|
// just expect not to see the output from print_and_exit.
|
Add simple runtime tests for shadowcallstack
Summary:
ShadowCallStack does not yet have a runtime provided by compiler-rt, but
this change includes simple tests that make use of a very minimal
runtime in test/shadowcallstack/minimal_runtime.h
Reviewers: pcc, kcc, delcypher, eugenis, filcab
Reviewed By: pcc
Subscribers: kubamracek, mgorny, delcypher, llvm-commits, #sanitizers, kcc
Differential Revision: https://reviews.llvm.org/D44803
llvm-svn: 329210
2018-04-05 01:53:33 +08:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "minimal_runtime.h"
|
|
|
|
|
|
|
|
void print_and_exit(void) {
|
|
|
|
// CHECK-NOT: Stack overflow successful.
|
|
|
|
// OVERFLOW_SUCCESS: Stack overflow successful.
|
2018-04-10 04:18:10 +08:00
|
|
|
scs_fputs_stdout("Stack overflow successful.\n");
|
Add simple runtime tests for shadowcallstack
Summary:
ShadowCallStack does not yet have a runtime provided by compiler-rt, but
this change includes simple tests that make use of a very minimal
runtime in test/shadowcallstack/minimal_runtime.h
Reviewers: pcc, kcc, delcypher, eugenis, filcab
Reviewed By: pcc
Subscribers: kubamracek, mgorny, delcypher, llvm-commits, #sanitizers, kcc
Differential Revision: https://reviews.llvm.org/D44803
llvm-svn: 329210
2018-04-05 01:53:33 +08:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2018-04-10 04:18:10 +08:00
|
|
|
int scs_main(void)
|
Add simple runtime tests for shadowcallstack
Summary:
ShadowCallStack does not yet have a runtime provided by compiler-rt, but
this change includes simple tests that make use of a very minimal
runtime in test/shadowcallstack/minimal_runtime.h
Reviewers: pcc, kcc, delcypher, eugenis, filcab
Reviewed By: pcc
Subscribers: kubamracek, mgorny, delcypher, llvm-commits, #sanitizers, kcc
Differential Revision: https://reviews.llvm.org/D44803
llvm-svn: 329210
2018-04-05 01:53:33 +08:00
|
|
|
{
|
|
|
|
void *addrs[4];
|
2018-04-10 04:18:10 +08:00
|
|
|
for (int i = 0; i < ITERATIONS; i++)
|
Add simple runtime tests for shadowcallstack
Summary:
ShadowCallStack does not yet have a runtime provided by compiler-rt, but
this change includes simple tests that make use of a very minimal
runtime in test/shadowcallstack/minimal_runtime.h
Reviewers: pcc, kcc, delcypher, eugenis, filcab
Reviewed By: pcc
Subscribers: kubamracek, mgorny, delcypher, llvm-commits, #sanitizers, kcc
Differential Revision: https://reviews.llvm.org/D44803
llvm-svn: 329210
2018-04-05 01:53:33 +08:00
|
|
|
addrs[i] = &print_and_exit;
|
|
|
|
|
2018-04-10 04:18:10 +08:00
|
|
|
scs_fputs_stdout("Returning.\n");
|
Add simple runtime tests for shadowcallstack
Summary:
ShadowCallStack does not yet have a runtime provided by compiler-rt, but
this change includes simple tests that make use of a very minimal
runtime in test/shadowcallstack/minimal_runtime.h
Reviewers: pcc, kcc, delcypher, eugenis, filcab
Reviewed By: pcc
Subscribers: kubamracek, mgorny, delcypher, llvm-commits, #sanitizers, kcc
Differential Revision: https://reviews.llvm.org/D44803
llvm-svn: 329210
2018-04-05 01:53:33 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|