mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-28 05:20:28 +00:00
Get address sanitizer mostly working
This commit is contained in:
parent
1f1f3cd477
commit
7327c345f9
149 changed files with 3777 additions and 3457 deletions
|
@ -26,34 +26,61 @@
|
|||
/ @param %rsi is ignored
|
||||
/ @param %rdx is ignored
|
||||
_ZdlPvSt11align_val_tRKSt9nothrow_t:
|
||||
/ operator delete(void*, std::align_val_t, std::nothrow_t const&)
|
||||
nop
|
||||
/ 𝑠𝑙𝑖𝑑𝑒
|
||||
.endfn _ZdlPvSt11align_val_tRKSt9nothrow_t,weak
|
||||
_ZdaPvSt11align_val_tRKSt9nothrow_t:
|
||||
/ operator delete[](void*, std::align_val_t, std::nothrow_t const&)
|
||||
nop
|
||||
/ 𝑠𝑙𝑖𝑑𝑒
|
||||
.endfn _ZdaPvSt11align_val_tRKSt9nothrow_t,weak
|
||||
_ZdlPvRKSt9nothrow_t:
|
||||
/ operator delete(void*, std::nothrow_t const&)
|
||||
nop
|
||||
/ 𝑠𝑙𝑖𝑑𝑒
|
||||
.endfn _ZdlPvRKSt9nothrow_t,weak
|
||||
_ZdaPvRKSt9nothrow_t:
|
||||
/ operator delete[](void*, std::nothrow_t const&)
|
||||
nop
|
||||
/ 𝑠𝑙𝑖𝑑𝑒
|
||||
.endfn _ZdaPvRKSt9nothrow_t,weak
|
||||
_ZdlPvmSt11align_val_t:
|
||||
/ operator delete(void*, unsigned long, std::align_val_t)
|
||||
nop
|
||||
/ 𝑠𝑙𝑖𝑑𝑒
|
||||
.endfn _ZdlPvmSt11align_val_t,weak
|
||||
_ZdaPvmSt11align_val_t:
|
||||
/ operator delete[](void*, unsigned long, std::align_val_t)
|
||||
nop
|
||||
/ 𝑠𝑙𝑖𝑑𝑒
|
||||
.endfn _ZdaPvmSt11align_val_t,weak
|
||||
_ZdlPvSt11align_val_t:
|
||||
/ operator delete(void*, std::align_val_t)
|
||||
nop
|
||||
/ 𝑠𝑙𝑖𝑑𝑒
|
||||
.endfn _ZdlPvSt11align_val_t,weak
|
||||
_ZdaPvSt11align_val_t:
|
||||
/ operator delete[](void*, std::align_val_t)
|
||||
nop
|
||||
_ZdaPvm:nop
|
||||
_ZdlPvm:nop
|
||||
_ZdaPv: nop
|
||||
_ZdlPv: jmp *hook$free(%rip)
|
||||
.endfn _ZdlPv,globl,weak
|
||||
.endfn _ZdaPv,globl,weak
|
||||
.endfn _ZdaPvm,globl,weak
|
||||
.endfn _ZdlPvm,globl,weak
|
||||
.endfn _ZdaPvRKSt9nothrow_t,globl,weak
|
||||
.endfn _ZdlPvRKSt9nothrow_t,globl,weak
|
||||
.endfn _ZdaPvSt11align_val_t,globl,weak
|
||||
.endfn _ZdlPvSt11align_val_t,globl,weak
|
||||
.endfn _ZdaPvmSt11align_val_t,globl,weak
|
||||
.endfn _ZdlPvmSt11align_val_t,globl,weak
|
||||
.endfn _ZdlPvSt11align_val_tRKSt9nothrow_t,globl,weak
|
||||
.endfn _ZdaPvSt11align_val_tRKSt9nothrow_t,globl,weak
|
||||
/ 𝑠𝑙𝑖𝑑𝑒
|
||||
.endfn _ZdaPvSt11align_val_t,weak
|
||||
_ZdaPvm:
|
||||
/ operator delete[](void*, unsigned long):
|
||||
nop
|
||||
/ 𝑠𝑙𝑖𝑑𝑒
|
||||
.endfn _ZdaPvm,weak
|
||||
_ZdlPvm:
|
||||
/ operator delete(void*, unsigned long)
|
||||
nop
|
||||
/ 𝑠𝑙𝑖𝑑𝑒
|
||||
.endfn _ZdlPvm,weak
|
||||
_ZdaPv:
|
||||
/ operator delete[](void*)
|
||||
nop
|
||||
/ 𝑠𝑙𝑖𝑑𝑒
|
||||
.endfn _ZdaPv,weak
|
||||
_ZdlPv:
|
||||
/ operator delete(void*)
|
||||
jmp *hook$free(%rip)
|
||||
.endfn _ZdlPv,weak
|
|
@ -26,15 +26,24 @@
|
|||
/ @param %rsi is ignored
|
||||
/ @return new memory or NULL on OOM
|
||||
_ZnamRKSt9nothrow_t:
|
||||
/ operator new[](unsigned long, std::nothrow_t const&)
|
||||
nop
|
||||
/ 𝑠𝑙𝑖𝑑𝑒
|
||||
.endfn _ZnamRKSt9nothrow_t,weak
|
||||
_ZnwmRKSt9nothrow_t:
|
||||
/ operator new(unsigned long, std::nothrow_t const&)
|
||||
nop
|
||||
_Znam: nop
|
||||
_Znwm: test %rdi,%rdi
|
||||
/ 𝑠𝑙𝑖𝑑𝑒
|
||||
.endfn _ZnwmRKSt9nothrow_t,weak
|
||||
_Znam:
|
||||
/ operator new[](unsigned long)
|
||||
nop
|
||||
/ 𝑠𝑙𝑖𝑑𝑒
|
||||
.endfn _Znam,weak
|
||||
_Znwm:
|
||||
/ operator new(unsigned long)
|
||||
test %rdi,%rdi
|
||||
jne 1f
|
||||
mov $1,%edi
|
||||
1: jmp *hook$malloc(%rip)
|
||||
.endfn _Znwm,globl,weak
|
||||
.endfn _Znam,globl,weak
|
||||
.endfn _ZnwmRKSt9nothrow_t,globl,weak
|
||||
.endfn _ZnamRKSt9nothrow_t,globl,weak
|
||||
.endfn _Znwm,weak
|
|
@ -27,12 +27,22 @@
|
|||
/ @param %rdx is ignored
|
||||
/ @return new memory or NULL on OOM
|
||||
_ZnamSt11align_val_tRKSt9nothrow_t:
|
||||
/ operator new[](unsigned long, std::align_val_t, std::nothrow_t const&)
|
||||
nop
|
||||
/ 𝑠𝑙𝑖𝑑𝑒
|
||||
.endfn _ZnamSt11align_val_tRKSt9nothrow_t,weak
|
||||
_ZnwmSt11align_val_tRKSt9nothrow_t:
|
||||
/ operator new(unsigned long, std::align_val_t, std::nothrow_t const&)
|
||||
nop
|
||||
/ 𝑠𝑙𝑖𝑑𝑒
|
||||
.endfn _ZnwmSt11align_val_tRKSt9nothrow_t,weak
|
||||
_ZnwmSt11align_val_t:
|
||||
/ operator new(unsigned long, std::align_val_t)
|
||||
nop
|
||||
/ 𝑠𝑙𝑖𝑑𝑒
|
||||
.endfn _ZnwmSt11align_val_t,weak
|
||||
_ZnamSt11align_val_t:
|
||||
/ operator new[](unsigned long, std::align_val_t)
|
||||
test %rdi,%rdi
|
||||
jnz 1f
|
||||
mov $1,%eax
|
||||
|
@ -41,7 +51,4 @@ _ZnamSt11align_val_t:
|
|||
cmovb %rax,%rsi
|
||||
xchg %rdi,%rsi
|
||||
jmp *hook$memalign(%rip)
|
||||
.endfn _ZnwmSt11align_val_t,globl,weak
|
||||
.endfn _ZnamSt11align_val_t,globl,weak
|
||||
.endfn _ZnamSt11align_val_tRKSt9nothrow_t,globl,weak
|
||||
.endfn _ZnwmSt11align_val_tRKSt9nothrow_t,globl,weak
|
||||
.endfn _ZnamSt11align_val_t,weak
|
|
@ -20,15 +20,15 @@
|
|||
#include "libc/macros.h"
|
||||
.source __FILE__
|
||||
|
||||
.initbss 800,_init_calloc
|
||||
.initbss 202,_init_calloc
|
||||
hook$calloc:
|
||||
.quad 0
|
||||
.endobj hook$calloc,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 800,_init_calloc
|
||||
.init.start 202,_init_calloc
|
||||
.hidden dlcalloc
|
||||
ezlea dlcalloc,ax
|
||||
stosq
|
||||
yoink free
|
||||
.init.end 800,_init_calloc
|
||||
.init.end 202,_init_calloc
|
|
@ -20,16 +20,16 @@
|
|||
#include "libc/macros.h"
|
||||
.source __FILE__
|
||||
|
||||
.initbss 800,_init_free
|
||||
.initbss 202,_init_free
|
||||
hook$free:
|
||||
.quad 0
|
||||
.endobj hook$free,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 800,_init_free
|
||||
.init.start 202,_init_free
|
||||
ezlea dlfree,ax
|
||||
stosq
|
||||
yoink realloc
|
||||
.init.end 800,_init_free
|
||||
.init.end 202,_init_free
|
||||
|
||||
.hidden dlfree
|
18
libc/mem/hook/hook.h
Normal file
18
libc/mem/hook/hook.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_MEM_HOOK_HOOK_H_
|
||||
#define COSMOPOLITAN_LIBC_MEM_HOOK_HOOK_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
extern void (*hook$free)(void *);
|
||||
extern void *(*hook$malloc)(size_t);
|
||||
extern void *(*hook$calloc)(size_t, size_t);
|
||||
extern void *(*hook$memalign)(size_t, size_t);
|
||||
extern void *(*hook$realloc)(void *, size_t);
|
||||
extern void *(*hook$realloc_in_place)(void *, size_t);
|
||||
extern void *(*hook$valloc)(size_t);
|
||||
extern void *(*hook$pvalloc)(size_t);
|
||||
extern size_t (*hook$malloc_usable_size)(const void *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_MEM_HOOK_HOOK_H_ */
|
|
@ -20,16 +20,15 @@
|
|||
#include "libc/macros.h"
|
||||
.source __FILE__
|
||||
|
||||
.initbss 800,_init_malloc
|
||||
.initbss 202,_init_malloc
|
||||
hook$malloc:
|
||||
.quad 0
|
||||
.endobj hook$malloc,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 800,_init_malloc
|
||||
.init.start 202,_init_malloc
|
||||
.hidden dlmalloc
|
||||
ezlea dlmalloc,ax
|
||||
stosq
|
||||
yoink free
|
||||
.init.end 800,_init_malloc
|
||||
|
||||
.hidden dlmalloc
|
||||
.init.end 202,_init_malloc
|
33
libc/mem/hook/malloc_usable_size.S
Normal file
33
libc/mem/hook/malloc_usable_size.S
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.source __FILE__
|
||||
|
||||
.initbss 202,_init_malloc_usable_size
|
||||
hook$malloc_usable_size:
|
||||
.quad 0
|
||||
.endobj hook$malloc_usable_size,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 202,_init_malloc_usable_size
|
||||
.hidden dlmalloc_usable_size
|
||||
ezlea dlmalloc_usable_size,ax
|
||||
stosq
|
||||
.init.end 202,_init_malloc_usable_size
|
|
@ -20,16 +20,15 @@
|
|||
#include "libc/macros.h"
|
||||
.source __FILE__
|
||||
|
||||
.initbss 800,_init_memalign
|
||||
.initbss 202,_init_memalign
|
||||
hook$memalign:
|
||||
.quad 0
|
||||
.endobj hook$memalign,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 800,_init_memalign
|
||||
.init.start 202,_init_memalign
|
||||
.hidden dlmemalign
|
||||
ezlea dlmemalign,ax
|
||||
stosq
|
||||
yoink free
|
||||
.init.end 800,_init_memalign
|
||||
|
||||
.hidden dlmemalign
|
||||
.init.end 202,_init_memalign
|
34
libc/mem/hook/posix_memalign.S
Normal file
34
libc/mem/hook/posix_memalign.S
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.source __FILE__
|
||||
|
||||
.initbss 202,_init_posix_memalign
|
||||
hook$posix_memalign:
|
||||
.quad 0
|
||||
.endobj hook$posix_memalign,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 202,_init_posix_memalign
|
||||
.hidden dlposix_memalign
|
||||
ezlea dlposix_memalign,ax
|
||||
stosq
|
||||
yoink free
|
||||
.init.end 202,_init_posix_memalign
|
34
libc/mem/hook/pvalloc.S
Normal file
34
libc/mem/hook/pvalloc.S
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.source __FILE__
|
||||
|
||||
.initbss 202,_init_pvalloc
|
||||
hook$pvalloc:
|
||||
.quad 0
|
||||
.endobj hook$pvalloc,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 202,_init_pvalloc
|
||||
.hidden dlpvalloc
|
||||
ezlea dlpvalloc,ax
|
||||
stosq
|
||||
yoink free
|
||||
.init.end 202,_init_pvalloc
|
|
@ -20,15 +20,15 @@
|
|||
#include "libc/macros.h"
|
||||
.source __FILE__
|
||||
|
||||
.initbss 800,_init_realloc
|
||||
.initbss 202,_init_realloc
|
||||
hook$realloc:
|
||||
.quad 0
|
||||
.endobj hook$realloc,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 800,_init_realloc
|
||||
.init.start 202,_init_realloc
|
||||
.hidden dlrealloc
|
||||
ezlea dlrealloc,ax
|
||||
stosq
|
||||
yoink free
|
||||
.init.end 800,_init_realloc
|
||||
.init.end 202,_init_realloc
|
34
libc/mem/hook/realloc_in_place.S
Normal file
34
libc/mem/hook/realloc_in_place.S
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.source __FILE__
|
||||
|
||||
.initbss 202,_init_realloc_in_place
|
||||
hook$realloc_in_place:
|
||||
.quad 0
|
||||
.endobj hook$realloc_in_place,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 202,_init_realloc_in_place
|
||||
.hidden dlrealloc_in_place
|
||||
ezlea dlrealloc_in_place,ax
|
||||
stosq
|
||||
yoink free
|
||||
.init.end 202,_init_realloc_in_place
|
34
libc/mem/hook/valloc.S
Normal file
34
libc/mem/hook/valloc.S
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.source __FILE__
|
||||
|
||||
.initbss 202,_init_valloc
|
||||
hook$valloc:
|
||||
.quad 0
|
||||
.endobj hook$valloc,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 202,_init_valloc
|
||||
.hidden dlvalloc
|
||||
ezlea dlvalloc,ax
|
||||
stosq
|
||||
yoink free
|
||||
.init.end 202,_init_valloc
|
|
@ -39,4 +39,3 @@
|
|||
/ @see dlmalloc()
|
||||
malloc: jmp *hook$malloc(%rip)
|
||||
.endfn malloc,globl
|
||||
|
||||
|
|
|
@ -40,14 +40,3 @@
|
|||
malloc_usable_size:
|
||||
jmp *hook$malloc_usable_size(%rip)
|
||||
.endfn malloc_usable_size,globl
|
||||
|
||||
.initbss 800,_init_malloc_usable_size
|
||||
hook$malloc_usable_size:
|
||||
.quad 0
|
||||
.endobj hook$malloc_usable_size,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 800,_init_malloc_usable_size
|
||||
ezlea dlmalloc_usable_size,ax
|
||||
stosq
|
||||
.init.end 800,_init_malloc_usable_size
|
||||
|
|
|
@ -6,11 +6,15 @@ PKGS += LIBC_MEM
|
|||
LIBC_MEM_ARTIFACTS += LIBC_MEM_A
|
||||
LIBC_MEM = $(LIBC_MEM_A_DEPS) $(LIBC_MEM_A)
|
||||
LIBC_MEM_A = o/$(MODE)/libc/mem/mem.a
|
||||
LIBC_MEM_A_FILES := $(wildcard libc/mem/*)
|
||||
LIBC_MEM_A_HDRS = $(filter %.h,$(LIBC_MEM_A_FILES))
|
||||
LIBC_MEM_A_SRCS_S = $(filter %.S,$(LIBC_MEM_A_FILES))
|
||||
LIBC_MEM_A_SRCS_C = $(filter %.c,$(LIBC_MEM_A_FILES))
|
||||
|
||||
LIBC_MEM_A_FILES := \
|
||||
$(wildcard libc/mem/*) \
|
||||
$(wildcard libc/mem/cxx/*) \
|
||||
$(wildcard libc/mem/hook/*)
|
||||
|
||||
LIBC_MEM_A_SRCS = \
|
||||
$(LIBC_MEM_A_SRCS_S) \
|
||||
$(LIBC_MEM_A_SRCS_C)
|
||||
|
|
|
@ -35,17 +35,3 @@
|
|||
posix_memalign:
|
||||
jmp *hook$posix_memalign(%rip)
|
||||
.endfn posix_memalign,globl
|
||||
|
||||
.initbss 800,_init_posix_memalign
|
||||
hook$posix_memalign:
|
||||
.quad 0
|
||||
.endobj hook$posix_memalign,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 800,_init_posix_memalign
|
||||
.hidden dlposix_memalign
|
||||
ezlea dlposix_memalign,ax
|
||||
stosq
|
||||
.init.end 800,_init_posix_memalign
|
||||
|
||||
yoink free
|
||||
|
|
|
@ -22,24 +22,10 @@
|
|||
.source __FILE__
|
||||
|
||||
/ Equivalent to valloc(minimum-page-that-holds(n)), that is,
|
||||
/ round up n to nearest PAGESIZE.
|
||||
/ round up n to nearest pagesize.
|
||||
/
|
||||
/ @param rdi is number of bytes needed
|
||||
/ @return rax is memory address, or NULL w/ errno
|
||||
/ @see dlpvalloc()
|
||||
pvalloc:jmp *hook$pvalloc(%rip)
|
||||
.endfn pvalloc,globl
|
||||
|
||||
.initbss 800,_init_pvalloc
|
||||
hook$pvalloc:
|
||||
.quad 0
|
||||
.endobj hook$pvalloc,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 800,_init_pvalloc
|
||||
.hidden dlpvalloc
|
||||
ezlea dlpvalloc,ax
|
||||
stosq
|
||||
.init.end 800,_init_pvalloc
|
||||
|
||||
yoink free
|
||||
|
|
|
@ -55,5 +55,6 @@
|
|||
/ @note realloc(p=0, n=0) → malloc(32)
|
||||
/ @note realloc(p≠0, n=0) → free(p)
|
||||
/ @see dlrealloc()
|
||||
realloc:jmp *hook$realloc(%rip)
|
||||
realloc:
|
||||
jmp *hook$realloc(%rip)
|
||||
.endfn realloc,globl
|
||||
|
|
|
@ -23,12 +23,12 @@
|
|||
|
||||
/ Resizes the space allocated for p to size n, only if this can be
|
||||
/ done without moving p (i.e., only if there is adjacent space
|
||||
/ available if n is greater than p's current allocated size, or n is
|
||||
/ less than or equal to p's size). This may be used instead of plain
|
||||
/ realloc if an alternative allocation strategy is needed upon failure
|
||||
/ to expand space, for example, reallocation of a buffer that must be
|
||||
/ memory-aligned or cleared. You can use realloc_in_place to trigger
|
||||
/ these alternatives only when needed.
|
||||
/ available if n is greater than p's current allocated size, or n
|
||||
/ is less than or equal to p's size). This may be used instead of
|
||||
/ plain realloc if an alternative allocation strategy is needed
|
||||
/ upon failure to expand space, for example, reallocation of a
|
||||
/ buffer that must be memory-aligned or cleared. You can use
|
||||
/ realloc_in_place to trigger these alternatives only when needed.
|
||||
/
|
||||
/ @param rdi (p) is address of current allocation
|
||||
/ @param rsi (newsize) is number of bytes needed
|
||||
|
@ -37,17 +37,3 @@
|
|||
realloc_in_place:
|
||||
jmp *hook$realloc_in_place(%rip)
|
||||
.endfn realloc_in_place,globl
|
||||
|
||||
.initbss 800,_init_realloc_in_place
|
||||
hook$realloc_in_place:
|
||||
.quad 0
|
||||
.endobj hook$realloc_in_place,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 800,_init_realloc_in_place
|
||||
.hidden dlrealloc_in_place
|
||||
ezlea dlrealloc_in_place,ax
|
||||
stosq
|
||||
.init.end 800,_init_realloc_in_place
|
||||
|
||||
yoink free
|
||||
|
|
|
@ -21,24 +21,10 @@
|
|||
#include "libc/notice.inc"
|
||||
.source __FILE__
|
||||
|
||||
/ Equivalent to memalign(PAGESIZE, n).
|
||||
/ Equivalent to memalign(4096, n).
|
||||
/
|
||||
/ @param rdi is number of bytes needed
|
||||
/ @return rax is memory address, or NULL w/ errno
|
||||
/ @see dlvalloc()
|
||||
valloc: jmp *hook$valloc(%rip)
|
||||
.endfn valloc,globl
|
||||
|
||||
.initbss 800,_init_valloc
|
||||
hook$valloc:
|
||||
.quad 0
|
||||
.endobj hook$valloc,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 800,_init_valloc
|
||||
.hidden dlvalloc
|
||||
ezlea dlvalloc,ax
|
||||
stosq
|
||||
.init.end 800,_init_valloc
|
||||
|
||||
yoink free
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue