2020-06-16 13:38:43 +00:00
|
|
|
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
2020-06-15 14:18:57 +00:00
|
|
|
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
|
|
|
╞══════════════════════════════════════════════════════════════════════════════╡
|
|
|
|
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
|
|
|
│ │
|
2020-12-28 01:18:44 +00:00
|
|
|
│ Permission to use, copy, modify, and/or distribute this software for │
|
|
|
|
│ any purpose with or without fee is hereby granted, provided that the │
|
|
|
|
│ above copyright notice and this permission notice appear in all copies. │
|
2020-06-15 14:18:57 +00:00
|
|
|
│ │
|
2020-12-28 01:18:44 +00:00
|
|
|
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
|
|
|
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
|
|
|
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
|
|
|
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
|
|
|
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
|
|
|
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
|
|
|
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
|
|
|
│ PERFORMANCE OF THIS SOFTWARE. │
|
2020-06-15 14:18:57 +00:00
|
|
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
2021-03-01 07:42:35 +00:00
|
|
|
#include "libc/macros.internal.h"
|
2020-06-15 14:18:57 +00:00
|
|
|
|
2021-02-03 14:22:51 +00:00
|
|
|
.rodata.cst4
|
|
|
|
__asan_option_detect_stack_use_after_return:
|
|
|
|
.long 0
|
|
|
|
.endobj __asan_option_detect_stack_use_after_return,globl
|
|
|
|
.previous
|
|
|
|
|
2020-06-15 14:18:57 +00:00
|
|
|
__asan_report_load1:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $1
|
|
|
|
jmp 1f
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_report_load1,globl
|
|
|
|
__asan_report_load2:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $2
|
|
|
|
jmp 1f
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_report_load2,globl
|
|
|
|
__asan_report_load4:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $4
|
|
|
|
jmp 1f
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_report_load4,globl
|
|
|
|
__asan_report_load8:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $8
|
|
|
|
jmp 1f
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_report_load8,globl
|
|
|
|
__asan_report_load16:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $16
|
|
|
|
jmp 1f
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_report_load16,globl
|
2021-02-03 14:22:51 +00:00
|
|
|
__asan_report_load32:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $32
|
|
|
|
1: pop %rsi
|
|
|
|
0: jmp __asan_report_load
|
2021-02-03 14:22:51 +00:00
|
|
|
.endfn __asan_report_load32,globl
|
2021-02-01 11:33:13 +00:00
|
|
|
__asan_report_load_n:
|
2021-10-14 00:27:13 +00:00
|
|
|
jmp 0b
|
2021-02-01 11:33:13 +00:00
|
|
|
.endfn __asan_report_load_n,globl
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
__asan_report_store1:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $1
|
|
|
|
jmp 1f
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_report_store1,globl
|
|
|
|
__asan_report_store2:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $2
|
|
|
|
jmp 1f
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_report_store2,globl
|
|
|
|
__asan_report_store4:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $4
|
|
|
|
jmp 1f
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_report_store4,globl
|
|
|
|
__asan_report_store8:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $8
|
|
|
|
jmp 1f
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_report_store8,globl
|
|
|
|
__asan_report_store16:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $16
|
|
|
|
jmp 1f
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_report_store16,globl
|
|
|
|
__asan_report_store32:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $32
|
|
|
|
1: pop %rsi
|
|
|
|
0: jmp __asan_report_store
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_report_store32,globl
|
2021-05-14 12:36:58 +00:00
|
|
|
__asan_report_store_n:
|
2021-10-14 00:27:13 +00:00
|
|
|
jmp 0b
|
2021-05-14 12:36:58 +00:00
|
|
|
.endfn __asan_report_store_n,globl
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
__asan_stack_free_0:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $0
|
|
|
|
jmp 1f
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_stack_free_0,globl
|
|
|
|
__asan_stack_free_1:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $1
|
|
|
|
jmp 1f
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_stack_free_1,globl
|
|
|
|
__asan_stack_free_2:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $2
|
|
|
|
jmp 1f
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_stack_free_2,globl
|
|
|
|
__asan_stack_free_3:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $3
|
|
|
|
jmp 1f
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_stack_free_3,globl
|
|
|
|
__asan_stack_free_4:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $4
|
|
|
|
jmp 1f
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_stack_free_4,globl
|
|
|
|
__asan_stack_free_5:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $5
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_stack_free_5,globl
|
2021-10-14 00:27:13 +00:00
|
|
|
__asan_stack_free_hop:
|
|
|
|
1: pop %rdx
|
|
|
|
jmp __asan_stack_free
|
|
|
|
.endfn __asan_report_store_n,globl
|
2020-06-15 14:18:57 +00:00
|
|
|
__asan_stack_free_6:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $6
|
|
|
|
jmp 1b
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_stack_free_6,globl
|
|
|
|
__asan_stack_free_7:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $7
|
|
|
|
jmp 1b
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_stack_free_7,globl
|
|
|
|
__asan_stack_free_8:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $8
|
|
|
|
jmp 1b
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_stack_free_8,globl
|
|
|
|
__asan_stack_free_9:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $9
|
|
|
|
jmp 1b
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_stack_free_9,globl
|
|
|
|
__asan_stack_free_10:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $10
|
|
|
|
jmp 1b
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_stack_free_10,globl
|
|
|
|
|
|
|
|
__asan_stack_malloc_0:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $0
|
|
|
|
jmp 1f
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_stack_malloc_0,globl
|
|
|
|
__asan_stack_malloc_1:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $1
|
|
|
|
jmp 1f
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_stack_malloc_1,globl
|
|
|
|
__asan_stack_malloc_2:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $2
|
|
|
|
jmp 1f
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_stack_malloc_2,globl
|
|
|
|
__asan_stack_malloc_3:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $3
|
|
|
|
jmp 1f
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_stack_malloc_3,globl
|
|
|
|
__asan_stack_malloc_4:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $4
|
|
|
|
jmp 1f
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_stack_malloc_4,globl
|
|
|
|
__asan_stack_malloc_5:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $5
|
|
|
|
jmp 1f
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_stack_malloc_5,globl
|
2021-10-14 00:27:13 +00:00
|
|
|
__asan_stack_malloc_hop:
|
|
|
|
1: pop %rsi
|
|
|
|
jmp __asan_stack_malloc
|
|
|
|
.endfn __asan_report_store_n,globl
|
2020-06-15 14:18:57 +00:00
|
|
|
__asan_stack_malloc_6:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $6
|
|
|
|
jmp 1b
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_stack_malloc_6,globl
|
|
|
|
__asan_stack_malloc_7:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $7
|
|
|
|
jmp 1b
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_stack_malloc_7,globl
|
|
|
|
__asan_stack_malloc_8:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $8
|
|
|
|
jmp 1b
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_stack_malloc_8,globl
|
|
|
|
__asan_stack_malloc_9:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $9
|
|
|
|
jmp 1b
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_stack_malloc_9,globl
|
|
|
|
__asan_stack_malloc_10:
|
2021-10-14 00:27:13 +00:00
|
|
|
push $10
|
|
|
|
jmp 1b
|
2020-06-15 14:18:57 +00:00
|
|
|
.endfn __asan_stack_malloc_10,globl
|
2020-09-03 12:44:37 +00:00
|
|
|
|
|
|
|
__asan_version_mismatch_check_v8:
|
|
|
|
ret
|
|
|
|
.endfn __asan_version_mismatch_check_v8,globl
|
|
|
|
|
2021-02-08 17:19:00 +00:00
|
|
|
// Initializes Address Sanitizer runtime earlier if linked.
|
Introduce --strace flag for system call tracing
This is similar to the --ftrace (c function call trace) flag, except
it's less noisy since it only logs system calls to stderr. Having this
flag is valuable because (1) system call tracing tells us a lot about
the behavior of complex programs and (2) it's usually very hard to get
system call tracing on various operating systems, e.g. strace, ktrace,
dtruss, truss, nttrace, etc. Especially on Apple platforms where even
with the special boot trick, debuggers still aren't guaranteed to work.
make -j8 o//examples
o//examples/hello.com --strace
This is enabled by default in MODE=, MODE=opt, and MODE=dbg. In MODE=dbg
extra information will be printed.
make -j8 MODE=dbg o/dbg/examples
o/dbg/examples/hello.com --strace |& less
This change also changes:
- Rename IsText() → _istext()
- Rename IsUtf8() → _isutf8()
- Fix madvise() on Windows NT
- Fix empty string case of inet_ntop()
- vfork() wrapper now saves and restores errno
- Update xsigaction() to yoink syscall support
2022-03-19 01:07:28 +00:00
|
|
|
.init.start 303,_init_asan
|
2020-09-03 12:44:37 +00:00
|
|
|
push %rdi
|
|
|
|
push %rsi
|
|
|
|
mov %r12,%rdi
|
|
|
|
mov %r13,%rsi
|
|
|
|
mov %r14,%rdx
|
|
|
|
mov %r15,%rcx
|
|
|
|
call __asan_init
|
|
|
|
pop %rsi
|
|
|
|
pop %rdi
|
Introduce --strace flag for system call tracing
This is similar to the --ftrace (c function call trace) flag, except
it's less noisy since it only logs system calls to stderr. Having this
flag is valuable because (1) system call tracing tells us a lot about
the behavior of complex programs and (2) it's usually very hard to get
system call tracing on various operating systems, e.g. strace, ktrace,
dtruss, truss, nttrace, etc. Especially on Apple platforms where even
with the special boot trick, debuggers still aren't guaranteed to work.
make -j8 o//examples
o//examples/hello.com --strace
This is enabled by default in MODE=, MODE=opt, and MODE=dbg. In MODE=dbg
extra information will be printed.
make -j8 MODE=dbg o/dbg/examples
o/dbg/examples/hello.com --strace |& less
This change also changes:
- Rename IsText() → _istext()
- Rename IsUtf8() → _isutf8()
- Fix madvise() on Windows NT
- Fix empty string case of inet_ntop()
- vfork() wrapper now saves and restores errno
- Update xsigaction() to yoink syscall support
2022-03-19 01:07:28 +00:00
|
|
|
.init.end 303,_init_asan
|
2020-06-15 14:18:57 +00:00
|
|
|
|
2021-02-03 14:22:51 +00:00
|
|
|
__asan_before_dynamic_init:
|
|
|
|
push %rbp
|
|
|
|
mov %rsp,%rbp
|
|
|
|
ud2
|
|
|
|
.endfn __asan_before_dynamic_init,globl
|
2020-09-03 12:44:37 +00:00
|
|
|
|
2021-02-03 14:22:51 +00:00
|
|
|
__asan_after_dynamic_init:
|
|
|
|
push %rbp
|
|
|
|
mov %rsp,%rbp
|
|
|
|
ud2
|
|
|
|
.endfn __asan_after_dynamic_init,globl
|
|
|
|
|
|
|
|
__asan_load1:
|
|
|
|
push %rbp
|
|
|
|
mov %rsp,%rbp
|
|
|
|
ud2
|
|
|
|
.endfn __asan_load1,globl
|
2021-05-14 12:36:58 +00:00
|
|
|
|
2021-02-03 14:22:51 +00:00
|
|
|
__asan_load2:
|
|
|
|
push %rbp
|
|
|
|
mov %rsp,%rbp
|
|
|
|
ud2
|
|
|
|
.endfn __asan_load2,globl
|
2021-05-14 12:36:58 +00:00
|
|
|
|
2021-02-03 14:22:51 +00:00
|
|
|
__asan_load4:
|
|
|
|
push %rbp
|
|
|
|
mov %rsp,%rbp
|
|
|
|
ud2
|
|
|
|
.endfn __asan_load4,globl
|
2021-05-14 12:36:58 +00:00
|
|
|
|
2021-02-03 14:22:51 +00:00
|
|
|
__asan_load8:
|
|
|
|
push %rbp
|
|
|
|
mov %rsp,%rbp
|
|
|
|
ud2
|
|
|
|
.endfn __asan_load8,globl
|
2021-05-14 12:36:58 +00:00
|
|
|
|
2021-02-03 14:22:51 +00:00
|
|
|
__asan_load16:
|
|
|
|
push %rbp
|
|
|
|
mov %rsp,%rbp
|
|
|
|
ud2
|
|
|
|
.endfn __asan_load16,globl
|
2021-05-14 12:36:58 +00:00
|
|
|
|
2021-02-03 14:22:51 +00:00
|
|
|
__asan_load32:
|
|
|
|
push %rbp
|
|
|
|
mov %rsp,%rbp
|
|
|
|
ud2
|
|
|
|
.endfn __asan_load32,globl
|
|
|
|
|
|
|
|
__asan_store1:
|
|
|
|
push %rbp
|
|
|
|
mov %rsp,%rbp
|
|
|
|
ud2
|
|
|
|
.endfn __asan_store1,globl
|
2021-05-14 12:36:58 +00:00
|
|
|
|
2021-02-03 14:22:51 +00:00
|
|
|
__asan_store2:
|
|
|
|
push %rbp
|
|
|
|
mov %rsp,%rbp
|
|
|
|
ud2
|
|
|
|
.endfn __asan_store2,globl
|
2021-05-14 12:36:58 +00:00
|
|
|
|
2021-02-03 14:22:51 +00:00
|
|
|
__asan_store4:
|
|
|
|
push %rbp
|
|
|
|
mov %rsp,%rbp
|
|
|
|
ud2
|
|
|
|
.endfn __asan_store4,globl
|
2021-05-14 12:36:58 +00:00
|
|
|
|
2021-02-03 14:22:51 +00:00
|
|
|
__asan_store8:
|
|
|
|
push %rbp
|
|
|
|
mov %rsp,%rbp
|
|
|
|
ud2
|
|
|
|
.endfn __asan_store8,globl
|
2021-05-14 12:36:58 +00:00
|
|
|
|
2021-02-03 14:22:51 +00:00
|
|
|
__asan_store16:
|
|
|
|
push %rbp
|
|
|
|
mov %rsp,%rbp
|
|
|
|
ud2
|
|
|
|
.endfn __asan_store16,globl
|
2021-05-14 12:36:58 +00:00
|
|
|
|
2021-02-03 14:22:51 +00:00
|
|
|
__asan_store32:
|
|
|
|
push %rbp
|
|
|
|
mov %rsp,%rbp
|
|
|
|
ud2
|
|
|
|
.endfn __asan_store32,globl
|