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
|
|
|
|
|
2019-03-08 02:56:36 +08:00
|
|
|
// On aarch64 we just load the return address from the shadow call stack so we
|
|
|
|
// do not expect to see the output from print_and_exit.
|
|
|
|
// RUN: %clang_scs %s -o %t -DITERATIONS=12
|
|
|
|
// RUN: %run %t | FileCheck %S/overflow.c
|
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;
|
|
|
|
}
|