2017-07-28 09:38:43 +08:00
|
|
|
// Tests -fsanitize-coverage=inline-8bit-counters,pc-table
|
2017-06-09 06:58:19 +08:00
|
|
|
//
|
|
|
|
// REQUIRES: has_sancovcc,stable-runtime
|
2017-06-22 03:04:59 +08:00
|
|
|
// UNSUPPORTED: i386-darwin
|
2017-06-09 06:58:19 +08:00
|
|
|
//
|
2017-08-26 03:29:47 +08:00
|
|
|
// RUN: %clangxx -O0 %s -fsanitize-coverage=inline-8bit-counters,pc-table -o %t
|
|
|
|
// RUN: %run %t 2>&1 | FileCheck %s
|
|
|
|
// XFAIL: tsan
|
2017-06-09 06:58:19 +08:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2017-07-28 09:38:43 +08:00
|
|
|
#include <stdint.h>
|
2017-06-09 06:58:19 +08:00
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
const char *first_counter;
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
void __sanitizer_cov_8bit_counters_init(const char *start, const char *end) {
|
|
|
|
printf("INIT: %p %p\n", start, end);
|
|
|
|
assert(end - start > 1);
|
|
|
|
first_counter = start;
|
|
|
|
}
|
|
|
|
|
2017-07-28 09:38:43 +08:00
|
|
|
uintptr_t FirstPC;
|
2017-08-26 03:29:47 +08:00
|
|
|
uintptr_t FirstPCFlag;
|
2017-07-28 09:38:43 +08:00
|
|
|
|
2017-08-26 03:29:47 +08:00
|
|
|
extern "C" void __sanitizer_cov_pcs_init(const uintptr_t *pcs_beg,
|
|
|
|
const uintptr_t *pcs_end) {
|
2017-07-28 09:38:43 +08:00
|
|
|
const uintptr_t *B = (const uintptr_t *)pcs_beg;
|
|
|
|
const uintptr_t *E = (const uintptr_t *)pcs_end;
|
2017-08-26 03:29:47 +08:00
|
|
|
assert(B + 1 < E);
|
|
|
|
FirstPC = B[0];
|
|
|
|
FirstPCFlag = B[1];
|
2017-07-28 09:38:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-09 06:58:19 +08:00
|
|
|
int main() {
|
|
|
|
assert(first_counter);
|
|
|
|
assert(*first_counter == 1);
|
2017-07-28 09:38:43 +08:00
|
|
|
assert(FirstPC == (uintptr_t)&main);
|
2017-08-26 03:29:47 +08:00
|
|
|
assert(FirstPCFlag == 1);
|
|
|
|
fprintf(stderr, "PASS\n");
|
|
|
|
// CHECK: PASS
|
2017-06-09 06:58:19 +08:00
|
|
|
}
|