mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 00:02:28 +00:00
Get llama.com building as an aarch64 native binary
This commit is contained in:
parent
d04430f4ef
commit
4c093155a3
40 changed files with 7842 additions and 11683 deletions
|
@ -1,33 +0,0 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ 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. │
|
||||
│ │
|
||||
│ 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. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dns/hoststxt.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
||||
/**
|
||||
* Frees HOSTS.TXT data structure populated by ParseHostsTxt().
|
||||
*/
|
||||
void FreeHostsTxt(struct HostsTxt **ht) {
|
||||
if (*ht) {
|
||||
free((*ht)->entries.p);
|
||||
free((*ht)->strings.p);
|
||||
free(*ht);
|
||||
*ht = 0;
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@
|
|||
#include "libc/intrin/pushpop.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nt/systeminfo.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
@ -85,3 +86,21 @@ const struct HostsTxt *GetHostsTxt(void) {
|
|||
pthread_mutex_unlock(&init->lock);
|
||||
return g_hoststxt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees HOSTS.TXT data structure populated by ParseHostsTxt().
|
||||
*/
|
||||
void FreeHostsTxt(struct HostsTxt **ht) {
|
||||
if (*ht) {
|
||||
if ((*ht)->entries.p != g_hoststxt_init.entries) {
|
||||
free((*ht)->entries.p);
|
||||
}
|
||||
if ((*ht)->strings.p != g_hoststxt_init.strings) {
|
||||
free((*ht)->strings.p);
|
||||
}
|
||||
if (*ht != &g_hoststxt_init.ht) {
|
||||
free(*ht);
|
||||
}
|
||||
*ht = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -175,6 +175,36 @@
|
|||
#define R_X86_64_REX_GOTPCRELX 42 /* 7 bytes */
|
||||
#define R_X86_64_NUM 43
|
||||
|
||||
#define R_AARCH64_NONE 0
|
||||
#define R_AARCH64_ABS64 257
|
||||
#define R_AARCH64_ABS32 258
|
||||
#define R_AARCH64_ABS16 259
|
||||
#define R_AARCH64_PREL64 260
|
||||
#define R_AARCH64_PREL32 261
|
||||
#define R_AARCH64_PREL16 262
|
||||
|
||||
#define R_PPC_NONE 0
|
||||
#define R_PPC_ADDR32 1
|
||||
#define R_PPC_ADDR24 2
|
||||
#define R_PPC_ADDR16 3
|
||||
|
||||
#define R_PPC64_NONE R_PPC_NONE
|
||||
#define R_PPC64_ADDR32 R_PPC_ADDR32
|
||||
#define R_PPC64_ADDR24 R_PPC_ADDR24
|
||||
#define R_PPC64_ADDR16 R_PPC_ADDR16
|
||||
|
||||
#define R_RISCV_NONE 0
|
||||
#define R_RISCV_32 1
|
||||
#define R_RISCV_64 2
|
||||
#define R_RISCV_RELATIVE 3
|
||||
|
||||
#define R_390_NONE 0
|
||||
#define R_390_8 1
|
||||
#define R_390_12 2
|
||||
#define R_390_16 3
|
||||
#define R_390_32 4
|
||||
#define R_390_PC32 5
|
||||
|
||||
#define STB_LOCAL 0
|
||||
#define STB_GLOBAL 1
|
||||
#define STB_WEAK 2
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2022 Justine Alexandra Roberts Tunney │
|
||||
│ Copyright 2023 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
|
@ -16,6 +16,13 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/thread/thread.h"
|
||||
#include "libc/intrin/intrin.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
|
||||
pthread_mutex_t __mmi_lock_obj; // recursive :'(
|
||||
void __cxa_pure_virtual(void) {
|
||||
#ifndef NDEBUG
|
||||
kprintf("__cxa_pure_virtual() called\n"
|
||||
"Did you call a virtual method from a destructor?\n");
|
||||
#endif
|
||||
__builtin_trap();
|
||||
}
|
|
@ -23,6 +23,7 @@
|
|||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/intrin/directmap.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/likely.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/log/libfatal.internal.h"
|
||||
|
|
|
@ -16,8 +16,18 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/runtime/memtrack.internal.h"
|
||||
|
||||
STATIC_YOINK("_init__mmi");
|
||||
#include "libc/thread/thread.h"
|
||||
|
||||
struct MemoryIntervals _mmi;
|
||||
pthread_mutex_t __mmi_lock_obj; // recursive :'(
|
||||
|
||||
__attribute__((__constructor__)) void __mmi_init(void) {
|
||||
static bool once;
|
||||
if (once) return;
|
||||
_mmi.n = ARRAYLEN(_mmi.s);
|
||||
_mmi.p = _mmi.s;
|
||||
__mmi_lock_obj._type = PTHREAD_MUTEX_RECURSIVE;
|
||||
once = true;
|
||||
}
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
/*-*- 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 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ 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. │
|
||||
│ │
|
||||
│ 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. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/thread/thread.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
.init.start 200,_init__mmi
|
||||
movb $OPEN_MAX,_mmi+8
|
||||
movl $_mmi+24,_mmi+16
|
||||
movb $PTHREAD_MUTEX_RECURSIVE,__mmi_lock_obj+4(%rip)
|
||||
.init.end 200,_init__mmi
|
|
@ -26,6 +26,8 @@
|
|||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
static double GetTotal(const struct countbranch *p) {
|
||||
return p->total;
|
||||
}
|
||||
|
@ -101,3 +103,5 @@ static textstartup void countbranch_init() {
|
|||
const void *const countbranch_ctor[] initarray = {
|
||||
countbranch_init,
|
||||
};
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
static long GetLongSum(const long *h, size_t n) {
|
||||
long t;
|
||||
size_t i;
|
||||
|
@ -80,3 +82,5 @@ static textstartup void countexpr_init() {
|
|||
const void *const countexpr_ctor[] initarray = {
|
||||
countexpr_init,
|
||||
};
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -43,6 +43,7 @@ LIBC_LOG_A_DIRECTDEPS = \
|
|||
LIBC_TIME \
|
||||
LIBC_TINYMATH \
|
||||
LIBC_ZIPOS \
|
||||
THIRD_PARTY_COMPILER_RT \
|
||||
THIRD_PARTY_DLMALLOC \
|
||||
THIRD_PARTY_GDTOA
|
||||
|
||||
|
|
|
@ -47,6 +47,8 @@
|
|||
#include "libc/thread/tls.h"
|
||||
#include "third_party/libcxx/math.h"
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
/**
|
||||
* @fileoverview Abnormal termination handling & GUI debugging.
|
||||
* @see libc/onkill.c
|
||||
|
@ -361,3 +363,5 @@ ItsATrap:
|
|||
strace_enabled(+1);
|
||||
ftrace_enabled(+1);
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/sysv/consts/ss.h"
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
STATIC_YOINK("zipos"); // for symtab
|
||||
STATIC_YOINK("__die"); // for backtracing
|
||||
STATIC_YOINK("ShowBacktrace"); // for backtracing
|
||||
|
@ -123,3 +125,8 @@ void ShowCrashReports(void) {
|
|||
}
|
||||
GetSymbolTable();
|
||||
}
|
||||
|
||||
#else
|
||||
void ShowCrashReports(void) {
|
||||
}
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include "libc/runtime/symbols.internal.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
static bool __watch_busy;
|
||||
static void *__watch_addr;
|
||||
static size_t __watch_size;
|
||||
|
@ -85,3 +87,5 @@ int __watch(void *addr, size_t size) {
|
|||
Copy(__watch_last, __watch_addr, __watch_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -175,6 +175,13 @@
|
|||
#endif
|
||||
.endm
|
||||
|
||||
// Embeds Fixed-Width Zero-Padded String.
|
||||
// @note .fxstr is better
|
||||
.macro .ascin str:req fieldsize:req
|
||||
1347: .ascii "\str"
|
||||
.org 1347b+\fieldsize,0x00
|
||||
.endm
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
#if __MNO_VZEROUPPER__ + 0
|
||||
|
@ -297,13 +304,6 @@
|
|||
.endif
|
||||
.endm
|
||||
|
||||
// Embeds Fixed-Width Zero-Padded String.
|
||||
// @note .fxstr is better
|
||||
.macro .ascin str:req fieldsize:req
|
||||
1347: .ascii "\str"
|
||||
.org 1347b+\fieldsize,0x00
|
||||
.endm
|
||||
|
||||
// Marks symbols as object en-masse.
|
||||
// @note zero-padded ≠ nul-terminated
|
||||
.macro .object symbol rest:vararg
|
||||
|
|
|
@ -1,84 +0,0 @@
|
|||
/*-*- 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 │
|
||||
│ │
|
||||
│ 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. │
|
||||
│ │
|
||||
│ 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. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
// Frees memory the C++ way.
|
||||
//
|
||||
// \param %rdi is pointer, or NULL for no-op
|
||||
// \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
|
||||
// 𝑠𝑙𝑖𝑑𝑒
|
||||
.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
|
|
@ -1,47 +0,0 @@
|
|||
/*-*- 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 │
|
||||
│ │
|
||||
│ 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. │
|
||||
│ │
|
||||
│ 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. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
// Allocates memory the C++ way.
|
||||
//
|
||||
// \param %rdi is bytes to allocate
|
||||
// \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
|
||||
// 𝑠𝑙𝑖𝑑𝑒
|
||||
.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,weak
|
|
@ -1,52 +0,0 @@
|
|||
/*-*- 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 │
|
||||
│ │
|
||||
│ 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. │
|
||||
│ │
|
||||
│ 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. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
// Allocates aligned memory the C++ way.
|
||||
//
|
||||
// \param %rdi is bytes to allocate
|
||||
// \param %rsi is byte alignment
|
||||
// \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
|
||||
1: mov $__BIGGEST_ALIGNMENT__,%eax
|
||||
cmp %rax,%rsi
|
||||
cmovb %rax,%rsi
|
||||
xchg %rdi,%rsi
|
||||
jmp *hook_memalign(%rip)
|
||||
.endfn _ZnamSt11align_val_t,weak
|
|
@ -6,14 +6,11 @@ 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 = $(filter %.c,$(LIBC_MEM_A_FILES))
|
||||
LIBC_MEM_A_OBJS = $(LIBC_MEM_A_SRCS:%.c=o/$(MODE)/%.o)
|
||||
|
||||
LIBC_MEM_A_FILES := \
|
||||
$(wildcard libc/mem/*) \
|
||||
$(wildcard libc/mem/cxx/*)
|
||||
|
||||
LIBC_MEM_A_CHECKS = \
|
||||
$(LIBC_MEM_A).pkg \
|
||||
$(LIBC_MEM_A_HDRS:%=o/$(MODE)/%.ok)
|
||||
|
|
|
@ -48,6 +48,8 @@ o/$(MODE)/libc/nexgen32e/threaded.o: private \
|
|||
-fno-sanitize=all
|
||||
|
||||
# these assembly files are safe to build on aarch64
|
||||
o/$(MODE)/libc/nexgen32e/zip.o: libc/nexgen32e/zip.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
o/$(MODE)/libc/nexgen32e/mcount.o: libc/nexgen32e/mcount.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
o/$(MODE)/libc/nexgen32e/ksha256.o: libc/nexgen32e/ksha256.S
|
||||
|
|
|
@ -32,14 +32,14 @@ __zip_start:
|
|||
...
|
||||
*/.section .zip.5,"",@progbits
|
||||
__zip_end:
|
||||
.long kZipCdirHdrMagic # magic
|
||||
.short 0 # disk
|
||||
.short 0 # starting disk
|
||||
.short v_zip_records # number of records on disk
|
||||
.short v_zip_records # records
|
||||
.long v_zip_cdirsize # size of central directory
|
||||
.long RVA(__zip_start) # central directory offset
|
||||
.short v_zip_commentsize # comment size
|
||||
.long kZipCdirHdrMagic // magic
|
||||
.short 0 // disk
|
||||
.short 0 // starting disk
|
||||
.short v_zip_records // number of records on disk
|
||||
.short v_zip_records // records
|
||||
.long v_zip_cdirsize // size of central directory
|
||||
.long RVA(__zip_start) // central directory offset
|
||||
.short v_zip_commentsize // comment size
|
||||
.endobj __zip_end,globl,hidden
|
||||
.weak v_zip_records
|
||||
.weak v_zip_cdirsize
|
||||
|
|
|
@ -141,6 +141,7 @@ cosmo: push %rbp
|
|||
push %rsi
|
||||
|
||||
// allocate stack
|
||||
call __mmi_init
|
||||
movabs $ape_stack_vaddr,%rdi
|
||||
mov $ape_stack_memsz,%esi
|
||||
mov $ape_stack_prot,%edx
|
||||
|
|
|
@ -45,6 +45,7 @@ struct MemoryIntervals {
|
|||
|
||||
extern struct MemoryIntervals _mmi;
|
||||
|
||||
void __mmi_init(void);
|
||||
void __mmi_lock(void);
|
||||
void __mmi_unlock(void);
|
||||
void __mmi_funlock(void);
|
||||
|
|
|
@ -122,6 +122,8 @@ o/$(MODE)/libc/runtime/clone-linux.o: libc/runtime/clone-linux.S
|
|||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
o/$(MODE)/libc/runtime/ftrace-hook.o: libc/runtime/ftrace-hook.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
o/$(MODE)/libc/runtime/dsohandle.o: libc/runtime/dsohandle.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
|
||||
LIBC_RUNTIME_LIBS = $(foreach x,$(LIBC_RUNTIME_ARTIFACTS),$($(x)))
|
||||
LIBC_RUNTIME_SRCS = $(foreach x,$(LIBC_RUNTIME_ARTIFACTS),$($(x)_SRCS))
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
/*-*- 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 │
|
||||
│ │
|
||||
│ 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. │
|
||||
│ │
|
||||
│ 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. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
// Did you call a virtual method from a destructor?
|
||||
__cxa_pure_virtual:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
call abort
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn __cxa_pure_virtual,globl
|
|
@ -40,7 +40,8 @@ LIBC_TIME_A_DIRECTDEPS = \
|
|||
LIBC_STUBS \
|
||||
LIBC_SYSV \
|
||||
LIBC_SYSV_CALLS \
|
||||
LIBC_ZIPOS
|
||||
LIBC_ZIPOS \
|
||||
THIRD_PARTY_COMPILER_RT
|
||||
|
||||
LIBC_TIME_A_DEPS := \
|
||||
$(call uniq,$(foreach x,$(LIBC_TIME_A_DIRECTDEPS),$($(x))))
|
||||
|
@ -72,6 +73,15 @@ o/$(MODE)/libc/time/iso8601us.o: private \
|
|||
o/$(MODE)/usr/share/zoneinfo/.zip.o: \
|
||||
usr/share/zoneinfo
|
||||
|
||||
o/$(MODE)/libc/time/kmonthname.o: libc/time/kmonthname.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
o/$(MODE)/libc/time/kmonthnameshort.o: libc/time/kmonthnameshort.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
o/$(MODE)/libc/time/kweekdayname.o: libc/time/kweekdayname.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
o/$(MODE)/libc/time/kweekdaynameshort.o: libc/time/kweekdaynameshort.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
|
||||
LIBC_TIME_LIBS = $(foreach x,$(LIBC_TIME_ARTIFACTS),$($(x)))
|
||||
LIBC_TIME_SRCS = $(foreach x,$(LIBC_TIME_ARTIFACTS),$($(x)_SRCS))
|
||||
LIBC_TIME_HDRS = $(foreach x,$(LIBC_TIME_ARTIFACTS),$($(x)_HDRS))
|
||||
|
|
|
@ -57,6 +57,10 @@ o/$(MODE)/libc/zipos/.cosmo.zip.o: private \
|
|||
ZIPOBJ_FLAGS += \
|
||||
-B
|
||||
|
||||
# these assembly files are safe to build on aarch64
|
||||
o/$(MODE)/libc/zipos/zipos.o: libc/zipos/zipos.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
|
||||
LIBC_ZIPOS_LIBS = $(foreach zipos,$(LIBC_ZIPOS_ARTIFACTS),$($(zipos)))
|
||||
LIBC_ZIPOS_SRCS = $(foreach zipos,$(LIBC_ZIPOS_ARTIFACTS),$($(zipos)_SRCS))
|
||||
LIBC_ZIPOS_HDRS = $(foreach zipos,$(LIBC_ZIPOS_ARTIFACTS),$($(zipos)_HDRS))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue