mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-03 15:38:22 +00:00
parent
4d629fd424
commit
25678db2a0
3 changed files with 9 additions and 7 deletions
|
@ -128,6 +128,7 @@ endif
|
||||||
# - Larger binaries
|
# - Larger binaries
|
||||||
#
|
#
|
||||||
ifeq ($(MODE), asan)
|
ifeq ($(MODE), asan)
|
||||||
|
ENABLE_FTRACE = 1
|
||||||
CONFIG_CCFLAGS += $(BACKTRACES) -O2 -DSYSDEBUG
|
CONFIG_CCFLAGS += $(BACKTRACES) -O2 -DSYSDEBUG
|
||||||
CONFIG_COPTS += -fsanitize=address
|
CONFIG_COPTS += -fsanitize=address
|
||||||
TARGET_ARCH ?= -msse3
|
TARGET_ARCH ?= -msse3
|
||||||
|
|
|
@ -165,15 +165,16 @@ void __asan_version_mismatch_check_v8(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool __asan_once(void) {
|
static bool __asan_once(void) {
|
||||||
bool want = false;
|
int want = false;
|
||||||
static atomic_int once;
|
static atomic_int once;
|
||||||
return atomic_compare_exchange_strong_explicit(
|
return atomic_compare_exchange_strong_explicit(
|
||||||
&once, &want, true, memory_order_relaxed, memory_order_relaxed);
|
&once, &want, true, memory_order_relaxed, memory_order_relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define __asan_unreachable() \
|
#define __asan_unreachable() \
|
||||||
do { \
|
do { \
|
||||||
for (;;) __builtin_trap(); \
|
kprintf("%s:%d: __asan_unreachable()\n", __FILE__, __LINE__); \
|
||||||
|
for (;;) __builtin_trap(); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
static int __asan_bsf(uint64_t x) {
|
static int __asan_bsf(uint64_t x) {
|
||||||
|
@ -1309,16 +1310,16 @@ void __asan_report_load(uint8_t *addr, int size) {
|
||||||
__asan_evil(addr, size, "load");
|
__asan_evil(addr, size, "load");
|
||||||
if (!__vforked && __asan_once()) {
|
if (!__vforked && __asan_once()) {
|
||||||
__asan_report_memory_fault(addr, size, "load")();
|
__asan_report_memory_fault(addr, size, "load")();
|
||||||
__asan_unreachable();
|
|
||||||
}
|
}
|
||||||
|
__asan_unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void __asan_report_store(uint8_t *addr, int size) {
|
void __asan_report_store(uint8_t *addr, int size) {
|
||||||
__asan_evil(addr, size, "store");
|
__asan_evil(addr, size, "store");
|
||||||
if (!__vforked && __asan_once()) {
|
if (!__vforked && __asan_once()) {
|
||||||
__asan_report_memory_fault(addr, size, "store")();
|
__asan_report_memory_fault(addr, size, "store")();
|
||||||
__asan_unreachable();
|
|
||||||
}
|
}
|
||||||
|
__asan_unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void __asan_poison_stack_memory(char *addr, size_t size) {
|
void __asan_poison_stack_memory(char *addr, size_t size) {
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
(require 'ld-script)
|
(require 'ld-script)
|
||||||
(require 'make-mode)
|
(require 'make-mode)
|
||||||
|
|
||||||
(setq cosmo-dbg-mode "zero")
|
(setq cosmo-dbg-mode "asan")
|
||||||
(setq c-doc-comment-style 'javadown)
|
(setq c-doc-comment-style 'javadown)
|
||||||
|
|
||||||
(add-to-list 'auto-mode-alist '("\\.x$" . c-mode)) ;; -aux-info
|
(add-to-list 'auto-mode-alist '("\\.x$" . c-mode)) ;; -aux-info
|
||||||
|
|
Loading…
Add table
Reference in a new issue