Fix remaining regressions in ASAN support

See #829
This commit is contained in:
Justine Tunney 2023-06-08 08:00:37 -07:00
parent 4d629fd424
commit 25678db2a0
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
3 changed files with 9 additions and 7 deletions

View file

@ -128,6 +128,7 @@ endif
# - Larger binaries
#
ifeq ($(MODE), asan)
ENABLE_FTRACE = 1
CONFIG_CCFLAGS += $(BACKTRACES) -O2 -DSYSDEBUG
CONFIG_COPTS += -fsanitize=address
TARGET_ARCH ?= -msse3

View file

@ -165,15 +165,16 @@ void __asan_version_mismatch_check_v8(void) {
}
static bool __asan_once(void) {
bool want = false;
int want = false;
static atomic_int once;
return atomic_compare_exchange_strong_explicit(
&once, &want, true, memory_order_relaxed, memory_order_relaxed);
}
#define __asan_unreachable() \
do { \
for (;;) __builtin_trap(); \
#define __asan_unreachable() \
do { \
kprintf("%s:%d: __asan_unreachable()\n", __FILE__, __LINE__); \
for (;;) __builtin_trap(); \
} while (0)
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");
if (!__vforked && __asan_once()) {
__asan_report_memory_fault(addr, size, "load")();
__asan_unreachable();
}
__asan_unreachable();
}
void __asan_report_store(uint8_t *addr, int size) {
__asan_evil(addr, size, "store");
if (!__vforked && __asan_once()) {
__asan_report_memory_fault(addr, size, "store")();
__asan_unreachable();
}
__asan_unreachable();
}
void __asan_poison_stack_memory(char *addr, size_t size) {

View file

@ -25,7 +25,7 @@
(require 'ld-script)
(require 'make-mode)
(setq cosmo-dbg-mode "zero")
(setq cosmo-dbg-mode "asan")
(setq c-doc-comment-style 'javadown)
(add-to-list 'auto-mode-alist '("\\.x$" . c-mode)) ;; -aux-info