mirror of
https://github.com/darlinghq/darling.git
synced 2024-11-23 12:19:43 +00:00
32-bit Hello world working once again in Darling
This commit is contained in:
parent
c3163f017e
commit
5b27c8e6a3
@ -317,7 +317,8 @@ name:
|
||||
1: ; \
|
||||
popl %edx ; \
|
||||
2: ; \
|
||||
addl $_GLOBAL_OFFSET_TABLE_+(2b-1b),%edx
|
||||
addl $_GLOBAL_OFFSET_TABLE_+(2b-1b),%edx ; \
|
||||
movl var@GOT(%edx), %edx
|
||||
|
||||
#endif // DARLING
|
||||
#elif defined(__x86_64__)
|
||||
@ -383,12 +384,24 @@ L ## var ## __non_lazy_ptr: ; \
|
||||
#endif
|
||||
|
||||
#if defined(__i386__)
|
||||
#ifndef DARLING
|
||||
#define EXTERN_TO_REG(var, reg) \
|
||||
call 1f ; \
|
||||
1: ; \
|
||||
popl %edx ; \
|
||||
movl L ## var ##__non_lazy_ptr-1b(%edx),reg ; \
|
||||
NON_LAZY_STUB(var)
|
||||
#else // DARLING
|
||||
#define EXTERN_TO_REG(var, reg) \
|
||||
call 1f ; \
|
||||
1: ; \
|
||||
popl %edx ; \
|
||||
2: ; \
|
||||
addl $_GLOBAL_OFFSET_TABLE_+(2b-1b),%edx ; \
|
||||
movl var@GOT(%edx), %edx; \
|
||||
movl (%edx), reg
|
||||
#endif
|
||||
|
||||
#elif defined(__x86_64__)
|
||||
#define EXTERN_TO_REG(var, reg) \
|
||||
PICIFY(var) ; \
|
||||
|
@ -50,6 +50,10 @@ extern uint8_t __commpage[];
|
||||
#define _COMM_PAGE_APPROX_TIME_SUPPORTED (_COMM_PAGE_START_ADDRESS+0x080)
|
||||
#define _COMM_PAGE_APPROX_TIME (_COMM_PAGE_START_ADDRESS+0x088)
|
||||
|
||||
#define _COMM_TEXT_PFZ_ENQUEUE_OFFSET (_COMM_PAGE_START_ADDRESS+0xc00)
|
||||
#define _COMM_TEXT_PFZ_DEQUEUE_OFFSET (_COMM_PAGE_START_ADDRESS+0xc80)
|
||||
#define _COMM_TEXT_PFZ_MUTEX_LOCK_OFFSET (_COMM_PAGE_START_ADDRESS+0xd00)
|
||||
|
||||
#define _COMM_PAGE_END (_COMM_PAGE_START_ADDRESS+0xfff) /* end of common page */
|
||||
|
||||
#define _COMM_PAGE_TEXT_START (_COMM_PAGE_START_ADDRESS+0x1000)
|
||||
|
2
src/external/corefoundation
vendored
2
src/external/corefoundation
vendored
@ -1 +1 @@
|
||||
Subproject commit 782a332a0cdf04834981df12beeb0fa7eb064a95
|
||||
Subproject commit 57f42c2752b68629bda6fbde8fdeb30453fc756f
|
2
src/external/curl
vendored
2
src/external/curl
vendored
@ -1 +1 @@
|
||||
Subproject commit 7e51b6d6cfe230916d620dafa888762a9ede723e
|
||||
Subproject commit a15187d0687accd97b584fd205feec20fdd94101
|
2
src/external/foundation
vendored
2
src/external/foundation
vendored
@ -1 +1 @@
|
||||
Subproject commit 0fee49f16e008b5046d54cf649694b9a0b4e3898
|
||||
Subproject commit 2bb615310ff8e3cdfab03d8f7e4ea7ec6309fe64
|
2
src/external/libcxx
vendored
2
src/external/libcxx
vendored
@ -1 +1 @@
|
||||
Subproject commit 44232bda542408bfad97e5dbaa7afd259dac5f15
|
||||
Subproject commit 9056f5b88e2aff578e9c91281862b9db568cc4e3
|
2
src/external/libcxxabi
vendored
2
src/external/libcxxabi
vendored
@ -1 +1 @@
|
||||
Subproject commit 83ad1e2950e5f293b372f40ed4d12bd08baa9f00
|
||||
Subproject commit 462493b5bbb522440ed446e60336aecced8f9270
|
2
src/external/libdispatch
vendored
2
src/external/libdispatch
vendored
@ -1 +1 @@
|
||||
Subproject commit 3b1795bac32b89db60da6b65585616a427000d73
|
||||
Subproject commit c8e3382df77e6bc44b6831ba5aca5e37109d97a0
|
2
src/external/libobjc2
vendored
2
src/external/libobjc2
vendored
@ -1 +1 @@
|
||||
Subproject commit 8a615053eb14b4d8153a3933fd3ff3c28731bf61
|
||||
Subproject commit 89b8c94f7b0e1a3d149bc7a496d4cfdc1513200c
|
@ -45,6 +45,7 @@ set(emulation_sources
|
||||
unistd/getpid.c
|
||||
unistd/lseek.c
|
||||
unistd/ftruncate.c
|
||||
unistd/truncate.c
|
||||
unistd/access.c
|
||||
unistd/readlink.c
|
||||
unistd/symlink.c
|
||||
@ -54,6 +55,7 @@ set(emulation_sources
|
||||
unistd/mknod.c
|
||||
unistd/chmod.c
|
||||
unistd/chown.c
|
||||
unistd/lchown.c
|
||||
unistd/umask.c
|
||||
unistd/chroot.c
|
||||
unistd/getgid.c
|
||||
|
@ -15,12 +15,43 @@ long linux_syscall(long a1, long a2, long a3, long a4, long a5, long a6, int nr)
|
||||
"ret");
|
||||
}
|
||||
#elif defined(__i386__)
|
||||
__attribute__((naked))
|
||||
long linux_syscall(long a1, long a2, long a3, long a4, long a5, long a6, int nr)
|
||||
{
|
||||
__asm__("sysenter\n"
|
||||
/*
|
||||
__asm__("push %%ecx\n"
|
||||
"push %%edx\n"
|
||||
"push %%ebp\n"
|
||||
"movl %%esp, %%ebp\n"
|
||||
"sysenter\n"
|
||||
"ret\n"
|
||||
:: "a"(nr), "b" (a1), "c"(a2), "d"(a3),
|
||||
"S"(a4), "D"(a5), "ebp"(a6));
|
||||
__builtin_unreachable();
|
||||
*/
|
||||
__asm__("push %ebp\n"
|
||||
"call 1f\n"
|
||||
"1:\n"
|
||||
"pop %ebp\n"
|
||||
"addl $(2f-1b), %ebp\n"
|
||||
"push %ebp\n"
|
||||
"push %ecx\n"
|
||||
"push %edx\n"
|
||||
"movl 28+16(%esp), %eax\n"
|
||||
"movl 4+16(%esp), %ebx\n"
|
||||
"movl 8+16(%esp), %ecx\n"
|
||||
"movl 12+16(%esp), %edx\n"
|
||||
"movl 16+16(%esp), %esi\n"
|
||||
"movl 20+16(%esp), %edi\n"
|
||||
"push %ebp\n"
|
||||
"movl 24+16(%esp), %ebp\n"
|
||||
"movl %ebp, -4(%esp)\n"
|
||||
"movl %esp, %ebp\n"
|
||||
"sysenter\n"
|
||||
"2:\n"
|
||||
"pop %ebp\n"
|
||||
"ret"
|
||||
);
|
||||
}
|
||||
#else
|
||||
# error Unsupported platform!
|
||||
|
@ -82,7 +82,11 @@ long sys_fcntl_nocancel(int fd, int cmd, long arg)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
#ifdef __NR_fcntl64
|
||||
ret = LINUX_SYSCALL(__NR_fcntl64, fd, linux_cmd, arg);
|
||||
#else
|
||||
ret = LINUX_SYSCALL(__NR_fcntl, fd, linux_cmd, arg);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = errno_linux_to_bsd(ret);
|
||||
|
@ -16,7 +16,7 @@ long sys_accept_nocancel(int fd, void* from, int* socklen)
|
||||
struct sockaddr_fixup* fixed;
|
||||
|
||||
#ifdef __NR_socketcall
|
||||
ret = LINUX_SYSCALL(__NR_socketcall, LINUX_SYS_ACCEPT, fd, from, socklen);
|
||||
ret = LINUX_SYSCALL(__NR_socketcall, LINUX_SYS_ACCEPT, ((long[6]) { fd, from, socklen }));
|
||||
#else
|
||||
ret = LINUX_SYSCALL(__NR_accept, fd, from, socklen);
|
||||
#endif
|
||||
|
@ -28,7 +28,7 @@ long sys_connect_nocancel(int fd, const void* name, int socklen)
|
||||
fixed->linux_family = sfamily_bsd_to_linux(fixed->bsd_family);
|
||||
|
||||
#ifdef __NR_socketcall
|
||||
ret = LINUX_SYSCALL(__NR_socketcall, LINUX_SYS_CONNECT, fd, fixed, socklen);
|
||||
ret = LINUX_SYSCALL(__NR_socketcall, LINUX_SYS_CONNECT, ((long[6]) { fd, fixed, socklen }));
|
||||
#else
|
||||
ret = LINUX_SYSCALL(__NR_connect, fd, fixed, socklen);
|
||||
#endif
|
||||
|
@ -10,7 +10,8 @@ long sys_getpeername(int fd, void* asa, int* socklen)
|
||||
struct sockaddr_fixup* fixed;
|
||||
|
||||
#ifdef __NR_socketcall
|
||||
ret = LINUX_SYSCALL(__NR_socketcall, LINUX_SYS_GETPEERNAME, fd, asa, socklen);
|
||||
ret = LINUX_SYSCALL(__NR_socketcall, LINUX_SYS_GETPEERNAME,
|
||||
((long[6]) { fd, asa, socklen }));
|
||||
#else
|
||||
ret = LINUX_SYSCALL(__NR_getpeername, fd, asa, socklen);
|
||||
#endif
|
||||
|
@ -10,7 +10,8 @@ long sys_getsockname(int fd, void* asa, int* socklen)
|
||||
struct sockaddr_fixup* fixed;
|
||||
|
||||
#ifdef __NR_socketcall
|
||||
ret = LINUX_SYSCALL(__NR_socketcall, LINUX_SYS_GETSOCKNAME, fd, asa, socklen);
|
||||
ret = LINUX_SYSCALL(__NR_socketcall, LINUX_SYS_GETSOCKNAME,
|
||||
((long[6]) { fd, asa, socklen }));
|
||||
#else
|
||||
ret = LINUX_SYSCALL(__NR_getsockname, fd, asa, socklen);
|
||||
#endif
|
||||
|
@ -22,8 +22,8 @@ long sys_recvfrom_nocancel(int fd, void* buf, unsigned long len,
|
||||
linux_flags = msgflags_bsd_to_linux(flags);
|
||||
|
||||
#ifdef __NR_socketcall
|
||||
ret = LINUX_SYSCALL(__NR_socketcall, LINUX_SYS_RECVFROM, fd, buf, len,
|
||||
flags, from, socklen);
|
||||
ret = LINUX_SYSCALL(__NR_socketcall, LINUX_SYS_RECVFROM, ((long[6]) { fd, buf, len,
|
||||
flags, from, socklen }));
|
||||
#else
|
||||
ret = LINUX_SYSCALL(__NR_connect, fd, buf, len, flags, from, socklen);
|
||||
#endif
|
||||
|
@ -42,7 +42,8 @@ long sys_recvmsg_nocancel(int socket, struct bsd_msghdr* msg, int flags)
|
||||
linux_flags = msgflags_bsd_to_linux(flags);
|
||||
|
||||
#ifdef __NR_socketcall
|
||||
ret = LINUX_SYSCALL(__NR_socketcall, LINUX_SYS_RECVMSG, socket, &lmsg, linux_flags);
|
||||
ret = LINUX_SYSCALL(__NR_socketcall, LINUX_SYS_RECVMSG,
|
||||
((long[6]) { socket, &lmsg, linux_flags }));
|
||||
#else
|
||||
ret = LINUX_SYSCALL(__NR_recvmsg, socket, &lmsg, linux_flags);
|
||||
#endif
|
||||
|
@ -53,7 +53,8 @@ long sys_sendmsg_nocancel(int socket, const struct bsd_msghdr* msg, int flags)
|
||||
linux_flags = msgflags_bsd_to_linux(flags);
|
||||
|
||||
#ifdef __NR_socketcall
|
||||
ret = LINUX_SYSCALL(__NR_socketcall, LINUX_SYS_SENDMSG, socket, &lmsg, linux_flags);
|
||||
ret = LINUX_SYSCALL(__NR_socketcall, LINUX_SYS_SENDMSG,
|
||||
((long[6]) { socket, &lmsg, linux_flags }));
|
||||
#else
|
||||
ret = LINUX_SYSCALL(__NR_recvmsg, socket, &lmsg, linux_flags);
|
||||
#endif
|
||||
|
@ -10,7 +10,8 @@ long sys_shutdown(int fd, int how)
|
||||
int ret;
|
||||
|
||||
#ifdef __NR_socketcall
|
||||
ret = LINUX_SYSCALL(__NR_socketcall, LINUX_SYS_SHUTDOWN, fd, how);
|
||||
ret = LINUX_SYSCALL(__NR_socketcall, LINUX_SYS_SHUTDOWN,
|
||||
((long[6]) { fd, how }));
|
||||
#else
|
||||
ret = LINUX_SYSCALL(__NR_shutdown, fd, how);
|
||||
#endif
|
||||
|
@ -26,7 +26,8 @@ long sys_socket(int domain, int type, int protocol)
|
||||
}
|
||||
|
||||
#ifdef __NR_socketcall
|
||||
ret = LINUX_SYSCALL(__NR_socketcall, LINUX_SYS_SOCKET, linux_domain, type, protocol);
|
||||
ret = LINUX_SYSCALL(__NR_socketcall, LINUX_SYS_SOCKET,
|
||||
((long[6]) { linux_domain, type, protocol }));
|
||||
#else
|
||||
ret = LINUX_SYSCALL(__NR_socket, linux_domain, type, protocol);
|
||||
#endif
|
||||
|
@ -20,8 +20,13 @@ long sys_select_nocancel(int nfds, void* rfds, void* wfds, void* efds, struct bs
|
||||
ltv.tv_usec = timeout->tv_usec;
|
||||
}
|
||||
|
||||
#ifdef __NR__newselect
|
||||
ret = LINUX_SYSCALL(__NR__newselect, nfds, rfds, wfds, efds,
|
||||
(timeout != NULL) ? <v : NULL);
|
||||
#else
|
||||
ret = LINUX_SYSCALL(__NR_select, nfds, rfds, wfds, efds,
|
||||
(timeout != NULL) ? <v : NULL);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
ret = errno_linux_to_bsd(ret);
|
||||
|
||||
|
@ -16,25 +16,37 @@ __darling_bsd_syscall:
|
||||
|
||||
#elif defined(__i386__)
|
||||
|
||||
#define copy_arg(off) \
|
||||
movl 8+off(%esp), %ecx ;\
|
||||
movl %ecx, -24+off(%esp)
|
||||
|
||||
__darling_bsd_syscall:
|
||||
calll .L0$pb
|
||||
calll .L0$pb
|
||||
.L0$pb:
|
||||
popl %ecx
|
||||
popl %ecx
|
||||
.Ltmp0:
|
||||
addl $_GLOBAL_OFFSET_TABLE_+(.Ltmp0-.L0$pb), %ecx
|
||||
movl __bsd_syscall_table@GOT(%eax), %eax
|
||||
movl (%eax), %eax
|
||||
movl 8(%esp), %ecx
|
||||
movl (%eax,%ecx,4), %eax
|
||||
test %eax, %eax
|
||||
jz .no_sys
|
||||
call *%eax
|
||||
ret
|
||||
addl $_GLOBAL_OFFSET_TABLE_+(.Ltmp0-.L0$pb), %ecx
|
||||
movl __bsd_syscall_table@GOT(%ecx), %ecx
|
||||
andl $0xffff, %eax // Because there is some extra stuff in upper bytes we don't need
|
||||
movl (%ecx,%eax,4), %eax
|
||||
test %eax, %eax
|
||||
jz .no_sys
|
||||
// Copy arguments
|
||||
copy_arg(0)
|
||||
copy_arg(4)
|
||||
copy_arg(8)
|
||||
copy_arg(12)
|
||||
copy_arg(16)
|
||||
copy_arg(20)
|
||||
subl $24, %esp
|
||||
call *%eax
|
||||
addl $24, %esp
|
||||
ret
|
||||
.no_sys:
|
||||
pushl %ecx
|
||||
call __unknown_syscall@PLT
|
||||
addl $4, %esp
|
||||
ret
|
||||
pushl %ecx
|
||||
call __unknown_syscall@PLT
|
||||
addl $4, %esp
|
||||
ret
|
||||
|
||||
#else
|
||||
# error Missing assembly
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "unistd/getpid.h"
|
||||
#include "unistd/access.h"
|
||||
#include "unistd/lseek.h"
|
||||
#include "unistd/truncate.h"
|
||||
#include "unistd/ftruncate.h"
|
||||
#include "unistd/readlink.h"
|
||||
#include "unistd/readv.h"
|
||||
@ -40,6 +41,7 @@
|
||||
#include "unistd/mknod.h"
|
||||
#include "unistd/chmod.h"
|
||||
#include "unistd/chown.h"
|
||||
#include "unistd/lchown.h"
|
||||
#include "unistd/getgid.h"
|
||||
#include "unistd/getppid.h"
|
||||
#include "unistd/rename.h"
|
||||
@ -204,6 +206,7 @@ void* __bsd_syscall_table[512] = {
|
||||
[196] = sys_getdirentries,
|
||||
[197] = sys_mmap,
|
||||
[199] = sys_lseek,
|
||||
[200] = sys_truncate,
|
||||
[201] = sys_ftruncate,
|
||||
[202] = sys_sysctl,
|
||||
[216] = sys_mkcomplex,
|
||||
@ -245,6 +248,7 @@ void* __bsd_syscall_table[512] = {
|
||||
[347] = sys_getfsstat64,
|
||||
[360] = sys_bsdthread_create,
|
||||
[361] = sys_bsdthread_terminate,
|
||||
[364] = sys_lchown,
|
||||
[366] = sys_bsdthread_register,
|
||||
[367] = sys_workq_open,
|
||||
[368] = sys_workq_kernreturn,
|
||||
|
@ -8,8 +8,11 @@ long sys_chown(const char* path, int uid, int gid)
|
||||
int ret;
|
||||
|
||||
// TODO: case translation
|
||||
|
||||
#ifdef __NR_chown32
|
||||
ret = LINUX_SYSCALL(__NR_chown32, path, uid, gid);
|
||||
#else
|
||||
ret = LINUX_SYSCALL(__NR_chown, path, uid, gid);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
ret = errno_linux_to_bsd(ret);
|
||||
|
||||
|
@ -7,7 +7,11 @@ long sys_fchown(int fd, int uid, int gid)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#ifdef __NR_fchown32
|
||||
ret = LINUX_SYSCALL3(__NR_fchown32, fd, uid, gid);
|
||||
#else
|
||||
ret = LINUX_SYSCALL3(__NR_fchown, fd, uid, gid);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
ret = errno_linux_to_bsd(ret);
|
||||
|
||||
|
@ -7,7 +7,11 @@ long sys_ftruncate(int fd, long long length)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#ifdef __NR_ftruncate64
|
||||
ret = LINUX_SYSCALL(__NR_ftruncate64, fd, LL_ARG(length));
|
||||
#else
|
||||
ret = LINUX_SYSCALL(__NR_ftruncate, fd, LL_ARG(length));
|
||||
#endif
|
||||
if (ret < 0)
|
||||
ret = errno_linux_to_bsd(ret);
|
||||
|
||||
|
@ -7,7 +7,11 @@ long sys_getegid(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#ifdef __NR_getegid32
|
||||
ret = LINUX_SYSCALL0(__NR_getegid32);
|
||||
#else
|
||||
ret = LINUX_SYSCALL0(__NR_getegid);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
ret = errno_linux_to_bsd(ret);
|
||||
|
||||
|
@ -7,7 +7,11 @@ long sys_geteuid(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#ifdef __NR_geteuid32
|
||||
ret = LINUX_SYSCALL0(__NR_geteuid32);
|
||||
#else
|
||||
ret = LINUX_SYSCALL0(__NR_geteuid);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
ret = errno_linux_to_bsd(ret);
|
||||
|
||||
|
@ -7,7 +7,11 @@ long sys_getgid(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#ifdef __NR_getgid32
|
||||
ret = LINUX_SYSCALL0(__NR_getgid32);
|
||||
#else
|
||||
ret = LINUX_SYSCALL0(__NR_getgid);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
ret = errno_linux_to_bsd(ret);
|
||||
|
||||
|
@ -7,7 +7,11 @@ long sys_getgroups(unsigned int size, int* gidset)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#ifdef __NR_getgroups32
|
||||
ret = LINUX_SYSCALL(__NR_getgroups32, size, gidset);
|
||||
#else
|
||||
ret = LINUX_SYSCALL(__NR_getgroups, size, gidset);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
ret = errno_linux_to_bsd(ret);
|
||||
|
||||
|
@ -7,7 +7,11 @@ long sys_getuid(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#ifdef __NR_getuid32
|
||||
ret = LINUX_SYSCALL0(__NR_getuid32);
|
||||
#else
|
||||
ret = LINUX_SYSCALL0(__NR_getuid);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
ret = errno_linux_to_bsd(ret);
|
||||
|
||||
|
21
src/kernel/emulation/linux/unistd/lchown.c
Normal file
21
src/kernel/emulation/linux/unistd/lchown.c
Normal file
@ -0,0 +1,21 @@
|
||||
#include "lchown.h"
|
||||
#include "../base.h"
|
||||
#include "../errno.h"
|
||||
#include <asm/unistd.h>
|
||||
|
||||
long sys_lchown(const char* path, int uid, int gid)
|
||||
{
|
||||
int ret;
|
||||
|
||||
// TODO: case translation
|
||||
#ifdef __NR_chown32
|
||||
ret = LINUX_SYSCALL(__NR_lchown32, path, uid, gid);
|
||||
#else
|
||||
ret = LINUX_SYSCALL(__NR_lchown, path, uid, gid);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
ret = errno_linux_to_bsd(ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
7
src/kernel/emulation/linux/unistd/lchown.h
Normal file
7
src/kernel/emulation/linux/unistd/lchown.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef LINUX_LCHOWN_H
|
||||
#define LINUX_LCHOWN_H
|
||||
|
||||
long sys_lchown(const char* path, int uid, int gid);
|
||||
|
||||
#endif
|
||||
|
@ -7,7 +7,11 @@ long sys_setgid(int gid)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#ifdef __NR_setgid32
|
||||
ret = LINUX_SYSCALL1(__NR_setgid32, gid);
|
||||
#else
|
||||
ret = LINUX_SYSCALL1(__NR_setgid, gid);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
ret = errno_linux_to_bsd(ret);
|
||||
|
||||
|
@ -7,7 +7,11 @@ long sys_setgroups(unsigned int size, int* gidset)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#ifdef __NR_setgroups32
|
||||
ret = LINUX_SYSCALL(__NR_setgroups32, size, gidset);
|
||||
#else
|
||||
ret = LINUX_SYSCALL(__NR_setgroups, size, gidset);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
ret = errno_linux_to_bsd(ret);
|
||||
|
||||
|
@ -7,7 +7,11 @@ long sys_setuid(int uid)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#ifdef __NR_setuid32
|
||||
ret = LINUX_SYSCALL1(__NR_setuid32, uid);
|
||||
#else
|
||||
ret = LINUX_SYSCALL1(__NR_setuid, uid);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
ret = errno_linux_to_bsd(ret);
|
||||
|
||||
|
22
src/kernel/emulation/linux/unistd/truncate.c
Normal file
22
src/kernel/emulation/linux/unistd/truncate.c
Normal file
@ -0,0 +1,22 @@
|
||||
#include "truncate.h"
|
||||
#include "../base.h"
|
||||
#include "../errno.h"
|
||||
#include <asm/unistd.h>
|
||||
|
||||
long sys_truncate(const char* path, long long length)
|
||||
{
|
||||
int ret;
|
||||
|
||||
// TODO: translate path
|
||||
|
||||
#ifdef __NR_truncate64
|
||||
ret = LINUX_SYSCALL(__NR_truncate64, path, LL_ARG(length));
|
||||
#else
|
||||
ret = LINUX_SYSCALL(__NR_truncate, path, LL_ARG(length));
|
||||
#endif
|
||||
if (ret < 0)
|
||||
ret = errno_linux_to_bsd(ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
7
src/kernel/emulation/linux/unistd/truncate.h
Normal file
7
src/kernel/emulation/linux/unistd/truncate.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef LINUX_TRUNCATE_H
|
||||
#define LINUX_TRUNCATE_H
|
||||
|
||||
long sys_truncate(const char* path, long long length);
|
||||
|
||||
#endif
|
||||
|
@ -550,6 +550,7 @@ set (syscall_sources ${syscall_sources}
|
||||
sys_x86-64/writev.S
|
||||
)
|
||||
elseif(BITS EQUAL 32)
|
||||
|
||||
set (syscall_sources ${syscall_sources}
|
||||
sys_i386/__accept_nocancel.S
|
||||
sys_i386/__accept.S
|
||||
|
@ -72,7 +72,7 @@
|
||||
#ifndef DARLING
|
||||
#define UNIX_SYSCALL_SYSENTER call __sysenter_trap
|
||||
#else
|
||||
#define UNIX_SYSCALL_SYSENTER call __darling_bsd_syscall@PLT
|
||||
#define UNIX_SYSCALL_SYSENTER call __darling_bsd_syscall
|
||||
#endif
|
||||
|
||||
#define UNIX_SYSCALL(name, nargs) \
|
||||
@ -80,42 +80,47 @@
|
||||
LEAF(_##name, 0) ;\
|
||||
movl $ SYS_##name, %eax ;\
|
||||
UNIX_SYSCALL_SYSENTER ;\
|
||||
jnb 2f ;\
|
||||
cmpl $-4095, %eax ;\
|
||||
jb 3f ;\
|
||||
BRANCH_EXTERN(tramp_cerror) ;\
|
||||
2:
|
||||
3:
|
||||
|
||||
#define UNIX_SYSCALL_INT(name, nargs) \
|
||||
.globl tramp_cerror ;\
|
||||
LEAF(_##name, 0) ;\
|
||||
movl $ SYS_##name, %eax ;\
|
||||
UNIX_SYSCALL_TRAP ;\
|
||||
jnb 2f ;\
|
||||
cmpl $-4095, %eax ;\
|
||||
jb 3f ;\
|
||||
BRANCH_EXTERN(tramp_cerror) ;\
|
||||
2:
|
||||
3:
|
||||
|
||||
#if defined(__SYSCALL_32BIT_ARG_BYTES) && ((__SYSCALL_32BIT_ARG_BYTES >= 4) && (__SYSCALL_32BIT_ARG_BYTES <= 20))
|
||||
#define UNIX_SYSCALL_NONAME(name, nargs, cerror) \
|
||||
movl $(SYS_##name | (__SYSCALL_32BIT_ARG_BYTES << I386_SYSCALL_ARG_BYTES_SHIFT)), %eax ;\
|
||||
UNIX_SYSCALL_SYSENTER ;\
|
||||
jnb 2f ;\
|
||||
cmpl $-4095, %eax ;\
|
||||
jb 3f ;\
|
||||
BRANCH_EXTERN(tramp_##cerror) ;\
|
||||
2:
|
||||
3:
|
||||
#else /* __SYSCALL_32BIT_ARG_BYTES < 4 || > 20 */
|
||||
#define UNIX_SYSCALL_NONAME(name, nargs, cerror) \
|
||||
movl $ SYS_##name, %eax ;\
|
||||
UNIX_SYSCALL_SYSENTER ;\
|
||||
jnb 2f ;\
|
||||
cmpl $-4095, %eax ;\
|
||||
jb 3f ;\
|
||||
BRANCH_EXTERN(tramp_##cerror) ;\
|
||||
2:
|
||||
3:
|
||||
#endif
|
||||
|
||||
#define UNIX_SYSCALL_INT_NONAME(name, nargs) \
|
||||
.globl tramp_cerror_nocancel ;\
|
||||
movl $ SYS_##name, %eax ;\
|
||||
UNIX_SYSCALL_TRAP ;\
|
||||
jnb 2f ;\
|
||||
cmpl $-4095, %eax ;\
|
||||
jb 3f ;\
|
||||
BRANCH_EXTERN(tramp_cerror_nocancel) ;\
|
||||
2:
|
||||
3:
|
||||
|
||||
#define PSEUDO(pseudo, name, nargs, cerror) \
|
||||
LEAF(pseudo, 0) ;\
|
||||
@ -149,19 +154,21 @@ LEAF(pseudo, 0) ;\
|
||||
LEAF(name, 0) ;\
|
||||
movl $ SYS_##name, %eax ;\
|
||||
call __darling_bsd_syscall@PLT ;\
|
||||
jnb 2f ;\
|
||||
cmpl $-4095, %eax ;\
|
||||
jb 3f ;\
|
||||
movq %rax, %rdi ;\
|
||||
BRANCH_EXTERN(cerror) ;\
|
||||
2:
|
||||
3:
|
||||
|
||||
#define UNIX_SYSCALL_NONAME(name, nargs, cerror) \
|
||||
.globl cerror ;\
|
||||
movl $ SYS_##name, %eax ;\
|
||||
call __darling_bsd_syscall@PLT ;\
|
||||
jnb 2f ;\
|
||||
cmpl $-4095, %eax ;\
|
||||
jb 3f ;\
|
||||
movq %rax, %rdi ;\
|
||||
BRANCH_EXTERN(cerror) ;\
|
||||
2:
|
||||
3:
|
||||
|
||||
|
||||
#else
|
||||
|
@ -49,26 +49,26 @@
|
||||
#define GET_CURRENT_PID PICIFY(__current_pid)
|
||||
|
||||
NON_LAZY_STUB(__current_pid)
|
||||
#define __current_pid (%edx)
|
||||
#define __current_pid_var (%edx)
|
||||
#else
|
||||
#define GET_CURRENT_PID
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If __current_pid >= 0, we want to put a -1 in there
|
||||
* If __current_pid_var >= 0, we want to put a -1 in there
|
||||
* otherwise we just decrement it
|
||||
*/
|
||||
|
||||
LEAF(___vfork, 0)
|
||||
GET_CURRENT_PID
|
||||
movl __current_pid, %eax
|
||||
movl __current_pid_var, %eax
|
||||
0:
|
||||
xorl %ecx, %ecx
|
||||
testl %eax, %eax
|
||||
cmovs %eax, %ecx
|
||||
decl %ecx
|
||||
lock
|
||||
cmpxchgl %ecx, __current_pid
|
||||
cmpxchgl %ecx, __current_pid_var
|
||||
jne 0b
|
||||
popl %ecx
|
||||
movl $(SYS_vfork), %eax // code for vfork -> eax
|
||||
@ -76,7 +76,7 @@ LEAF(___vfork, 0)
|
||||
jnb L1 // jump if CF==0
|
||||
GET_CURRENT_PID
|
||||
lock
|
||||
incl __current_pid
|
||||
incl __current_pid_var
|
||||
pushl %ecx
|
||||
BRANCH_EXTERN(tramp_cerror)
|
||||
|
||||
@ -89,25 +89,25 @@ L1:
|
||||
L2:
|
||||
GET_CURRENT_PID
|
||||
lock
|
||||
incl __current_pid
|
||||
incl __current_pid_var
|
||||
jmp *%ecx
|
||||
|
||||
#elif defined(__x86_64__)
|
||||
|
||||
/*
|
||||
* If __current_pid >= 0, we want to put a -1 in there
|
||||
* If __current_pid_var >= 0, we want to put a -1 in there
|
||||
* otherwise we just decrement it
|
||||
*/
|
||||
|
||||
LEAF(___vfork, 0)
|
||||
movq __current_pid@GOTPCREL(%rip), %rax
|
||||
movq __current_pid_var@GOTPCREL(%rip), %rax
|
||||
movl (%rax), %eax
|
||||
0:
|
||||
xorl %ecx, %ecx
|
||||
testl %eax, %eax
|
||||
cmovs %eax, %ecx
|
||||
subl $1, %ecx
|
||||
movq __current_pid@GOTPCREL(%rip), %rdx
|
||||
movq __current_pid_var@GOTPCREL(%rip), %rdx
|
||||
lock
|
||||
cmpxchgl %ecx, (%rdx)
|
||||
jne 0b
|
||||
@ -116,7 +116,7 @@ LEAF(___vfork, 0)
|
||||
UNIX_SYSCALL_TRAP // do the system call
|
||||
jnb L1 // jump if CF==0
|
||||
pushq %rdi // put return address back on stack for cerror
|
||||
movq __current_pid@GOTPCREL(%rip), %rcx
|
||||
movq __current_pid_var@GOTPCREL(%rip), %rcx
|
||||
lock
|
||||
addq $1, (%rcx)
|
||||
movq %rax, %rdi
|
||||
@ -129,7 +129,7 @@ L1:
|
||||
jmp *%rdi
|
||||
|
||||
L2:
|
||||
movq __current_pid@GOTPCREL(%rip), %rdx
|
||||
movq __current_pid_var@GOTPCREL(%rip), %rdx
|
||||
lock
|
||||
addq $1, (%rdx)
|
||||
jmp *%rdi
|
||||
|
@ -1,6 +1,15 @@
|
||||
#define __SYSCALL_32BIT_ARG_BYTES 12
|
||||
#include "SYS.h"
|
||||
|
||||
#ifndef SYS_aio_suspend
|
||||
#error "SYS_aio_suspend not defined. The header files libsyscall is building against do not match syscalls.master."
|
||||
#endif
|
||||
|
||||
#if defined(__i386__)
|
||||
__SYSCALL2(__aio_suspend, aio_suspend, 1, cerror)
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__i386__)
|
||||
.globl aio_suspend$UNIX2003
|
||||
aio_suspend$UNIX2003 = __aio_suspend
|
||||
|
@ -1,6 +1,14 @@
|
||||
#define __SYSCALL_32BIT_ARG_BYTES 4
|
||||
#include "SYS.h"
|
||||
|
||||
#ifndef SYS_close
|
||||
#error "SYS_close not defined. The header files libsyscall is building against do not match syscalls.master."
|
||||
#endif
|
||||
|
||||
#if defined(__i386__)
|
||||
__SYSCALL2(__close, close, 1, cerror)
|
||||
#endif
|
||||
|
||||
#if defined(__i386__)
|
||||
.globl close$UNIX2003
|
||||
close$UNIX2003 = __close
|
||||
|
@ -1,6 +1,15 @@
|
||||
#define __SYSCALL_32BIT_ARG_BYTES 4
|
||||
#include "SYS.h"
|
||||
|
||||
#ifndef SYS_fsync
|
||||
#error "SYS_fsync not defined. The header files libsyscall is building against do not match syscalls.master."
|
||||
#endif
|
||||
|
||||
#if defined(__i386__)
|
||||
__SYSCALL2(__fsync, fsync, 1, cerror)
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__i386__)
|
||||
.globl fsync$UNIX2003
|
||||
fsync$UNIX2003 = __fsync
|
||||
|
@ -1,6 +1,15 @@
|
||||
#define __SYSCALL_32BIT_ARG_BYTES 20
|
||||
#include "SYS.h"
|
||||
|
||||
#ifndef SYS_msgrcv
|
||||
#error "SYS_msgrcv not defined. The header files libsyscall is building against do not match syscalls.master."
|
||||
#endif
|
||||
|
||||
#if defined(__i386__)
|
||||
__SYSCALL2(__msgrcv, msgrcv, 1, cerror)
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__i386__)
|
||||
.globl msgrcv$UNIX2003
|
||||
msgrcv$UNIX2003 = __msgrcv
|
||||
|
@ -1,6 +1,15 @@
|
||||
#define __SYSCALL_32BIT_ARG_BYTES 16
|
||||
#include "SYS.h"
|
||||
|
||||
#ifndef SYS_msgsnd
|
||||
#error "SYS_msgsnd not defined. The header files libsyscall is building against do not match syscalls.master."
|
||||
#endif
|
||||
|
||||
#if defined(__i386__)
|
||||
__SYSCALL2(__msgsnd, msgsnd, 1, cerror)
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__i386__)
|
||||
.globl msgsnd$UNIX2003
|
||||
msgsnd$UNIX2003 = __msgsnd
|
||||
|
@ -1,6 +1,15 @@
|
||||
#define __SYSCALL_32BIT_ARG_BYTES 12
|
||||
#include "SYS.h"
|
||||
|
||||
#ifndef SYS_poll
|
||||
#error "SYS_poll not defined. The header files libsyscall is building against do not match syscalls.master."
|
||||
#endif
|
||||
|
||||
#if defined(__i386__)
|
||||
__SYSCALL2(__poll, poll, 1, cerror)
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__i386__)
|
||||
.globl poll$UNIX2003
|
||||
poll$UNIX2003 = __poll
|
||||
|
@ -1,6 +1,15 @@
|
||||
#define __SYSCALL_32BIT_ARG_BYTES 20
|
||||
#include "SYS.h"
|
||||
|
||||
#ifndef SYS_pread
|
||||
#error "SYS_pread not defined. The header files libsyscall is building against do not match syscalls.master."
|
||||
#endif
|
||||
|
||||
#if defined(__i386__)
|
||||
__SYSCALL2(__pread, pread, 1, cerror)
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__i386__)
|
||||
.globl pread$UNIX2003
|
||||
pread$UNIX2003 = __pread
|
||||
|
@ -1,6 +1,15 @@
|
||||
#define __SYSCALL_32BIT_ARG_BYTES 20
|
||||
#include "SYS.h"
|
||||
|
||||
#ifndef SYS_pwrite
|
||||
#error "SYS_pwrite not defined. The header files libsyscall is building against do not match syscalls.master."
|
||||
#endif
|
||||
|
||||
#if defined(__i386__)
|
||||
__SYSCALL2(__pwrite, pwrite, 1, cerror)
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__i386__)
|
||||
.globl pwrite$UNIX2003
|
||||
pwrite$UNIX2003 = __pwrite
|
||||
|
@ -1,6 +1,15 @@
|
||||
#define __SYSCALL_32BIT_ARG_BYTES 12
|
||||
#include "SYS.h"
|
||||
|
||||
#ifndef SYS_read
|
||||
#error "SYS_read not defined. The header files libsyscall is building against do not match syscalls.master."
|
||||
#endif
|
||||
|
||||
#if defined(__i386__)
|
||||
__SYSCALL2(__read, read, 1, cerror)
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__i386__)
|
||||
.globl read$UNIX2003
|
||||
read$UNIX2003 = __read
|
||||
|
@ -1,6 +1,15 @@
|
||||
#define __SYSCALL_32BIT_ARG_BYTES 12
|
||||
#include "SYS.h"
|
||||
|
||||
#ifndef SYS_readv
|
||||
#error "SYS_readv not defined. The header files libsyscall is building against do not match syscalls.master."
|
||||
#endif
|
||||
|
||||
#if defined(__i386__)
|
||||
__SYSCALL2(__readv, readv, 1, cerror)
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__i386__)
|
||||
.globl readv$UNIX2003
|
||||
readv$UNIX2003 = __readv
|
||||
|
@ -1,6 +1,15 @@
|
||||
#define __SYSCALL_32BIT_ARG_BYTES 4
|
||||
#include "SYS.h"
|
||||
|
||||
#ifndef SYS_sem_wait
|
||||
#error "SYS_sem_wait not defined. The header files libsyscall is building against do not match syscalls.master."
|
||||
#endif
|
||||
|
||||
#if defined(__i386__)
|
||||
__SYSCALL2(__sem_wait, sem_wait, 1, cerror)
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__i386__)
|
||||
.globl sem_wait$UNIX2003
|
||||
sem_wait$UNIX2003 = __sem_wait
|
||||
|
@ -1,6 +1,15 @@
|
||||
#define __SYSCALL_32BIT_ARG_BYTES 16
|
||||
#include "SYS.h"
|
||||
|
||||
#ifndef SYS_waitid
|
||||
#error "SYS_waitid not defined. The header files libsyscall is building against do not match syscalls.master."
|
||||
#endif
|
||||
|
||||
#if defined(__i386__)
|
||||
__SYSCALL2(__waitid, waitid, 1, cerror)
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__i386__)
|
||||
.globl waitid$UNIX2003
|
||||
waitid$UNIX2003 = __waitid
|
||||
|
@ -1,6 +1,15 @@
|
||||
#define __SYSCALL_32BIT_ARG_BYTES 12
|
||||
#include "SYS.h"
|
||||
|
||||
#ifndef SYS_write
|
||||
#error "SYS_write not defined. The header files libsyscall is building against do not match syscalls.master."
|
||||
#endif
|
||||
|
||||
#if defined(__i386__)
|
||||
__SYSCALL2(__write, write, 1, cerror)
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__i386__)
|
||||
.globl write$UNIX2003
|
||||
write$UNIX2003 = __write
|
||||
|
@ -1,6 +1,15 @@
|
||||
#define __SYSCALL_32BIT_ARG_BYTES 12
|
||||
#include "SYS.h"
|
||||
|
||||
#ifndef SYS_writev
|
||||
#error "SYS_writev not defined. The header files libsyscall is building against do not match syscalls.master."
|
||||
#endif
|
||||
|
||||
#if defined(__i386__)
|
||||
__SYSCALL2(__writev, writev, 1, cerror)
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__i386__)
|
||||
.globl writev$UNIX2003
|
||||
writev$UNIX2003 = __writev
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/_types/_timeval32.h>
|
||||
|
||||
#ifdef UTMP_COMPAT
|
||||
#define UTMP_COMPAT_UTMP0 0x01
|
||||
|
@ -9,15 +9,15 @@ add_definitions(-DPRIVATE)
|
||||
|
||||
set(i386_sources
|
||||
gen/getmcontext.c
|
||||
#gen/makecontext.c
|
||||
#gen/setcontext.c
|
||||
gen/makecontext.c
|
||||
gen/setcontext.c
|
||||
gen/setjmperr.c
|
||||
#gen/swapcontext.c
|
||||
gen/swapcontext.c
|
||||
gen/cpu_number.S
|
||||
gen/icacheinval.S
|
||||
gen/mcount.S
|
||||
gen/_ctx_start.S
|
||||
#gen/getcontext.S
|
||||
gen/getcontext.S
|
||||
gen/_setcontext.S
|
||||
|
||||
# sys/i386_gettimeofday_asm.S
|
||||
@ -55,11 +55,11 @@ set(i386_sources
|
||||
string/memcpy.c
|
||||
string/memmove.c
|
||||
|
||||
# pthreads/preempt.S
|
||||
pthreads/preempt.S
|
||||
pthreads/pthread_getspecific.S
|
||||
pthreads/pthread_mutex_lock.S
|
||||
pthreads/pthread_self.S
|
||||
pthreads/pthread_set_self.S
|
||||
#pthreads/pthread_set_self.S
|
||||
pthreads/start_wqthread.S
|
||||
pthreads/thread_start.S
|
||||
pthreads/init_cpu_capabilities.c
|
||||
|
@ -50,6 +50,7 @@
|
||||
.align 4
|
||||
#ifdef DARLING
|
||||
.hidden _cpu_number
|
||||
.globl _cpu_number
|
||||
#else
|
||||
.private_extern _cpu_number
|
||||
#endif
|
||||
|
@ -1,3 +1,4 @@
|
||||
// Modified by Lubos Dolezel for Darling
|
||||
/*
|
||||
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
@ -22,6 +23,10 @@
|
||||
*/
|
||||
#import <architecture/i386/asm_help.h>
|
||||
|
||||
#ifdef DARLING
|
||||
# define _moncount moncount
|
||||
#endif
|
||||
|
||||
.text
|
||||
.globl mcount
|
||||
mcount:
|
||||
|
@ -38,7 +38,12 @@
|
||||
* Destroys %eax, %ecx, and %edx.
|
||||
*/
|
||||
.align 4
|
||||
#ifndef DARLING
|
||||
.private_extern _preempt
|
||||
#else
|
||||
.globl _preempt
|
||||
.hidden _preempt
|
||||
#endif
|
||||
_preempt:
|
||||
popl %edx // get return address
|
||||
movl %esp,%ecx // save stack ptr here
|
||||
@ -56,7 +61,12 @@ _preempt:
|
||||
*/
|
||||
|
||||
.align 4
|
||||
#ifndef DARLING
|
||||
.private_extern _backoff
|
||||
#else
|
||||
.globl _backoff
|
||||
.hidden _backoff
|
||||
#endif
|
||||
_backoff:
|
||||
testl %ebx,%ebx // does kernel want to preempt us?
|
||||
jz 1f // no
|
||||
|
@ -1,3 +1,4 @@
|
||||
// Modified by Lubos Dolezel for Darling
|
||||
/*
|
||||
* Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
@ -24,8 +25,13 @@
|
||||
#include <machine/cpu_capabilities.h>
|
||||
#include <architecture/i386/asm_help.h>
|
||||
|
||||
#ifdef DARLING
|
||||
# define _preempt preempt
|
||||
# define _commpage_pfz_base commpage_pfz_base
|
||||
#endif
|
||||
|
||||
.text
|
||||
.align 2
|
||||
.align (1<<2)
|
||||
.globl __commpage_pthread_mutex_lock
|
||||
__commpage_pthread_mutex_lock:
|
||||
pushl %ebp // set up frame for backtrace
|
||||
|
@ -26,11 +26,11 @@
|
||||
|
||||
#ifdef DARLING
|
||||
# define _thread_start thread_start
|
||||
# definie __pthread_start _pthread_start@PLT
|
||||
# define __pthread_start _pthread_start
|
||||
#endif
|
||||
|
||||
.text
|
||||
.align 2, 0x90
|
||||
.align (1<<2), 0x90
|
||||
.globl _thread_start
|
||||
_thread_start:
|
||||
// This routine is never called directly by user code, jumped from kernel
|
||||
|
@ -1,5 +1,6 @@
|
||||
#ifdef DARLING
|
||||
# define ___bzero __bzero
|
||||
# define _bzero bzero
|
||||
#endif
|
||||
|
||||
.globl ___bzero
|
||||
|
@ -1,3 +1,4 @@
|
||||
// Modified by Lubos Dolezel for Darling
|
||||
/*
|
||||
* Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
@ -29,6 +30,10 @@
|
||||
#include <machine/cpu_capabilities.h>
|
||||
#include <platfunc.h>
|
||||
|
||||
#ifdef DARLING
|
||||
# define _longcopy longcopy
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The bcopy/memcpy loops, tuned for Pentium-M class processors with
|
||||
* Supplemental SSE3 and 64-byte cache lines.
|
||||
|
@ -64,6 +64,7 @@
|
||||
#ifndef DARLING
|
||||
.private_extern _longcopy
|
||||
#else
|
||||
.globl _longcopy
|
||||
.hidden _longcopy
|
||||
#endif
|
||||
|
||||
|
@ -51,6 +51,7 @@
|
||||
# define _memset_pattern4 memset_pattern4
|
||||
# define _memset_pattern8 memset_pattern8
|
||||
# define _memset_pattern16 memset_pattern16
|
||||
# define _bzero bzero
|
||||
#endif
|
||||
|
||||
.text
|
||||
|
@ -64,6 +64,7 @@
|
||||
#ifndef DARLING
|
||||
.private_extern _memset_pattern
|
||||
#else
|
||||
.globl _memset_pattern
|
||||
.hidden _memset_pattern
|
||||
#endif
|
||||
_memset_pattern:
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#ifdef DARLING
|
||||
#define _strncpy strncpy
|
||||
#define _bzero bzero
|
||||
#endif
|
||||
|
||||
// *****************
|
||||
|
@ -35,6 +35,8 @@
|
||||
#ifdef DARLING
|
||||
# define _OSAtomicFifoEnqueue OSAtomicFifoEnqueue
|
||||
# define _OSAtomicFifoDequeue OSAtomicFifoDequeue
|
||||
# define _preempt preempt
|
||||
# define _commpage_pfz_base commpage_pfz_base
|
||||
#endif
|
||||
|
||||
#ifndef DARLING
|
||||
|
@ -40,7 +40,7 @@
|
||||
return find_platform_function((const platfunc_descriptor**) symbol ## _platfunc_descriptors); \
|
||||
}
|
||||
#else // ELF doesn't support symbol resolvers
|
||||
#define RESOLVER_UP_MP(symbol) __asm__(".globl " #symbol); __asm__(#symbol ": jmp " #symbol "$VARIANT$mp@PLT");
|
||||
#define RESOLVER_UP_MP(symbol) __asm__(".globl " #symbol); __asm__(#symbol ": jmp " #symbol "$VARIANT$mp");
|
||||
#endif
|
||||
|
||||
RESOLVER_UP_MP(OSAtomicAnd32)
|
||||
|
@ -39,7 +39,7 @@
|
||||
# define _siglongjmp siglongjmp
|
||||
# define x_longjmp longjmp
|
||||
# define x__longjmp _longjmp
|
||||
# define __sigunalstack _sigunaltstack
|
||||
# define __sigunaltstack _sigunaltstack
|
||||
#else
|
||||
# define x_longjmp _longjmp
|
||||
# define x__longjmp __longjmp
|
||||
|
@ -40,7 +40,7 @@
|
||||
return find_platform_function((const platfunc_descriptor**) symbol ## _platfunc_descriptors); \
|
||||
}
|
||||
#else // ELF doesn't support symbol resolvers
|
||||
#define RESOLVER_UP_MP(symbol) __asm__(".globl " #symbol); __asm__(#symbol ": jmp " #symbol "$VARIANT$mp@PLT");
|
||||
#define RESOLVER_UP_MP(symbol) __asm__(".globl " #symbol); __asm__(#symbol ": jmp " #symbol "$VARIANT$mp");
|
||||
#endif
|
||||
|
||||
RESOLVER_UP_MP(OSSpinLockTry)
|
||||
|
@ -127,8 +127,8 @@ PLATFUNC_DESCRIPTOR(_spin_lock,mp,0,kUP)
|
||||
|
||||
.align 2, 0x90
|
||||
.globl _OSSpinLockUnlock
|
||||
.globl _spin_unlock
|
||||
.globl __spin_unlock
|
||||
.globl x_spin_unlock
|
||||
.globl x__spin_unlock
|
||||
_OSSpinLockUnlock:
|
||||
x_spin_unlock:
|
||||
x__spin_unlock:
|
||||
|
@ -30,9 +30,9 @@ set(sys_sources chmodx_np.c
|
||||
OpenBSD/stack_protector.c
|
||||
)
|
||||
|
||||
if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
|
||||
set(sys_sources ${sys_sources} context-stubs.c)
|
||||
endif()
|
||||
#if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
|
||||
# set(sys_sources ${sys_sources} context-stubs.c)
|
||||
#endif()
|
||||
|
||||
SET_SOURCE_FILES_PROPERTIES(semctl.c PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -DLIBC_ALIAS_SEMCTL -DKERNEL -U__DARWIN_UNIX03 -D__DARWIN_UNIX03=0")
|
||||
SET_SOURCE_FILES_PROPERTIES(shmctl.c PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -DLIBC_ALIAS_SEMCTL -DKERNEL -U__DARWIN_UNIX03 -D__DARWIN_UNIX03=0")
|
||||
|
@ -39,7 +39,7 @@ set(dyld_SRCS
|
||||
threads.cpp
|
||||
)
|
||||
|
||||
if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
|
||||
#if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
|
||||
set(dyld_SRCS ${dyld_SRCS}
|
||||
UndefinedFunction.cpp
|
||||
Trampoline.cpp
|
||||
@ -55,7 +55,7 @@ if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} STR
|
||||
add_definitions(-DHAS_DEBUG_HELPERS)
|
||||
add_definitions(-DHAS_TLS_SUPPORT)
|
||||
|
||||
endif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
|
||||
#endif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
|
||||
|
||||
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib${SUFFIX}/darling")
|
||||
#SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--enable-new-dtags")
|
||||
|
@ -37,7 +37,7 @@ reg_saveall: // 24 bytes on stack
|
||||
pushl %edx
|
||||
pushl %esi
|
||||
pushl %edi
|
||||
subl 8, %esp
|
||||
subl $8, %esp
|
||||
fstpl (%esp)
|
||||
|
||||
jmpl *%eax
|
||||
|
@ -33,6 +33,7 @@
|
||||
# define _ffi_prep_args ffi_prep_args
|
||||
# define _ffi_call_SYSV ffi_call_SYSV
|
||||
# define _ffi_closure_SYSV ffi_closure_SYSV
|
||||
# define _ffi_closure_SYSV_inner ffi_closure_SYSV_inner
|
||||
# define _ffi_closure_raw_SYSV ffi_closure_raw_SYSV
|
||||
#endif
|
||||
|
||||
@ -307,14 +308,19 @@ Lrcls_retllong:
|
||||
jmp Lrcls_epilogue
|
||||
LFE3:
|
||||
#endif
|
||||
|
||||
#ifndef DARLING
|
||||
.section __IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5
|
||||
L_ffi_closure_SYSV_inner$stub:
|
||||
.indirect_symbol _ffi_closure_SYSV_inner
|
||||
hlt ; hlt ; hlt ; hlt ; hlt
|
||||
#else
|
||||
L_ffi_closure_SYSV_inner$stub:
|
||||
jmp _ffi_closure_SYSV_inner
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef DARLING
|
||||
.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
|
||||
#endif
|
||||
EH_frame1:
|
||||
.set L$set$0,LECIE1-LSCIE1
|
||||
.long L$set$0
|
||||
|
@ -65,14 +65,24 @@ struct mach_port_allocate_args
|
||||
|
||||
struct mach_msg_overwrite_args
|
||||
{
|
||||
union { void* msg; uint64_t pad; };
|
||||
#ifdef __i386__
|
||||
void* msg;
|
||||
uint32_t pad1;
|
||||
#else
|
||||
void* msg;
|
||||
#endif
|
||||
unsigned int option;
|
||||
unsigned int send_size;
|
||||
unsigned int recv_size;
|
||||
unsigned int rcv_name;
|
||||
unsigned int timeout;
|
||||
unsigned int notify;
|
||||
union { void* rcv_msg; uint64_t pad2; };
|
||||
#ifdef __i386__
|
||||
void* rcv_msg;
|
||||
uint32_t pad2;
|
||||
#else
|
||||
void* rcv_msg;
|
||||
#endif
|
||||
unsigned int rcv_limit;
|
||||
};
|
||||
|
||||
|
@ -491,7 +491,11 @@ kern_return_t mach_msg_overwrite_trap(mach_task_t* task,
|
||||
debug_msg("mach_msg_overwrite_trap()");
|
||||
|
||||
if (copy_from_user(&args, in_args, sizeof(args)))
|
||||
{
|
||||
debug_msg("!!! Cannot copy %d bytes from %p\n",
|
||||
sizeof(args), in_args);
|
||||
return KERN_INVALID_ADDRESS;
|
||||
}
|
||||
|
||||
if (args.option & MACH_SEND_MSG)
|
||||
{
|
||||
@ -514,6 +518,8 @@ kern_return_t mach_msg_overwrite_trap(mach_task_t* task,
|
||||
|
||||
if (copy_from_user(msg, args.msg, args.send_size))
|
||||
{
|
||||
debug_msg("!!! Cannot copy %d bytes from %p\n",
|
||||
args.send_size, args.msg);
|
||||
kfree(msg);
|
||||
return KERN_INVALID_ADDRESS;
|
||||
}
|
||||
@ -782,10 +788,9 @@ kern_return_t bsdthread_terminate_trap(mach_task_t* task,
|
||||
if (PORT_IS_VALID(sem->port))
|
||||
mach_semaphore_signal(sem->port);
|
||||
else
|
||||
debug_msg("Invalid semaphore %d!\n", args.signal);
|
||||
debug_msg("Invalid semaphore %d in bsdthread_terminate_trap()!\n", args.signal);
|
||||
|
||||
// Deallocate stack
|
||||
debug_msg("unmap %p, 0x%x bytes\n", args.stackaddr, args.freesize);
|
||||
vm_munmap(args.stackaddr, args.freesize);
|
||||
|
||||
// Deregister thread
|
||||
|
Loading…
Reference in New Issue
Block a user