Make considerably more progress on AARCH64

- Utilities like pledge.com now build
- kprintf() will no longer balk at 48-bit addresses
- There's a new aarch64-dbg build mode that should work
- gc() and defer() are mostly pacified; avoid using them on aarch64
- THIRD_PART_STB now has Arm Neon intrinsics for fast image handling
This commit is contained in:
Justine Tunney 2023-05-12 22:42:57 -07:00
parent 1bfb3aab1b
commit fd34ef732d
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
91 changed files with 1288 additions and 1192 deletions

View file

@ -16,6 +16,7 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/assert.h"
#include "libc/calls/calls.h"
#include "libc/calls/cp.internal.h"
#include "libc/calls/internal.h"

View file

@ -1254,23 +1254,21 @@ static privileged int HasSyscall(struct Pledges *p, uint16_t n) {
static privileged void OnSigSys(int sig, siginfo_t *si, void *vctx) {
bool found;
char ord[17], rip[17];
char ord[17];
int i, ok, mode = si->si_errno;
ucontext_t *ctx = vctx;
ctx->uc_mcontext.MCONTEXT_SYSCALL_RESULT_REGISTER = -Eperm;
FixCpy(ord, si->si_syscall, 12);
HexCpy(rip, ctx->uc_mcontext.MCONTEXT_INSTRUCTION_POINTER);
for (found = i = 0; i < ARRAYLEN(kPledge); ++i) {
if (HasSyscall(kPledge + i, si->si_syscall)) {
Log("error: pledge ", kPledge[i].name, " for ",
GetSyscallName(si->si_syscall), " (ord=", ord, " rip=", rip, ")\n",
NULL);
GetSyscallName(si->si_syscall), " (ord=", ord, ")\n", NULL);
found = true;
}
}
if (!found) {
Log("error: bad syscall (", GetSyscallName(si->si_syscall), " ord=", ord,
" rip=", rip, ")\n", NULL);
")\n", NULL);
}
switch (mode & PLEDGE_PENALTY_MASK) {
case PLEDGE_PENALTY_KILL_PROCESS:

View file

@ -42,8 +42,8 @@ privileged int prctl(int operation, ...) {
d = va_arg(va, intptr_t);
va_end(va);
#ifdef __x86_64__
if (IsLinux()) {
#ifdef __x86_64__
asm volatile("mov\t%5,%%r10\n\t"
"mov\t%6,%%r8\n\t"
"syscall"
@ -51,25 +51,25 @@ privileged int prctl(int operation, ...) {
: "0"(157), "D"(operation), "S"(a), "d"(b), "g"(c), "g"(d)
: "rcx", "r8", "r10", "r11", "memory");
if (rc > -4096u) errno = -rc, rc = -1;
} else {
rc = enosys();
}
#elif defined(__aarch64__)
register long r0 asm("x0") = (long)operation;
register long r1 asm("x1") = (long)a;
register long r2 asm("x2") = (long)b;
register long r3 asm("x3") = (long)c;
register long r4 asm("x4") = (long)d;
register long res_x0 asm("x0");
asm volatile("mov\tx8,%1\n\t"
"svc\t0"
: "=r"(res_x0)
: "i"(167), "r"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r4)
: "x8", "memory");
rc = _sysret(res_x0);
register long r0 asm("x0") = (long)operation;
register long r1 asm("x1") = (long)a;
register long r2 asm("x2") = (long)b;
register long r3 asm("x3") = (long)c;
register long r4 asm("x4") = (long)d;
register long res_x0 asm("x0");
asm volatile("mov\tx8,%1\n\t"
"svc\t0"
: "=r"(res_x0)
: "i"(167), "r"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r4)
: "x8", "memory");
rc = _sysret(res_x0);
#else
#error "arch unsupported"
#endif
} else {
rc = enosys();
}
#ifdef SYSDEBUG
if (operation == PR_CAPBSET_READ || operation == PR_CAPBSET_DROP) {

View file

@ -37,8 +37,8 @@
*/
privileged int seccomp(unsigned operation, unsigned flags, void *args) {
int rc;
#ifdef __x86_64__
if (IsLinux()) {
#ifdef __x86_64__
asm volatile("syscall"
: "=a"(rc)
: "0"(317), "D"(operation), "S"(flags), "d"(args)
@ -61,23 +61,23 @@ privileged int seccomp(unsigned operation, unsigned flags, void *args) {
errno = -rc;
rc = -1;
}
} else {
rc = enosys();
}
#elif defined(__aarch64__)
register long r0 asm("x0") = (long)operation;
register long r1 asm("x1") = (long)flags;
register long r2 asm("x2") = (long)args;
register long res_x0 asm("x0");
asm volatile("mov\tx8,%1\n\t"
"svc\t0"
: "=r"(res_x0)
: "i"(211), "r"(r0), "r"(r1), "r"(r2)
: "x8", "memory");
rc = _sysret(res_x0);
register long r0 asm("x0") = (long)operation;
register long r1 asm("x1") = (long)flags;
register long r2 asm("x2") = (long)args;
register long res_x0 asm("x0");
asm volatile("mov\tx8,%1\n\t"
"svc\t0"
: "=r"(res_x0)
: "i"(211), "r"(r0), "r"(r1), "r"(r2)
: "x8", "memory");
rc = _sysret(res_x0);
#else
#error "arch unsupported"
#endif
} else {
rc = enosys();
}
STRACE("seccomp(%s, %#x, %p) → %d% m", DescribeSeccompOperation(operation),
flags, args, rc);
return rc;

View file

@ -49,6 +49,12 @@
#include "libc/thread/tls.h"
#ifdef __x86_64__
#define ARCHITECTURE AUDIT_ARCH_X86_64
#elif defined(__aarch64__)
#define ARCHITECTURE AUDIT_ARCH_AARCH64
#else
#error "unsupported architecture"
#endif
#define OFF(f) offsetof(struct seccomp_data, f)
@ -70,7 +76,7 @@
static const struct sock_filter kUnveilBlacklistAbiVersionBelow3[] = {
BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(arch)),
BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, AUDIT_ARCH_X86_64, 1, 0),
BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, ARCHITECTURE, 1, 0),
BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS),
BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(nr)),
BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_linux_truncate, 1, 0),
@ -81,7 +87,7 @@ static const struct sock_filter kUnveilBlacklistAbiVersionBelow3[] = {
static const struct sock_filter kUnveilBlacklistLatestAbi[] = {
BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(arch)),
BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, AUDIT_ARCH_X86_64, 1, 0),
BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, ARCHITECTURE, 1, 0),
BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS),
BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(nr)),
BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_linux_setxattr, 0, 1),
@ -402,5 +408,3 @@ int unveil(const char *path, const char *permissions) {
STRACE("unveil(%#s, %#s) → %d% m", path, permissions, rc);
return rc;
}
#endif /* __x86_64__ */

