diff options
author | Gwenolé Beauchesne <gbeauchesne@mandriva.org> | 2003-06-04 18:44:09 +0000 |
---|---|---|
committer | Gwenolé Beauchesne <gbeauchesne@mandriva.org> | 2003-06-04 18:44:09 +0000 |
commit | 4cd6a4a5d7e49d54d53dcf4a6f3393d50bd88e8b (patch) | |
tree | acd4001a266a8713495af7f1b2102b61e67113b0 /mdk-stage1/dietlibc/x86_64 | |
parent | 71b111ec6c4671667a19c6fbe0023d33422535d7 (diff) | |
download | drakx-backup-do-not-use-4cd6a4a5d7e49d54d53dcf4a6f3393d50bd88e8b.tar drakx-backup-do-not-use-4cd6a4a5d7e49d54d53dcf4a6f3393d50bd88e8b.tar.gz drakx-backup-do-not-use-4cd6a4a5d7e49d54d53dcf4a6f3393d50bd88e8b.tar.bz2 drakx-backup-do-not-use-4cd6a4a5d7e49d54d53dcf4a6f3393d50bd88e8b.tar.xz drakx-backup-do-not-use-4cd6a4a5d7e49d54d53dcf4a6f3393d50bd88e8b.zip |
Import dietlibc 0.22 + other fixes for AMD64
Diffstat (limited to 'mdk-stage1/dietlibc/x86_64')
40 files changed, 669 insertions, 0 deletions
diff --git a/mdk-stage1/dietlibc/x86_64/Makefile.add b/mdk-stage1/dietlibc/x86_64/Makefile.add new file mode 100644 index 000000000..7d60185a7 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/Makefile.add @@ -0,0 +1,2 @@ +CFLAGS := -Os -fstrict-aliasing -momit-leaf-frame-pointer -mfancy-math-387 +VPATH := x86_64:syscalls.s:$(VPATH) diff --git a/mdk-stage1/dietlibc/x86_64/__longjmp.S b/mdk-stage1/dietlibc/x86_64/__longjmp.S new file mode 100644 index 000000000..43ec0539f --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/__longjmp.S @@ -0,0 +1,26 @@ +#include <setjmp.h> +#include "dietwarning.h" + +.text +.global __longjmp +.type __longjmp,@function +__longjmp: + mov $1,%eax + /* Restore the return address now. */ + movq (JB_PC*8)(%rdi),%rdx + /* Restore registers. */ + movq (JB_RBX*8)(%rdi),%rbx + movq (JB_RBP*8)(%rdi),%rbp + movq (JB_R12*8)(%rdi),%r12 + movq (JB_R13*8)(%rdi),%r13 + movq (JB_R14*8)(%rdi),%r14 + movq (JB_R15*8)(%rdi),%r15 + movq (JB_RSP*8)(%rdi),%rsp + /* never return 0 */ + test %esi,%esi + cmovne %esi,%eax + /* Jump to saved PC. */ + jmp *%rdx +.size __longjmp,.-__longjmp; + +link_warning("__longjmp","longjmp() not yet tested") diff --git a/mdk-stage1/dietlibc/x86_64/__testandset.S b/mdk-stage1/dietlibc/x86_64/__testandset.S new file mode 100644 index 000000000..7355477e6 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/__testandset.S @@ -0,0 +1,12 @@ +#include "dietwarning.h" + +.text +.global __testandset +.type __testandset,@function +__testandset: + xorl %eax,%eax + incl %eax + xchg %rax,(%rdi) + ret + +link_warning("__testandset", "warning: __testandset() was never tested!") diff --git a/mdk-stage1/dietlibc/x86_64/accept.S b/mdk-stage1/dietlibc/x86_64/accept.S new file mode 100644 index 000000000..7bdc38c7e --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/accept.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(accept, accept); diff --git a/mdk-stage1/dietlibc/x86_64/bind.S b/mdk-stage1/dietlibc/x86_64/bind.S new file mode 100644 index 000000000..05849d470 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/bind.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(bind, bind); diff --git a/mdk-stage1/dietlibc/x86_64/clone.S b/mdk-stage1/dietlibc/x86_64/clone.S new file mode 100644 index 000000000..82c8c5bae --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/clone.S @@ -0,0 +1,64 @@ +#include "syscalls.h" +#include <errno.h> +#include "dietwarning.h" + +.text +.type clone,@function +.weak clone +clone: +.type __clone,@function +.global __clone +__clone: + movl $-EINVAL,%eax + testq %rdi,%rdi /* have non null thread_funcion */ + jz .Lclone_error + testq %rsi,%rsi /* have non null child_stack pointer */ + jz .Lclone_error + + /* put the parameters on thread stack */ + subq $16,%rsi + movq %rcx,8(%rsi) /* thread parameter */ + movq %rdi,0(%rsi) /* thread function */ + + /* syscall */ + movq %rdx,%rdi + movl $__NR_clone,%eax + syscall + cmpl $0,%eax + jl .Lclone_error + jne .Lreturn + +.thread_start: + /* call thread function */ + popq %rax + popq %rdi + call *%rax + /* exit a thread */ + movq %rax,%rdi +#ifdef PIC + jmp _exit@PLT +#else + jmp _exit +#endif + +.Lclone_error: + /* set errno */ + negl %eax + pushq %rax +#ifdef PIC + call __errno_location@PLT +#else + call __errno_location +#endif + popq %rcx + movl %ecx,(%rax) + orq $-1, %rax + +.Lreturn: + /* just return */ + ret + +link_warning("clone", "warning: clone() not yet tested") +link_warning("__clone", "warning: clone() not yet tested") +//link_warning("clone", "warning: clone() not yet implemented") +//link_warning("__clone", "warning: clone() not yet implemented") diff --git a/mdk-stage1/dietlibc/x86_64/connect.S b/mdk-stage1/dietlibc/x86_64/connect.S new file mode 100644 index 000000000..5fbd151ae --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/connect.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(connect, connect); diff --git a/mdk-stage1/dietlibc/x86_64/getpeername.S b/mdk-stage1/dietlibc/x86_64/getpeername.S new file mode 100644 index 000000000..fdaa1038a --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/getpeername.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(getpeername, getpeername); diff --git a/mdk-stage1/dietlibc/x86_64/getsockname.S b/mdk-stage1/dietlibc/x86_64/getsockname.S new file mode 100644 index 000000000..1ea0bc000 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/getsockname.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(getsockname, getsockname); diff --git a/mdk-stage1/dietlibc/x86_64/getsockopt.S b/mdk-stage1/dietlibc/x86_64/getsockopt.S new file mode 100644 index 000000000..465c4e08e --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/getsockopt.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(getsockopt, getsockopt); diff --git a/mdk-stage1/dietlibc/x86_64/listen.S b/mdk-stage1/dietlibc/x86_64/listen.S new file mode 100644 index 000000000..66a3fe376 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/listen.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(listen, listen); diff --git a/mdk-stage1/dietlibc/x86_64/mmap.S b/mdk-stage1/dietlibc/x86_64/mmap.S new file mode 100644 index 000000000..764d5fd96 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/mmap.S @@ -0,0 +1,8 @@ +#include "syscalls.h" + +.text +.global mmap +.type mmap,@function +mmap: + mov $__NR_mmap,%al + jmp __unified_syscall diff --git a/mdk-stage1/dietlibc/x86_64/msgctl.S b/mdk-stage1/dietlibc/x86_64/msgctl.S new file mode 100644 index 000000000..d7caed2cc --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/msgctl.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(msgctl,msgctl) diff --git a/mdk-stage1/dietlibc/x86_64/msgget.S b/mdk-stage1/dietlibc/x86_64/msgget.S new file mode 100644 index 000000000..518d67ac4 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/msgget.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(msgget,msgget) diff --git a/mdk-stage1/dietlibc/x86_64/msgrcv.S b/mdk-stage1/dietlibc/x86_64/msgrcv.S new file mode 100644 index 000000000..ab62e6c30 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/msgrcv.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(msgrcv,msgrcv) diff --git a/mdk-stage1/dietlibc/x86_64/msgsnd.S b/mdk-stage1/dietlibc/x86_64/msgsnd.S new file mode 100644 index 000000000..890a996a2 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/msgsnd.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(msgsnd,msgsnd) diff --git a/mdk-stage1/dietlibc/x86_64/recv.c b/mdk-stage1/dietlibc/x86_64/recv.c new file mode 100644 index 000000000..3b76c0716 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/recv.c @@ -0,0 +1,13 @@ +#include <sys/types.h> +#include <sys/socket.h> +#include <linuxnet.h> + +int __libc_recv(int fd, void * buf, size_t n, int flags); + /* shut up gcc warning about missing prototype */ + +int __libc_recv(int fd, void * buf, size_t n, int flags) { + return recvfrom(fd, buf, n, flags, 0, 0); +} + +int recv(int a, void * b, size_t c, int flags) + __attribute__ ((weak, alias("__libc_recv"))); diff --git a/mdk-stage1/dietlibc/x86_64/recvfrom.S b/mdk-stage1/dietlibc/x86_64/recvfrom.S new file mode 100644 index 000000000..d3c2e602f --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/recvfrom.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(recvfrom, recvfrom); diff --git a/mdk-stage1/dietlibc/x86_64/recvmsg.S b/mdk-stage1/dietlibc/x86_64/recvmsg.S new file mode 100644 index 000000000..cfbbafdc1 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/recvmsg.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(recvmsg, recvmsg); diff --git a/mdk-stage1/dietlibc/x86_64/semctl.S b/mdk-stage1/dietlibc/x86_64/semctl.S new file mode 100644 index 000000000..e215ed955 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/semctl.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(semctl,semctl) diff --git a/mdk-stage1/dietlibc/x86_64/semget.S b/mdk-stage1/dietlibc/x86_64/semget.S new file mode 100644 index 000000000..67f488546 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/semget.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(semget,semget) diff --git a/mdk-stage1/dietlibc/x86_64/semop.S b/mdk-stage1/dietlibc/x86_64/semop.S new file mode 100644 index 000000000..81b6fc606 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/semop.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(semop,semop) diff --git a/mdk-stage1/dietlibc/x86_64/send.c b/mdk-stage1/dietlibc/x86_64/send.c new file mode 100644 index 000000000..bdeb1d31f --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/send.c @@ -0,0 +1,13 @@ +#include <sys/types.h> +#include <sys/socket.h> +#include <linuxnet.h> + +int __libc_send(int fd, const void * buf, size_t n, int flags); + /* shut up gcc warning about missing prototype */ + +int __libc_send(int fd, const void * buf, size_t n, int flags) { + return sendto(fd, buf, n, flags, NULL, 0); +} + +int send(int a, const void * b, size_t c, int flags) + __attribute__ ((weak, alias("__libc_send"))); diff --git a/mdk-stage1/dietlibc/x86_64/sendmsg.S b/mdk-stage1/dietlibc/x86_64/sendmsg.S new file mode 100644 index 000000000..c2bc80f72 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/sendmsg.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(sendmsg, sendmsg); diff --git a/mdk-stage1/dietlibc/x86_64/sendto.S b/mdk-stage1/dietlibc/x86_64/sendto.S new file mode 100644 index 000000000..1579a3b45 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/sendto.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(sendto, sendto); diff --git a/mdk-stage1/dietlibc/x86_64/setjmp.S b/mdk-stage1/dietlibc/x86_64/setjmp.S new file mode 100644 index 000000000..3d1ec11f0 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/setjmp.S @@ -0,0 +1,37 @@ +#include <setjmp.h> +#include "dietwarning.h" + +.text +.weak setjmp +.type setjmp,@function +setjmp: +.globl __setjmp +.type __setjmp,@function +__setjmp: + xorq %rsi,%rsi + +.globl __sigsetjmp +.type __sigsetjmp,@function +__sigsetjmp: + movq %rbx,(JB_RBX*8)(%rdi) + movq %rbp,(JB_RBP*8)(%rdi) + movq %r12,(JB_R12*8)(%rdi) + movq %r13,(JB_R13*8)(%rdi) + movq %r14,(JB_R14*8)(%rdi) + movq %r15,(JB_R15*8)(%rdi) + leaq 8(%rsp),%rdx + movq %rdx,(JB_RSP*8)(%rdi) + movq (%rsp),%rdx + movq %rdx,(JB_PC*8)(%rdi) +#ifdef PIC + jmp __sigjmp_save@PLT +#else + jmp __sigjmp_save +#endif +.size __sigsetjmp,.-__sigsetjmp; + +link_warning("setjmp","setjmp() not yet tested") +link_warning("__sigsetjmp","setjmp() not yet tested") +//link_warning("setjmp","error: setjmp() not yet implemented") +//link_warning("__sigsetjmp","error: setjmp() not yet implemented") + diff --git a/mdk-stage1/dietlibc/x86_64/setsockopt.S b/mdk-stage1/dietlibc/x86_64/setsockopt.S new file mode 100644 index 000000000..45fcfbb6c --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/setsockopt.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(setsockopt, setsockopt); diff --git a/mdk-stage1/dietlibc/x86_64/shmat.S b/mdk-stage1/dietlibc/x86_64/shmat.S new file mode 100644 index 000000000..51248173d --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/shmat.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(shmat,shmat) diff --git a/mdk-stage1/dietlibc/x86_64/shmctl.S b/mdk-stage1/dietlibc/x86_64/shmctl.S new file mode 100644 index 000000000..d56caace4 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/shmctl.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(shmctl,shmctl) diff --git a/mdk-stage1/dietlibc/x86_64/shmdt.S b/mdk-stage1/dietlibc/x86_64/shmdt.S new file mode 100644 index 000000000..d9812a799 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/shmdt.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(shmdt,shmdt) diff --git a/mdk-stage1/dietlibc/x86_64/shmget.S b/mdk-stage1/dietlibc/x86_64/shmget.S new file mode 100644 index 000000000..82914223f --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/shmget.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(shmget,shmget) diff --git a/mdk-stage1/dietlibc/x86_64/shutdown.S b/mdk-stage1/dietlibc/x86_64/shutdown.S new file mode 100644 index 000000000..024e99e18 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/shutdown.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(shutdown, shutdown); diff --git a/mdk-stage1/dietlibc/x86_64/sigaction.c b/mdk-stage1/dietlibc/x86_64/sigaction.c new file mode 100644 index 000000000..18f32efde --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/sigaction.c @@ -0,0 +1,26 @@ +#include <signal.h> +#include <stdlib.h> +#include <string.h> +#include <syscalls.h> + +int __rt_sigaction(int signum, const struct sigaction *act, struct sigaction *oldact, long nr); + +static void restore_rt(void) { + asm volatile ("syscall" : : "a" (__NR_rt_sigreturn)); +} + +int __libc_sigaction(int signum, const struct sigaction *act, struct sigaction *oldact); +int __libc_sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) { + struct sigaction *newact = (struct sigaction *)act; + if (act) { + newact = alloca(sizeof(*newact)); + newact->sa_handler = act->sa_handler; + newact->sa_flags = act->sa_flags | SA_RESTORER; + newact->sa_restorer = &restore_rt; + newact->sa_mask = act->sa_mask; + } + return __rt_sigaction(signum, newact, oldact, _NSIG/8); +} + +int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) +__attribute__((weak,alias("__libc_sigaction"))); diff --git a/mdk-stage1/dietlibc/x86_64/socket.S b/mdk-stage1/dietlibc/x86_64/socket.S new file mode 100644 index 000000000..cc453881f --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/socket.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(socket, socket); diff --git a/mdk-stage1/dietlibc/x86_64/socketpair.S b/mdk-stage1/dietlibc/x86_64/socketpair.S new file mode 100644 index 000000000..d92eaa4d8 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/socketpair.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(socketpair, socketpair); diff --git a/mdk-stage1/dietlibc/x86_64/start.S b/mdk-stage1/dietlibc/x86_64/start.S new file mode 100644 index 000000000..5e8356350 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/start.S @@ -0,0 +1,55 @@ +#include "dietfeatures.h" + +.text +.global _start +_start: +#ifdef WANT_DYNAMIC + movq %rdx, %rcx /* %rcx = dynamic fini */ +#endif + popq %rdi /* %rdi = argc */ + movq %rsp,%rsi /* %rsi = argv */ + pushq %rdi + + leaq 8(%rsi,%rdi,8),%rdx /* %rdx = envp = (8*rdi)+%rsi+8 */ + +#ifdef __DYN_LIB + movq environ@GOTPCREL(%rip), %rax + movq %rdx, (%rax) +#else + movq %rdx, environ(%rip) +#endif + +#ifdef PROFILING + pushq %rdi /* save reg args */ + pushq %rsi + pushq %rdx + pushq %rcx + + leaq _etext(%rip), %rsi /* highpc */ + leaq .text(%rip), %rdi /* lowpc */ + call monitor + + popq %rcx /* restore reg args */ + popq %rdx + popq %rsi + popq %rdi +#endif + +#ifdef WANT_DYNAMIC + call _dyn_start +#else + call main +#endif + +#ifdef PROFILING + pushq %rax + call _stop_monitor + popq %rdi +#else + movq %rax, %rdi /* return value */ +#endif + call exit + hlt +.Lstart: + .size _start,.Lstart-_start + diff --git a/mdk-stage1/dietlibc/x86_64/syscalls.h b/mdk-stage1/dietlibc/x86_64/syscalls.h new file mode 100644 index 000000000..6fcfbfc60 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/syscalls.h @@ -0,0 +1,282 @@ +#define __NR_read 0 +#define __NR_write 1 +#define __NR_open 2 +#define __NR_close 3 +#define __NR_stat 4 +#define __NR_fstat 5 +#define __NR_lstat 6 +#define __NR_poll 7 + +#define __NR_lseek 8 +#define __NR_mmap 9 +#define __NR_mprotect 10 +#define __NR_munmap 11 +#define __NR_brk 12 +#define __NR_rt_sigaction 13 +#define __NR_rt_sigprocmask 14 +#define __NR_rt_sigreturn 15 + +#define __NR_ioctl 16 +#define __NR_pread 17 +#define __NR_pwrite 18 +#define __NR_readv 19 +#define __NR_writev 20 +#define __NR_access 21 +#define __NR_pipe 22 +#define __NR_select 23 + +#define __NR_sched_yield 24 +#define __NR_mremap 25 +#define __NR_msync 26 +#define __NR_mincore 27 +#define __NR_madvise 28 +#define __NR_shmget 29 +#define __NR_shmat 30 +#define __NR_shmctl 31 + +#define __NR_dup 32 +#define __NR_dup2 33 +#define __NR_pause 34 +#define __NR_nanosleep 35 +#define __NR_getitimer 36 +#define __NR_alarm 37 +#define __NR_setitimer 38 +#define __NR_getpid 39 + +#define __NR_sendfile 40 +#define __NR_socket 41 +#define __NR_connect 42 +#define __NR_accept 43 +#define __NR_sendto 44 +#define __NR_recvfrom 45 +#define __NR_sendmsg 46 +#define __NR_recvmsg 47 + +#define __NR_shutdown 48 +#define __NR_bind 49 +#define __NR_listen 50 +#define __NR_getsockname 51 +#define __NR_getpeername 52 +#define __NR_socketpair 53 +#define __NR_setsockopt 54 +#define __NR_getsockopt 55 + +#define __NR_clone 56 +#define __NR_fork 57 +#define __NR_vfork 58 +#define __NR_execve 59 +#define __NR_exit 60 +#define __NR_wait4 61 +#define __NR_kill 62 +#define __NR_uname 63 + +#define __NR_semget 64 +#define __NR_semop 65 +#define __NR_semctl 66 +#define __NR_shmdt 67 +#define __NR_msgget 68 +#define __NR_msgsnd 69 +#define __NR_msgrcv 70 +#define __NR_msgctl 71 + +#define __NR_fcntl 72 +#define __NR_flock 73 +#define __NR_fsync 74 +#define __NR_fdatasync 75 +#define __NR_truncate 76 +#define __NR_ftruncate 77 +#define __NR_getdents 78 +#define __NR_getcwd 79 + +#define __NR_chdir 80 +#define __NR_fchdir 81 +#define __NR_rename 82 +#define __NR_mkdir 83 +#define __NR_rmdir 84 +#define __NR_creat 85 +#define __NR_link 86 +#define __NR_unlink 87 + +#define __NR_symlink 88 +#define __NR_readlink 89 +#define __NR_chmod 90 +#define __NR_fchmod 91 +#define __NR_chown 92 +#define __NR_fchown 93 +#define __NR_lchown 94 +#define __NR_umask 95 + +#define __NR_gettimeofday 96 +#define __NR_getrlimit 97 +#define __NR_getrusage 98 +#define __NR_sysinfo 99 +#define __NR_times 100 +#define __NR_ptrace 101 +#define __NR_getuid 102 +#define __NR_syslog 103 + +/* at the very end the stuff that never runs during the benchmarks */ +#define __NR_getgid 104 +#define __NR_setuid 105 +#define __NR_setgid 106 +#define __NR_geteuid 107 +#define __NR_getegid 108 +#define __NR_setpgid 109 +#define __NR_getppid 110 +#define __NR_getpgrp 111 + +#define __NR_setsid 112 +#define __NR_setreuid 113 +#define __NR_setregid 114 +#define __NR_getgroups 115 +#define __NR_setgroups 116 +#define __NR_setresuid 117 +#define __NR_getresuid 118 +#define __NR_setresgid 119 + +#define __NR_getresgid 120 +#define __NR_getpgid 121 +#define __NR_setfsuid 122 +#define __NR_setfsgid 123 +#define __NR_getsid 124 +#define __NR_capget 125 +#define __NR_capset 126 + +#define __NR_rt_sigpending 127 +#define __NR_rt_sigtimedwait 128 +#define __NR_rt_sigqueueinfo 129 +#define __NR_rt_sigsuspend 130 +#define __NR_sigaltstack 131 +#define __NR_utime 132 +#define __NR_mknod 133 + +#define __NR_uselib 134 +#define __NR_personality 135 + +#define __NR_ustat 136 +#define __NR_statfs 137 +#define __NR_fstatfs 138 +#define __NR_sysfs 139 + +#define __NR_getpriority 140 +#define __NR_setpriority 141 +#define __NR_sched_setparam 142 +#define __NR_sched_getparam 143 +#define __NR_sched_setscheduler 144 +#define __NR_sched_getscheduler 145 +#define __NR_sched_get_priority_max 146 +#define __NR_sched_get_priority_min 147 +#define __NR_sched_rr_get_interval 148 + +#define __NR_mlock 149 +#define __NR_munlock 150 +#define __NR_mlockall 151 +#define __NR_munlockall 152 + +#define __NR_vhangup 153 + +#define __NR_modify_ldt 154 + +#define __NR_pivot_root 155 + +#define __NR__sysctl 156 + +#define __NR_prctl 157 +#define __NR_arch_prctl 158 + +#define __NR_adjtimex 159 + +#define __NR_setrlimit 160 + +#define __NR_chroot 161 + +#define __NR_sync 162 + +#define __NR_acct 163 + +#define __NR_settimeofday 164 + +#define __NR_mount 165 +#define __NR_umount2 166 + +#define __NR_swapon 167 +#define __NR_swapoff 168 + +#define __NR_reboot 169 + +#define __NR_sethostname 170 +#define __NR_setdomainname 171 + +#define __NR_iopl 172 +#define __NR_ioperm 173 + +#define __NR_create_module 174 +#define __NR_init_module 175 +#define __NR_delete_module 176 +#define __NR_get_kernel_syms 177 +#define __NR_query_module 178 + +#define __NR_quotactl 179 + +#define __NR_nfsservctl 180 + +#define __NR_getpmsg 181 +#define __NR_putpmsg 182 + +#define __NR_afs_syscall 183 + +#define __NR_tuxcall 184 /* reserved for tux */ + +#define __NR_security 185 /* reserved for security */ + +#define __NR_gettid 186 + +#define __NR_readahead 187 + +#define __NR_setxattr 188 +#define __NR_lsetxattr 189 +#define __NR_fsetxattr 190 +#define __NR_getxattr 191 +#define __NR_lgetxattr 192 +#define __NR_fgetxattr 193 +#define __NR_listxattr 194 +#define __NR_llistxattr 195 +#define __NR_flistxattr 196 +#define __NR_removexattr 197 +#define __NR_lremovexattr 198 +#define __NR_fremovexattr 199 +#define __NR_tkill 200 /* 2.5 only */ +#define __NR_time 201 +#define __NR_futex 202 /* 2.5 only */ +#define __NR_sched_setaffinity 203 +#define __NR_sched_getaffinity 204 +#define __NR_set_thread_area 205 +#define __NR_io_setup 206 +#define __NR_io_destroy 207 +#define __NR_io_getevents 208 +#define __NR_io_submit 209 +#define __NR_io_cancel 210 +#define __NR_get_thread_area 211 +#define __NR_lookup_dcookie 212 + +#define __NR_syscall_max __NR_futex + +#define syscall_weak(name,wsym,sym) \ +.text; \ +.type wsym,@function; \ +.weak wsym; \ +wsym: ; \ +.type sym,@function; \ +.global sym; \ +sym: \ + mov $__NR_##name,%al; \ + jmp __unified_syscall + +#define syscall(name,sym) \ +.text; \ +.type sym,@function; \ +.global sym; \ +sym: \ + mov $__NR_##name,%al; \ + jmp __unified_syscall + diff --git a/mdk-stage1/dietlibc/x86_64/umount.S b/mdk-stage1/dietlibc/x86_64/umount.S new file mode 100644 index 000000000..2b51b8edf --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/umount.S @@ -0,0 +1,9 @@ +#include "syscalls.h" + +.text +.global umount +.type umount,@function +umount: + mov $__NR_umount2,%al + xorq %rsi,%rsi + jmp __unified_syscall diff --git a/mdk-stage1/dietlibc/x86_64/unified.S b/mdk-stage1/dietlibc/x86_64/unified.S new file mode 100644 index 000000000..48bb9a4fa --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/unified.S @@ -0,0 +1,32 @@ +#include <dietfeatures.h> + +#define SYS_exit 0x3c + +.text +.weak exit +exit: +.global _exit +_exit: + mov $SYS_exit,%al + +#ifndef __DYN_LIB +.global __unified_syscall +#endif +__unified_syscall: + movzbl %al, %eax + mov %rcx, %r10 + syscall + cmpq $-128, %rax + jbe .Lnoerror + negl %eax + pushq %rax + call __errno_location + popq %rcx + movl %ecx,(%rax) + orq $-1, %rax +.Lnoerror: + +/* here we go and "reuse" the return for weak-void functions */ +#include "dietuglyweaks.h" + + ret diff --git a/mdk-stage1/dietlibc/x86_64/waitpid.S b/mdk-stage1/dietlibc/x86_64/waitpid.S new file mode 100644 index 000000000..944df48bf --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/waitpid.S @@ -0,0 +1,12 @@ +#include "syscalls.h" + +.text +.type waitpid,@function +.weak waitpid +waitpid: +.type __libc_waitpid,@function +.global __libc_waitpid +__libc_waitpid: + mov $0,%rcx + mov $__NR_wait4,%al + jmp __unified_syscall |