From 9a4127bb0a174dd0c9d479ebc51c878f31d39ed6 Mon Sep 17 00:00:00 2001 From: Pavel Chupin Date: Wed, 12 Dec 2012 13:18:50 +0400 Subject: [PATCH] x86_64: add new __NR_arch_prctl syscall This is used to set/get TLS on x86_64. There's no public declaration of this because it's not meant to be used outside the C library, like glibc (though we don't currently have any visibility controls to ensure this). Change-Id: I5fc0a5e3ffc3f4cd597d92ee685ab19568ea18f7 Signed-off-by: Pavel Chupin --- libc/SYSCALLS.TXT | 1 + libc/arch-x86_64/syscalls.mk | 1 + libc/arch-x86_64/syscalls/arch_prctl.S | 17 +++++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 libc/arch-x86_64/syscalls/arch_prctl.S diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT index bb014bcc2..6465de477 100644 --- a/libc/SYSCALLS.TXT +++ b/libc/SYSCALLS.TXT @@ -94,6 +94,7 @@ int chroot(const char*) all # IMPORTANT: Even though declares prctl(int, ...), the syscall stub must take 6 arguments # to match the kernel implementation. int prctl(int option, unsigned int arg2, unsigned int arg3, unsigned int arg4, unsigned int arg5) all +long arch_prctl(int, unsigned long) x86_64 int capget(cap_user_header_t header, cap_user_data_t data) all int capset(cap_user_header_t header, const cap_user_data_t data) all int sigaltstack(const stack_t*, stack_t*) all diff --git a/libc/arch-x86_64/syscalls.mk b/libc/arch-x86_64/syscalls.mk index 568f1e8e6..5a7a88071 100644 --- a/libc/arch-x86_64/syscalls.mk +++ b/libc/arch-x86_64/syscalls.mk @@ -41,6 +41,7 @@ syscall_src += arch-x86_64/syscalls/vfork.S syscall_src += arch-x86_64/syscalls/setregid.S syscall_src += arch-x86_64/syscalls/chroot.S syscall_src += arch-x86_64/syscalls/prctl.S +syscall_src += arch-x86_64/syscalls/arch_prctl.S syscall_src += arch-x86_64/syscalls/capget.S syscall_src += arch-x86_64/syscalls/capset.S syscall_src += arch-x86_64/syscalls/sigaltstack.S diff --git a/libc/arch-x86_64/syscalls/arch_prctl.S b/libc/arch-x86_64/syscalls/arch_prctl.S new file mode 100644 index 000000000..eaf9494d0 --- /dev/null +++ b/libc/arch-x86_64/syscalls/arch_prctl.S @@ -0,0 +1,17 @@ +/* autogenerated by gensyscalls.py */ +#include +#include +#include + +ENTRY(arch_prctl) + movl $__NR_arch_prctl, %eax + syscall + cmpq $-MAX_ERRNO, %rax + jb 1f + negl %eax + movl %eax, %edi + call __set_errno + orq $-1, %rax +1: + ret +END(arch_prctl)