View file

@ -26,6 +26,7 @@ _Hide extern const struct MagnumStr kRlimitNames[];
_Hide extern const struct MagnumStr kSignalNames[];
_Hide extern const struct MagnumStr kSockOptnames[];
_Hide extern const struct MagnumStr kTcpOptnames[];
_Hide extern const struct MagnumStr kPollNames[];
char *GetMagnumStr(const struct MagnumStr *, int);
char *DescribeMagnum(char *, const struct MagnumStr *, const char *, int);

View file

@ -47,10 +47,9 @@
#include "libc/sysv/errfuns.h"
#include "libc/thread/tls.h"
#include "third_party/dlmalloc/dlmalloc.h"
#ifdef __x86_64__
STATIC_YOINK("_init_asan");
#endif
#if IsModeDbg()
// MODE=dbg
@ -1505,3 +1504,5 @@ void __asan_init(int argc, char **argv, char **envp, intptr_t *auxv) {
STRACE("/_/ \\_\\____/_/ \\_\\_| \\_|");
STRACE("cosmopolitan memory safety module initialized");
}
#endif /* __x86_64__ */

View file

@ -16,6 +16,7 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef __x86_64__
void __asan_report_load(void *, int);
void __asan_report_store(void *, int);
@ -171,3 +172,5 @@ void __asan_store16() {
void __asan_store32() {
__builtin_trap();
}
#endif /* __x86_64__ */

View file

@ -78,6 +78,14 @@ o/$(MODE)/libc/intrin/asan.o: private \
-finline \
-finline-functions
o/$(MODE)/libc/intrin/asanthunk.o: private \
OVERRIDE_CFLAGS += \
-x-no-pg \
$(MNO_FENTRY) \
-ffreestanding \
-fno-sanitize=all \
-fno-stack-protector
# we can't use compiler magic because:
# kprintf() is mission critical to error reporting
o/$(MODE)/libc/intrin/getmagnumstr.greg.o \

View file

@ -1,7 +1,7 @@
/*-*- 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 2022 Justine Alexandra Roberts Tunney
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
@ -16,13 +16,31 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/fmt/magnumstrs.internal.h"
#include "libc/macros.internal.h"
__utmpxname:
.errno
mov ENOTSUP(%rip),%edx
mov %edx,(%rax)
ret
.endfn __utmpxname,globl
.alias __utmpxname,utmpname
.alias __utmpxname,utmpxname
.macro .e e s
.long \e - kPollNames
.long .L\@ - kPollNames
.rodata.str1.1
.L\@: .string "\s"
.previous
.endm
.section .rodata,"a",@progbits
.balign 4
.underrun
kPollNames:
.e POLLNVAL "POLLNVAL"
.e POLLWRNORM "POLLWRNORM"
.e POLLWRBAND "POLLWRBAND"
.e POLLRDNORM "POLLRDNORM"
.e POLLRDHUP "POLLRDHUP"
.e POLLRDBAND "POLLRDBAND"
.e POLLHUP "POLLHUP"
.e POLLERR "POLLERR"
.e POLLPRI "POLLPRI"
.e POLLOUT "POLLOUT"
.e POLLIN "POLLIN"
.endobj kPollNames,globl,hidden
.overrun

View file

@ -48,6 +48,7 @@
#include "libc/runtime/internal.h"
#include "libc/runtime/memtrack.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/runtime/stack.h"
#include "libc/runtime/symbols.internal.h"
#include "libc/str/str.h"
#include "libc/str/tab.internal.h"
@ -173,12 +174,16 @@ privileged bool kisdangerous(const void *p) {
int frame;
if (kisimagepointer(p)) return false;
if (kiskernelpointer(p)) return false;
if (IsOldStack(p)) return false;
if (IsLegalPointer(p)) {
frame = (intptr_t)p >> 16;
frame = (uintptr_t)p >> 16;
if (IsStackFrame(frame)) return false;
if (IsOldStackFrame(frame)) return false;
if (kismapped(frame)) return false;
}
if (GetStackAddr() + GUARDSIZE <= (uintptr_t)p &&
(uintptr_t)p < GetStackAddr() + GetStackSize()) {
return false;
}
return true;
}
@ -219,12 +224,12 @@ privileged static void klog(const char *b, size_t n) {
register long r0 asm("x0") = (long)2;
register long r1 asm("x1") = (long)b;
register long r2 asm("x2") = (long)n;
register long r8 asm("x8") = (long)__NR_write;
register long res_x0 asm("x0");
asm volatile("mov\tx8,%1\n\t"
"svc\t0"
asm volatile("svc\t0"
: "=r"(res_x0)
: "i"(64), "r"(r0), "r"(r1), "r"(r2)
: "x8", "memory");
: "r"(r0), "r"(r1), "r"(r2), "r"(r8)
: "memory");
#else
#error "unsupported architecture"
#endif

46
libc/intrin/lshrti3.c Normal file
View file

@ -0,0 +1,46 @@
/* clang-format off */
/* ===-- lshrti3.c - Implement __lshrti3 -----------------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is dual licensed under the MIT and the University of Illinois Open
* Source Licenses. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __lshrti3 for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#include "third_party/compiler_rt/int_lib.h"
#ifdef CRT_HAS_128BIT
/* Returns: logical a >> b */
/* Precondition: 0 <= b < bits_in_tword */
COMPILER_RT_ABI ti_int
__lshrti3(ti_int a, si_int b)
{
const int bits_in_dword = (int)(sizeof(di_int) * CHAR_BIT);
utwords input;
utwords result;
input.all = a;
if (b & bits_in_dword) /* bits_in_dword <= b < bits_in_tword */
{
result.s.high = 0;
result.s.low = input.s.high >> (b - bits_in_dword);
}
else /* 0 <= b < bits_in_dword */
{
if (b == 0)
return a;
result.s.high = input.s.high >> b;
result.s.low = (input.s.high << (bits_in_dword - b)) | (input.s.low >> b);
}
return result.all;
}
#endif /* CRT_HAS_128BIT */

View file

@ -19,12 +19,9 @@ forceinline long __sysv_exit(long rc) {
: "memory", "cc");
#elif defined(__aarch64__)
register long r0 asm("x0") = rc;
register long r8 asm("x8") = __NR_exit_group;
register long res_x0 asm("x0");
asm volatile("mov\tx8,%1\n\t"
"svc\t0"
: "=r"(res_x0)
: "i"(94), "r"(r0)
: "x8", "memory");
asm volatile("svc\t0" : "=r"(res_x0) : "r"(r0), "r"(r8) : "memory");
ax = res_x0;
#else
ax = syscall(__NR_exit_group, rc);
@ -41,12 +38,13 @@ forceinline int __sysv_close(long fd) {
: "rdx", "memory", "cc");
#elif defined(__aarch64__)
register long r0 asm("x0") = fd;
register long r8 asm("x8") = __NR_close;
register long res_x0 asm("x0");
asm volatile("mov\tx8,%1\n\t"
"svc\t0"
: "=r"(res_x0)
: "i"(57), "r"(r0)
: "x8", "memory");
: "r"(r0), "r"(r8)
: "memory");
ax = res_x0;
#else
ax = syscall(__NR_close, fd);
@ -66,12 +64,12 @@ forceinline int __sysv_open(const char *path, long flags, long mode) {
register long r1 asm("x1") = (long)path;
register long r2 asm("x2") = (long)flags;
register long r3 asm("x3") = (long)mode;
register long r8 asm("x8") = (long)__NR_open;
register long res_x0 asm("x0");
asm volatile("mov\tx8,%1\n\t"
"svc\t0"
asm volatile("svc\t0"
: "=r"(res_x0)
: "i"(56), "r"(r0), "r"(r1), "r"(r2), "r"(r3)
: "x8", "memory");
: "r"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r8)
: "memory");
ax = res_x0;
#else
ax = syscall(__NR_open, path, flags, mode);
@ -90,12 +88,12 @@ forceinline long __sysv_read(long fd, void *data, unsigned long size) {
register long r0 asm("x0") = (long)fd;
register long r1 asm("x1") = (long)data;
register long r2 asm("x2") = (long)size;
register long r8 asm("x8") = (long)__NR_read;
register long res_x0 asm("x0");
asm volatile("mov\tx8,%1\n\t"
"svc\t0"
asm volatile("svc\t0"
: "=r"(res_x0)
: "i"(63), "r"(r0), "r"(r1), "r"(r2)
: "x8", "memory");
: "r"(r0), "r"(r1), "r"(r2), "r"(r8)
: "memory");
ax = res_x0;
#else
ax = syscall(__NR_read, fd, data, size);
@ -114,12 +112,12 @@ forceinline long __sysv_write(long fd, const void *data, unsigned long size) {
register long r0 asm("x0") = (long)fd;
register long r1 asm("x1") = (long)data;
register long r2 asm("x2") = (long)size;
register long r8 asm("x8") = (long)__NR_write;
register long res_x0 asm("x0");
asm volatile("mov\tx8,%1\n\t"
"svc\t0"
asm volatile("svc\t0"
: "=r"(res_x0)
: "i"(64), "r"(r0), "r"(r1), "r"(r2)
: "x8", "memory");
: "i"(64), "r"(r0), "r"(r1), "r"(r2), "r"(r8)
: "memory");
ax = res_x0;
#else
ax = syscall(__NR_write, fd, data, size);
@ -138,12 +136,12 @@ forceinline long __sysv_mprotect(void *addr, size_t size, long prot) {
register long r0 asm("x0") = (long)addr;
register long r1 asm("x1") = (long)size;
register long r2 asm("x2") = (long)prot;
register long r8 asm("x8") = (long)__NR_mprotect;
register long res_x0 asm("x0");
asm volatile("mov\tx8,%1\n\t"
"svc\t0"
asm volatile("svc\t0"
: "=r"(res_x0)
: "i"(226), "r"(r0), "r"(r1), "r"(r2)
: "x8", "memory");
: "r"(r0), "r"(r1), "r"(r2), "r"(r8)
: "memory");
ax = res_x0;
#else
ax = syscall(__NR_mprotect, addr, size, prot);
@ -159,12 +157,9 @@ forceinline int __sysv_getpid(void) {
: "0"(__NR_getpid)
: "rdx", "memory", "cc");
#elif defined(__aarch64__)
register long r8 asm("x8") = (long)__NR_getpid;
register long res_x0 asm("x0");
asm volatile("mov\tx8,%1\n\t"
"svc\t0"
: "=r"(res_x0)
: "i"(172)
: "x8", "memory");
asm volatile("svc\t0" : "=r"(res_x0) : "r"(r8) : "memory");
ax = res_x0;
#else
ax = syscall(__NR_getpid);

View file

@ -22,6 +22,8 @@
//
// This function crashes if called with a misaligned stack.
CheckStackIsAligned:
#ifdef __x86_64__
push %rbp
mov %rsp,%rbp
@ -35,4 +37,14 @@ CheckStackIsAligned:
leave
ret
#elif defined(__aarch64__)
// TODO: support me
mov x0,#1
ret
#else
#error "unsupported architecture"
#endif
.endfn CheckStackIsAligned,globl

View file

@ -31,6 +31,7 @@
// @threadsafe
// @noreturn
_gclongjmp:
#ifdef __x86_64__
push %rbp
mov %rsp,%rbp
.profilable
@ -59,4 +60,9 @@ _gclongjmp:
2: pop %rsi
pop %rdi
jmp 0b
#elif defined(__aarch64__)
b longjmp
#else
#error "unsupported architecture"
#endif /* __x86_64__ */
.endfn _gclongjmp,globl

View file

@ -17,10 +17,10 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/macros.internal.h"
.real
// Function Profiling Hook.
// cc -pg adds this to the start of global functions.
mcount: ret
.endfn mcount,weak
.endfn mcount,globl,weak
.alias mcount,_mcount // aarch64 weirdness?
.alias mcount,.mcount // freebsd weirdness?

View file

@ -42,10 +42,22 @@ $(LIBC_NEXGEN32E_A).pkg: \
$(LIBC_NEXGEN32E_A_OBJS) \
$(foreach x,$(LIBC_NEXGEN32E_A_DIRECTDEPS),$($(x)_A).pkg)
o/$(MODE)/libc/nexgen32e/argc2.o \
o/$(MODE)/libc/nexgen32e/argv2.o \
o/$(MODE)/libc/nexgen32e/auxv2.o \
o/$(MODE)/libc/nexgen32e/cescapec.o \
o/$(MODE)/libc/nexgen32e/crc32init.o \
o/$(MODE)/libc/nexgen32e/environ2.o \
o/$(MODE)/libc/nexgen32e/envp2.o \
o/$(MODE)/libc/nexgen32e/kbase36.o \
o/$(MODE)/libc/nexgen32e/ktens.o \
o/$(MODE)/libc/nexgen32e/ktolower.o \
o/$(MODE)/libc/nexgen32e/ktoupper.o \
o/$(MODE)/libc/nexgen32e/pid.o \
o/$(MODE)/libc/nexgen32e/program_invocation_name2.o \
o/$(MODE)/libc/nexgen32e/threaded.o: private \
OVERRIDE_CFLAGS += \
$(NO_MAGIC) \
-fno-sanitize=all
$(NO_MAGIC)
# these assembly files are safe to build on aarch64
o/$(MODE)/libc/nexgen32e/zip.o: libc/nexgen32e/zip.S
@ -70,6 +82,10 @@ o/$(MODE)/libc/nexgen32e/missingno.o: libc/nexgen32e/missingno.S
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
o/$(MODE)/libc/nexgen32e/khalfcache3.o: libc/nexgen32e/khalfcache3.S
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
o/$(MODE)/libc/nexgen32e/gclongjmp.o: libc/nexgen32e/gclongjmp.S
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
o/$(MODE)/libc/nexgen32e/checkstackalign.o: libc/nexgen32e/checkstackalign.S
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
LIBC_NEXGEN32E_LIBS = $(foreach x,$(LIBC_NEXGEN32E_ARTIFACTS),$($(x)))
LIBC_NEXGEN32E_SRCS = $(foreach x,$(LIBC_NEXGEN32E_ARTIFACTS),$($(x)_SRCS))

View file

@ -18,4 +18,8 @@
*/
#include "libc/runtime/runtime.h"
#ifndef __x86_64__
char *program_invocation_name;
#endif /* __x86_64__ */

View file

@ -31,19 +31,6 @@
int main(int, char **, char **) __attribute__((__weak__));
#if 0
static inline long sys_set_tid_address(int *t) {
register long res asm("x0");
register long arg asm("x0") = (long)t;
asm volatile("mov\tx8,%1\n\t"
"svc\t0"
: "=r"(res)
: "i"(96), "r"(arg)
: "x8", "memory");
return res;
}
#endif
typedef int init_f(int argc, char **argv, char **envp, unsigned long *auxv);
extern init_f __strace_init;
@ -77,16 +64,19 @@ textstartup void cosmo(long *sp) {
_mmi.n = ARRAYLEN(_mmi.s);
_mmi.p = _mmi.s;
__mmi_lock_obj._type = PTHREAD_MUTEX_RECURSIVE;
InitializeFileDescriptors();
#ifdef SYSDEBUG
// initialize --strace functionality
argc = __strace_init(argc, argv, envp, auxv);
#endif
#if 0
#if IsAsan()
__asan_init(argc, argv, envp, auxv);
#endif
#endif
InitializeFileDescriptors();
// set helpful globals
__argc = argc;

View file

@ -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 2022 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"
// Closes user accounting database.
// @note unsupported
endutxent:
xor %eax,%eax
ret
.endfn endutxent,globl

View file

@ -19,6 +19,7 @@
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/sysv/consts/sig.h"
#include "libc/sysv/errfuns.h"
int sys_fork(void) {
#ifdef __x86_64__
@ -37,23 +38,27 @@ int sys_fork(void) {
#elif defined(__aarch64__)
int flags = 17; // SIGCHLD;
void *child_stack = 0;
void *parent_tidptr = 0;
void *newtls = 0;
void *child_tidptr = 0;
register long r0 asm("x0") = (long)flags;
register long r1 asm("x1") = (long)child_stack;
register long r2 asm("x2") = (long)parent_tidptr;
register long r3 asm("x3") = (long)newtls;
register long r4 asm("x4") = (long)child_tidptr;
register long res_x0 asm("x0");
asm volatile("mov\tx8,%1\n\t"
"svc\t0"
: "=r"(res_x0)
: "i"(220), "r"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r4)
: "x8", "memory");
return _sysret(res_x0);
if (IsLinux()) {
int flags = 17; // SIGCHLD;
void *child_stack = 0;
void *parent_tidptr = 0;
void *newtls = 0;
void *child_tidptr = 0;
register long r0 asm("x0") = (long)flags;
register long r1 asm("x1") = (long)child_stack;
register long r2 asm("x2") = (long)parent_tidptr;
register long r3 asm("x3") = (long)newtls;
register long r4 asm("x4") = (long)child_tidptr;
register long res_x0 asm("x0");
asm volatile("mov\tx8,%1\n\t"
"svc\t0"
: "=r"(res_x0)
: "i"(220), "r"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r4)
: "x8", "memory");
return _sysret(res_x0);
} else {
return enosys();
}
#endif
}

View file

@ -1,24 +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 2022 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"
getutent:
xor %eax,%eax
ret
.endfn getutent,globl

View file

@ -1,24 +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 2022 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"
getutid:
xor %eax,%eax
ret
.endfn getutid,globl

View file

@ -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 2022 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"
// Reads next entry in user accounting database.
// @note unsupported
getutxent:
xor %eax,%eax
ret
.endfn getutxent,globl

View file

@ -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 2022 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"
// Searches forward in the user accounting database.
// @note unsupported
getutxid:
xor %eax,%eax
ret
.endfn getutxid,globl

View file

@ -1,27 +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 2022 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"
// Searches forward in the user accounting database.
// @note unsupported
getutxline:
xor %eax,%eax
ret
.endfn getutxline,globl
.alias getutxline,getutline

View file

@ -122,10 +122,18 @@ forceinline pureconst bool IsStackFrame(int x) {
x <= (int)((stack + (GetStackSize() - FRAMESIZE)) >> 16);
}
forceinline pureconst bool IsOldStackFrame(int x) {
forceinline pureconst bool IsOldStack(const void *x) {
/* openbsd uses 4mb stack by default */
/* freebsd uses 512mb stack by default */
/* most systems use 8mb stack by default */
size_t foss_stack_size = 4ul * 1024 * 1024;
uintptr_t top = ROUNDUP(__oldstack, FRAMESIZE);
uintptr_t bot = top - foss_stack_size;
uintptr_t old = ROUNDDOWN(__oldstack, foss_stack_size);
return bot <= (uintptr_t)x && (uintptr_t)x < top;
}
forceinline pureconst bool IsOldStackFrame(int x) {
size_t foss_stack_size = 4ul * 1024 * 1024;
uintptr_t top = ROUNDUP(__oldstack, FRAMESIZE);
uintptr_t bot = top - foss_stack_size;

View file

@ -45,12 +45,12 @@ static inline int __morph_rt_sigprocmask(int h, const sigset_t *s, sigset_t *o,
register long r1 asm("x1") = (long)s;
register long r2 asm("x2") = (long)o;
register long r3 asm("x3") = (long)c;
register long r8 asm("x8") = (long)__NR_sigprocmask;
register long res_x0 asm("x0");
asm volatile("mov\tx8,%1\n\t"
"svc\t0"
asm volatile("svc\t0"
: "=r"(res_x0)
: "i"(135), "r"(r0), "r"(r1), "r"(r2), "r"(r3)
: "x8", "memory");
: "r"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r8)
: "memory");
return res_x0;
#else
return 0;
@ -89,12 +89,12 @@ static privileged void __morph_mprotect(void *addr, size_t size, int prot,
register long r0 asm("x0") = (long)addr;
register long r1 asm("x1") = (long)size;
register long r2 asm("x2") = (long)prot;
register long r8 asm("x8") = (long)__NR_mprotect;
register long res_x0 asm("x0");
asm volatile("mov\tx8,%1\n\t"
"svc\t0"
asm volatile("svc\t0"
: "=r"(res_x0)
: "i"(226), "r"(r0), "r"(r1), "r"(r2)
: "x8", "memory");
: "r"(r0), "r"(r1), "r"(r2), "r"(r8)
: "memory");
_npassert(!res_x0);
#endif
}

View file

@ -63,8 +63,6 @@
#include "tool/decode/lib/idname.h"
#include "tool/decode/lib/x86idnames.h"
#ifdef __x86_64__
STATIC_YOINK("strerror"); // for kprintf()
STATIC_YOINK("strsignal"); // for kprintf()
@ -203,6 +201,7 @@ textstartup void __printargs(const char *prologue) {
PRINT("");
PRINT("MICROPROCESSOR");
kprintf(prologue);
#ifdef __x86_64__
kprintf(" %.*s%.*s%.*s", 4, &KCPUIDS(0H, EBX), 4, &KCPUIDS(0H, EDX), 4,
&KCPUIDS(0H, ECX));
if (getx86processormodel(kX86ProcessorModelKey)) {
@ -272,6 +271,9 @@ textstartup void __printargs(const char *prologue) {
if (X86_HAVE(RDPID)) kprintf(" RDPID");
if (X86_HAVE(LA57)) kprintf(" LA57");
if (X86_HAVE(FSGSBASE)) kprintf(" FSGSBASE");
#elif defined(__aarch64__)
PRINT(" AARCH64\n");
#endif
kprintf("\n");
PRINT("");
@ -424,8 +426,10 @@ textstartup void __printargs(const char *prologue) {
PRINT(" ☼ %s = %d", "getgid()", getgid());
PRINT(" ☼ %s = %d", "getegid()", getegid());
PRINT(" ☼ %s = %#s", "kTmpPath", kTmpPath);
#ifdef __x86_64__
PRINT(" ☼ %s = %#s", "kNtSystemDirectory", kNtSystemDirectory);
PRINT(" ☼ %s = %#s", "kNtWindowsDirectory", kNtWindowsDirectory);
#endif
PRINT(" ☼ %s = %#s", "GetProgramExecutableName", GetProgramExecutableName());
PRINT(" ☼ %s = %#s", "GetInterpreterExecutableName",
GetInterpreterExecutableName(u.path, sizeof(u.path)));
@ -713,5 +717,3 @@ textstartup void __printargs(const char *prologue) {
ftrace_enabled(+1);
errno = e;
}
#endif /* __x86_64__ */

View file

@ -1,24 +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 2022 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"
setutent:
xor %eax,%eax
ret
.endfn setutent,globl

View file

@ -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 2022 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"
// Rewinds the user accounting database.
// @note unsupported
setutxent:
xor %eax,%eax
ret
.endfn setutxent,globl

View file

@ -1,24 +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 2022 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"
updwtmp:
xor %eax,%eax
ret
.endfn updwtmp,globl

View file

@ -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 2022 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"
// Does something to the user accounting database.
// @note unsupported
updwtmpx:
xor %eax,%eax
ret
.endfn updwtmpx,globl

View file

@ -1,7 +1,7 @@
/*-*- 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
/*-*- 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,9 +16,57 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/macros.internal.h"
#include "libc/runtime/utmp.h"
#include "libc/errno.h"
#include "libc/runtime/utmpx.h"
endutent:
xor %eax,%eax
ret
.endfn endutent,globl
void setutent(void) {
}
void endutent(void) {
}
void endutxent(void) {
}
struct utmp *getutent(void) {
return 0;
}
void updwtmp(const char *x, const struct utmp *y) {
}
void updwtmpx(const char *x, const struct utmpx *y) {
}
void setutxent(void) {
}
struct utmp *getutid(const struct utmp *x) {
return 0;
}
struct utmpx *getutxent(void) {
return 0;
}
struct utmpx *getutxid(const struct utmpx *x) {
return 0;
}
struct utmpx *getutxline(const struct utmpx *x) {
return 0;
}
int __utmpxname() {
errno = ENOTSUP;
return -1;
}
int utmpname(const char *x) {
return __utmpxname();
}
int utmpxname(const char *x) {
return __utmpxname();
}

View file

@ -16,8 +16,10 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/sock/struct/msghdr.h"
#if IsAsan()
bool __asan_is_valid_msghdr(const struct msghdr *msg) {
if (!__asan_is_valid(msg, sizeof(struct msghdr))) return false;
@ -29,3 +31,5 @@ bool __asan_is_valid_msghdr(const struct msghdr *msg) {
}
return __asan_is_valid_iov(msg->msg_iov, msg->msg_iovlen);
}
#endif

View file

@ -33,10 +33,14 @@ void djbsort(int32_t *a, size_t n) {
__asan_verify(a, m);
}
if (n > 1) {
#ifdef __x86_64__
if (X86_HAVE(AVX2)) {
djbsort_avx2(a, n);
} else {
_intsort(a, n);
}
#else
_intsort(a, n);
#endif /* __x86_64__ */
}
}

View file

@ -1,2 +0,0 @@
#include "libc/sysv/macros.internal.h"
.scall sys_access,0x0210210212021015,0xfff,globl,hidden

View file

@ -360,6 +360,7 @@
#define __NR_linux_stat 0x004f
#define __NR_linux_fstat 0x0050
#define __NR_linux_ppoll 0x0049
#define __NR_linux_brk 0x00d6
#define __NR_linux_sigreturn 0x008b
#define __NR_linux_lseek 0x003e
#define __NR_linux_mmap 0x00de

View file

@ -33,6 +33,7 @@ __errfun:
str w19,[x0]
mov x0,#-1
ldp x19,x30,[sp],#16
ret
#else
#error "unsupported architecture"
#endif

View file

@ -18,11 +18,6 @@
*/
#include "libc/errno.h"
asm(".weak\t__asan_init");
asm(".weak\t__asan_register_globals");
asm(".weak\t__asan_unregister_globals");
asm(".weak\t__asan_version_mismatch_check_v8");
/**
* Global variable for last error.
*

View file

@ -56,7 +56,6 @@ scall sys_pread 0x8ad8ad9db2899811 0x043 globl hidden # a.k.a. pread64; netbsd+
scall sys_pwrite 0x8ae8ae9dc289a812 0x044 globl hidden # a.k.a. pwrite64; netbsd+openbsd:pad
scall sys_readv 0x8788788782878813 0x041 globl hidden
scall sys_writev 0x8798798792879814 0x042 globl hidden
scall sys_access 0x0210210212021015 0xfff globl hidden
scall __sys_pipe 0x02a10721e202a016 0x03b globl hidden # NOTE: pipe2() on FreeBSD and Linux Aarch64; XNU is pipe(void)→eax:edx
scall sys_select 0x9a184785d285d817 0xfff globl hidden
scall sys_pselect 0x9b486ea0a298a90e 0x048 globl hidden # pselect6() on gnu/systemd

View file

@ -24,6 +24,7 @@
// for the purpose of counting non-Windows system calls. Please
// note wrappers may still short circuit calls sometimes, which
// wouldn't impact this counter.
.bss
.balign 8
__syscount:
@ -31,6 +32,8 @@ __syscount:
.endobj __syscount,globl
.previous
#ifdef __x86_64__
.initbss 701,_init___syscount
__syscount_next:
.quad 0
@ -49,3 +52,5 @@ syscount:
ezlea syscount,ax
mov %rax,__systemfive(%rip)
.init.end 701,_init___syscount
#endif /* __x86_64__ */

View file

@ -70,6 +70,11 @@ $(LIBC_SYSV_A).pkg: \
$(LIBC_SYSV_A_OBJS) \
$(foreach x,$(LIBC_SYSV_A_DIRECTDEPS),$($(x)_A).pkg)
o/$(MODE)/libc/sysv/errno.o \
o/$(MODE)/libc/sysv/sysret.o: private \
OVERRIDE_CFLAGS += \
$(NO_MAGIC)
#───────────────────────────────────────────────────────────────────────────────
LIBC_SYSV_CALLS = \
@ -129,6 +134,8 @@ $(LIBC_SYSV_MACHCALLS_A).pkg: \
# let aarch64 compile these
o/$(MODE)/libc/sysv/errfun.o: libc/sysv/errfun.S
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) $<
o/$(MODE)/libc/sysv/syscount.o: libc/sysv/syscount.S
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) $<
o/$(MODE)/libc/sysv/restorert.o: libc/sysv/restorert.S
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) $<
o/$(MODE)/libc/sysv/calls/%.o: libc/sysv/calls/%.S

View file

@ -210,14 +210,18 @@ int __zipos_open(const struct ZiposUri *name, unsigned flags, int mode) {
if ((zipos = __zipos_get())) {
if ((cf = __zipos_find(zipos, name)) != -1) {
rc = __zipos_load(zipos, cf, flags, mode);
assert(rc != 0);
} else {
rc = enoent();
assert(rc != 0);
}
} else {
rc = enoexec();
assert(rc != 0);
}
} else {
rc = einval();
assert(rc != 0);
}
ALLOW_SIGNALS;
return rc;