2015-03-03 03:34:27 +08:00
|
|
|
// RUN: %clangxx_msan -O0 %s -o %t && %run %t
|
2013-12-06 17:19:07 +08:00
|
|
|
|
|
|
|
// Check that strlen() and similar intercepted functions can be called on shadow
|
|
|
|
// memory.
|
Adding Msan support to FreeBSD
Summary:
Enabling the memory sanitizer support for FreeBSD, most of unit tests are compatible.
- Adding fstat and stressor_r interceptors.
- Updating the struct link_map access since most likely the struct Obj_Entry had been updated since.
- Disabling few unit tests until further work is needed (or we can assume it can work in real world code).
Patch by: David CARLIER
Reviewers: vitalybuka, krytarowski
Reviewed By: vitalybuka
Subscribers: eugenis, dim, srhines, emaste, kubamracek, mgorny, fedor.sergeev, hintonda, llvm-commits, #sanitizers
Differential Revision: https://reviews.llvm.org/D43080
llvm-svn: 326644
2018-03-03 19:43:11 +08:00
|
|
|
// The mem_to_shadow's part might need rework
|
|
|
|
// XFAIL: freebsd
|
2013-12-06 17:19:07 +08:00
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2015-09-16 23:12:25 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include "test.h"
|
2013-12-06 17:19:07 +08:00
|
|
|
|
|
|
|
const char *mem_to_shadow(const char *p) {
|
2015-02-18 17:24:19 +08:00
|
|
|
#if defined(__x86_64__)
|
2015-10-09 05:35:34 +08:00
|
|
|
return (char *)((uintptr_t)p ^ 0x500000000000ULL);
|
2015-02-18 17:24:19 +08:00
|
|
|
#elif defined (__mips64)
|
2016-08-16 20:49:54 +08:00
|
|
|
return (char *)((uintptr_t)p ^ 0x8000000000ULL);
|
2015-06-25 14:22:31 +08:00
|
|
|
#elif defined(__powerpc64__)
|
|
|
|
#define LINEARIZE_MEM(mem) \
|
|
|
|
(((uintptr_t)(mem) & ~0x200000000000ULL) ^ 0x100000000000ULL)
|
|
|
|
return (char *)(LINEARIZE_MEM(p) + 0x080000000000ULL);
|
[MSan] Enable for SystemZ
Summary:
This patch adds runtime support, adjusts tests and enables MSan.
Like for ASan and UBSan, compile the tests with -mbackchain.
Reviewers: eugenis, uweigand, jonpa, vitalybuka
Reviewed By: eugenis, vitalybuka
Subscribers: vitalybuka, mgorny, hiraditya, #sanitizers, stefansf, Andreas-Krebbel
Tags: #sanitizers
Differential Revision: https://reviews.llvm.org/D76358
2020-04-16 07:01:11 +08:00
|
|
|
#elif defined(__s390x__)
|
|
|
|
return (char *)(((uintptr_t)p & ~0xC00000000000ULL) + 0x080000000000ULL);
|
2015-09-16 23:12:25 +08:00
|
|
|
#elif defined(__aarch64__)
|
2015-10-29 21:04:19 +08:00
|
|
|
return (char *)((uintptr_t)p ^ 0x6000000000ULL);
|
2015-02-18 17:24:19 +08:00
|
|
|
#endif
|
2013-12-06 17:19:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(void) {
|
|
|
|
const char *s = "abcdef";
|
|
|
|
assert(strlen(s) == 6);
|
|
|
|
assert(strlen(mem_to_shadow(s)) == 0);
|
|
|
|
|
|
|
|
char *t = new char[42];
|
|
|
|
t[41] = 0;
|
|
|
|
assert(strlen(mem_to_shadow(t)) == 41);
|
|
|
|
return 0;
|
|
|
|
}
|