mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 00:02:28 +00:00
Remove dollars from system call support symbols
This commit is contained in:
parent
a8d7195777
commit
a37960a3af
743 changed files with 1380 additions and 2016 deletions
|
@ -23,7 +23,7 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
|
||||
textwindows wontreturn void abort$nt(void) {
|
||||
textwindows wontreturn void sys_abort_nt(void) {
|
||||
siginfo_t info;
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.si_signo = SIGABRT;
|
||||
|
|
|
@ -48,7 +48,7 @@ abort: push %rbp
|
|||
pop (%rsi)
|
||||
xor %edx,%edx # don't care about old sigmask
|
||||
pushpop 4*4,%r10 # sizeof(sigset_t) for systemd
|
||||
mov __NR_sigprocmask,%eax # sigprocmask$sysv is hookable
|
||||
mov __NR_sigprocmask,%eax # sys_sigprocmask is hookable
|
||||
syscall
|
||||
mov __NR_getpid,%eax
|
||||
syscall
|
||||
|
@ -56,5 +56,5 @@ abort: push %rbp
|
|||
mov SIGABRT,%esi
|
||||
mov __NR_kill,%eax
|
||||
syscall # avoid hook and less bt noise
|
||||
2: call abort$nt
|
||||
2: call sys_abort_nt
|
||||
.endfn abort,globl,protected
|
||||
|
|
|
@ -40,9 +40,9 @@
|
|||
* operating systems.
|
||||
*/
|
||||
|
||||
int arch_prctl$sysv(int, int64_t) hidden;
|
||||
int sys_arch_prctl(int, int64_t) hidden;
|
||||
|
||||
static inline int arch_prctl$fsgsbase(int code, int64_t addr) {
|
||||
static inline int arch_prctl_fsgsbase(int code, int64_t addr) {
|
||||
switch (code) {
|
||||
case ARCH_SET_GS:
|
||||
asm volatile("wrgsbase\t%0" : /* no outputs */ : "r"(addr));
|
||||
|
@ -61,7 +61,7 @@ static inline int arch_prctl$fsgsbase(int code, int64_t addr) {
|
|||
}
|
||||
}
|
||||
|
||||
static int arch_prctl$msr(int code, int64_t addr) {
|
||||
static int arch_prctl_msr(int code, int64_t addr) {
|
||||
switch (code) {
|
||||
case ARCH_SET_GS:
|
||||
wrmsr(MSR_IA32_GS_BASE, addr);
|
||||
|
@ -80,22 +80,22 @@ static int arch_prctl$msr(int code, int64_t addr) {
|
|||
}
|
||||
}
|
||||
|
||||
static int arch_prctl$freebsd(int code, int64_t addr) {
|
||||
static int arch_prctl_freebsd(int code, int64_t addr) {
|
||||
switch (code) {
|
||||
case ARCH_GET_FS:
|
||||
return arch_prctl$sysv(128, addr);
|
||||
return sys_arch_prctl(128, addr);
|
||||
case ARCH_SET_FS:
|
||||
return arch_prctl$sysv(129, addr);
|
||||
return sys_arch_prctl(129, addr);
|
||||
case ARCH_GET_GS:
|
||||
return arch_prctl$sysv(130, addr);
|
||||
return sys_arch_prctl(130, addr);
|
||||
case ARCH_SET_GS:
|
||||
return arch_prctl$sysv(131, addr);
|
||||
return sys_arch_prctl(131, addr);
|
||||
default:
|
||||
return einval();
|
||||
}
|
||||
}
|
||||
|
||||
static textsyscall int arch_prctl$xnu(int code, int64_t addr) {
|
||||
static textsyscall int arch_prctl_xnu(int code, int64_t addr) {
|
||||
int ax;
|
||||
switch (code) {
|
||||
case ARCH_SET_GS:
|
||||
|
@ -113,7 +113,7 @@ static textsyscall int arch_prctl$xnu(int code, int64_t addr) {
|
|||
}
|
||||
}
|
||||
|
||||
static textsyscall int arch_prctl$openbsd(int code, int64_t addr) {
|
||||
static textsyscall int arch_prctl_openbsd(int code, int64_t addr) {
|
||||
int64_t rax;
|
||||
switch (code) {
|
||||
case ARCH_GET_FS:
|
||||
|
@ -144,7 +144,7 @@ static struct InterruptibleCall g_fsgs_icall;
|
|||
* Don't bother.
|
||||
*/
|
||||
int arch_prctl(int code, int64_t addr) {
|
||||
void *fn = arch_prctl$fsgsbase;
|
||||
void *fn = arch_prctl_fsgsbase;
|
||||
if (!g_fsgs_once) {
|
||||
g_fsgs_once = true;
|
||||
if (X86_HAVE(FSGSBASE)) {
|
||||
|
@ -162,21 +162,21 @@ int arch_prctl(int code, int64_t addr) {
|
|||
}
|
||||
}
|
||||
if (g_fsgs_once == 2) {
|
||||
return arch_prctl$fsgsbase(code, addr);
|
||||
return arch_prctl_fsgsbase(code, addr);
|
||||
}
|
||||
switch (__hostos) {
|
||||
case METAL:
|
||||
return arch_prctl$msr(code, addr);
|
||||
return arch_prctl_msr(code, addr);
|
||||
case FREEBSD:
|
||||
/* claims support but it appears not */
|
||||
return arch_prctl$freebsd(code, addr);
|
||||
return arch_prctl_freebsd(code, addr);
|
||||
case OPENBSD:
|
||||
return arch_prctl$openbsd(code, addr);
|
||||
return arch_prctl_openbsd(code, addr);
|
||||
case LINUX:
|
||||
return arch_prctl$sysv(code, addr);
|
||||
return sys_arch_prctl(code, addr);
|
||||
case XNU:
|
||||
/* probably won't work */
|
||||
return arch_prctl$xnu(code, addr);
|
||||
return arch_prctl_xnu(code, addr);
|
||||
default:
|
||||
return enosys();
|
||||
}
|
||||
|
|
|
@ -31,10 +31,10 @@
|
|||
noasan struct DirectMap __mmap(void *addr, size_t size, unsigned prot,
|
||||
unsigned flags, int fd, int64_t off) {
|
||||
if (!IsWindows()) {
|
||||
return (struct DirectMap){mmap$sysv(addr, size, prot, flags, fd, off),
|
||||
return (struct DirectMap){sys_mmap(addr, size, prot, flags, fd, off),
|
||||
kNtInvalidHandleValue};
|
||||
} else {
|
||||
return __mmap$nt(addr, size, prot,
|
||||
return __sys_mmap_nt(addr, size, prot,
|
||||
fd != -1 ? g_fds.p[fd].handle : kNtInvalidHandleValue,
|
||||
off);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ struct DirectMap {
|
|||
};
|
||||
|
||||
struct DirectMap __mmap(void *, size_t, unsigned, unsigned, int, int64_t);
|
||||
struct DirectMap __mmap$nt(void *, size_t, unsigned, int64_t, int64_t);
|
||||
struct DirectMap __sys_mmap_nt(void *, size_t, unsigned, int64_t, int64_t);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "libc/runtime/directmap.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
|
||||
textwindows noasan struct DirectMap __mmap$nt(void *addr, size_t size,
|
||||
textwindows noasan struct DirectMap __sys_mmap_nt(void *addr, size_t size,
|
||||
unsigned prot, int64_t handle,
|
||||
int64_t off) {
|
||||
struct DirectMap dm;
|
||||
|
|
|
@ -97,7 +97,7 @@ textwindows noasan void WinMainForked(void) {
|
|||
size = ((uint64_t)(_mmi.p[i].y - _mmi.p[i].x) << 16) + FRAMESIZE;
|
||||
if (_mmi.p[i].flags & MAP_PRIVATE) {
|
||||
CloseHandle(_mmi.p[i].h);
|
||||
_mmi.p[i].h = __mmap$nt(addr, size, _mmi.p[i].prot, -1, 0).maphandle;
|
||||
_mmi.p[i].h = __sys_mmap_nt(addr, size, _mmi.p[i].prot, -1, 0).maphandle;
|
||||
ReadAll(reader, addr, size);
|
||||
} else {
|
||||
MapViewOfFileExNuma(
|
||||
|
@ -111,13 +111,13 @@ textwindows noasan void WinMainForked(void) {
|
|||
ReadAll(reader, _edata, _end - _edata);
|
||||
CloseHandle(reader);
|
||||
CloseHandle(writer);
|
||||
if (weaken(__wincrash$nt)) {
|
||||
AddVectoredExceptionHandler(1, (void *)weaken(__wincrash$nt));
|
||||
if (weaken(__wincrash_nt)) {
|
||||
AddVectoredExceptionHandler(1, (void *)weaken(__wincrash_nt));
|
||||
}
|
||||
longjmp(jb, 1);
|
||||
}
|
||||
|
||||
textwindows int fork$nt(void) {
|
||||
textwindows int sys_fork_nt(void) {
|
||||
jmp_buf jb;
|
||||
char exe[PATH_MAX];
|
||||
int64_t reader, writer;
|
||||
|
|
|
@ -30,9 +30,9 @@
|
|||
int fork(void) {
|
||||
int rc;
|
||||
if (!IsWindows()) {
|
||||
rc = fork$sysv();
|
||||
rc = sys_fork();
|
||||
} else {
|
||||
rc = fork$nt();
|
||||
rc = sys_fork_nt();
|
||||
}
|
||||
if (rc == 0) {
|
||||
__onfork();
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "libc/nt/memory.h"
|
||||
#include "libc/runtime/memtrack.h"
|
||||
|
||||
textwindows int msync$nt(void *addr, size_t size, int flags) {
|
||||
textwindows int sys_msync_nt(void *addr, size_t size, int flags) {
|
||||
int x, y, l, r, i;
|
||||
x = ROUNDDOWN((intptr_t)addr, FRAMESIZE) >> 16;
|
||||
y = ROUNDDOWN((intptr_t)addr + size - 1, FRAMESIZE) >> 16;
|
||||
|
|
|
@ -35,8 +35,8 @@
|
|||
int msync(void *addr, size_t size, int flags) {
|
||||
assert(((flags & MS_SYNC) ^ (flags & MS_ASYNC)) || !(MS_SYNC && MS_ASYNC));
|
||||
if (!IsWindows()) {
|
||||
return msync$sysv(addr, size, flags);
|
||||
return sys_msync(addr, size, flags);
|
||||
} else {
|
||||
return msync$nt(addr, size, flags);
|
||||
return sys_msync_nt(addr, size, flags);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,5 +46,5 @@ int munmap(void *addr, size_t size) {
|
|||
if (!ALIGNED(addr) || !CANONICAL(addr) || !size) return einval();
|
||||
if (UntrackMemoryIntervals(addr, size) == -1) return -1;
|
||||
if (IsWindows()) return 0;
|
||||
return munmap$sysv(addr, size);
|
||||
return sys_munmap(addr, size);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#define WasImported(SLOT) \
|
||||
((void *)*SLOT && *SLOT != (void *)&missingno /* see libc/crt/crt.S */)
|
||||
|
||||
static void __print$nt(const void *data, size_t len) {
|
||||
static void __sys_print_nt(const void *data, size_t len) {
|
||||
int64_t hand;
|
||||
char xmm[256];
|
||||
uint32_t wrote;
|
||||
|
@ -51,7 +51,7 @@ static void __print$nt(const void *data, size_t len) {
|
|||
textsyscall void __print(const void *data, size_t len) {
|
||||
int64_t ax, ordinal;
|
||||
if (WasImported(__imp_WriteFile)) {
|
||||
__print$nt(data, len);
|
||||
__sys_print_nt(data, len);
|
||||
} else {
|
||||
ordinal = __NR_write > 0 ? __NR_write : IsXnu() ? 0x2000004 : 4;
|
||||
asm volatile("syscall"
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
vfork:
|
||||
#if SupportsWindows()
|
||||
testb IsWindows()
|
||||
jnz fork$nt
|
||||
jnz sys_fork_nt
|
||||
#endif
|
||||
mov __NR_vfork(%rip),%eax
|
||||
pop %rsi # saves return address in a register
|
||||
|
|
|
@ -67,7 +67,7 @@ static noasan textwindows void MakeLongDoubleLongAgain(void) {
|
|||
static noasan textwindows void NormalizeCmdExe(void) {
|
||||
uint32_t mode;
|
||||
int64_t handle, hstdin, hstdout, hstderr;
|
||||
if ((int)weakaddr("v_ntsubsystem") == kNtImageSubsystemWindowsCui &&
|
||||
if ((int)weakaddr("sys_v_ntsubsystem") == kNtImageSubsystemWindowsCui &&
|
||||
NtGetVersion() >= kNtVersionWindows10) {
|
||||
hstdin = GetStdHandle(pushpop(kNtStdInputHandle));
|
||||
hstdout = GetStdHandle(pushpop(kNtStdOutputHandle));
|
||||
|
@ -107,9 +107,9 @@ static noasan textwindows wontreturn void WinMainNew(void) {
|
|||
*(/*unconst*/ int *)&__hostos = WINDOWS;
|
||||
addr = NtGetVersion() < kNtVersionWindows10 ? 0xff00000 : 0x777000000000;
|
||||
size = ROUNDUP(STACKSIZE + sizeof(struct WinArgs), FRAMESIZE);
|
||||
_mmi.p[0].h =
|
||||
__mmap$nt((char *)addr, size, PROT_READ | PROT_WRITE | PROT_EXEC, -1, 0)
|
||||
.maphandle;
|
||||
_mmi.p[0].h = __sys_mmap_nt((char *)addr, size,
|
||||
PROT_READ | PROT_WRITE | PROT_EXEC, -1, 0)
|
||||
.maphandle;
|
||||
_mmi.p[0].x = addr >> 16;
|
||||
_mmi.p[0].y = (addr >> 16) + ((size >> 16) - 1);
|
||||
_mmi.p[0].prot = PROT_READ | PROT_WRITE | PROT_EXEC;
|
||||
|
@ -167,7 +167,7 @@ static noasan textwindows wontreturn void WinMainNew(void) {
|
|||
noasan textwindows int64_t WinMain(int64_t hInstance, int64_t hPrevInstance,
|
||||
const char *lpCmdLine, int nCmdShow) {
|
||||
MakeLongDoubleLongAgain();
|
||||
if (weaken(winsockinit)) weaken(winsockinit)();
|
||||
if (weaken(__winsockinit)) weaken(__winsockinit)();
|
||||
if (weaken(WinMainForked)) weaken(WinMainForked)();
|
||||
WinMainNew();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue