summaryrefslogtreecommitdiffstats
path: root/lib/libc/arch/amd64/sys
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2016-05-07 19:05:21 +0000
committerguenther <guenther@openbsd.org>2016-05-07 19:05:21 +0000
commitfe38b55cb0aae270de3f844146814682e8cd345c (patch)
tree9825cc8aa96314e8e79ea1802ccbc9349772680b /lib/libc/arch/amd64/sys
parentImplement ACPI 5.0 GeneralPurposeIo OpRegion support. This basically allows (diff)
downloadwireguard-openbsd-fe38b55cb0aae270de3f844146814682e8cd345c.tar.xz
wireguard-openbsd-fe38b55cb0aae270de3f844146814682e8cd345c.zip
Use a Thread Information Block in both single and multi-threaded programs.
This stores errno, the cancelation flags, and related bits for each thread and is allocated by ld.so or libc.a. This is an ABI break from 5.9-stable! Make libpthread dlopen'able by moving the cancelation wrappers into libc and doing locking and fork/errno handling via callbacks that libpthread registers when it first initializes. 'errno' *must* be declared via <errno.h> now! Clean up libpthread's symbol exports like libc. On powerpc, offset the TIB/TCB/TLS data from the register per the ELF spec. Testing by various, particularly sthen@ and patrick@ ok kettenis@
Diffstat (limited to 'lib/libc/arch/amd64/sys')
-rw-r--r--lib/libc/arch/amd64/sys/Ovfork.S14
-rw-r--r--lib/libc/arch/amd64/sys/brk.S22
-rw-r--r--lib/libc/arch/amd64/sys/cerror.S55
-rw-r--r--lib/libc/arch/amd64/sys/fork.S43
-rw-r--r--lib/libc/arch/amd64/sys/sbrk.S21
-rw-r--r--lib/libc/arch/amd64/sys/sigprocmask.S14
-rw-r--r--lib/libc/arch/amd64/sys/sigsuspend.S16
-rw-r--r--lib/libc/arch/amd64/sys/syscall.S17
-rw-r--r--lib/libc/arch/amd64/sys/tfork_thread.S10
9 files changed, 25 insertions, 187 deletions
diff --git a/lib/libc/arch/amd64/sys/Ovfork.S b/lib/libc/arch/amd64/sys/Ovfork.S
index 6e70f7231a8..e42649e28ce 100644
--- a/lib/libc/arch/amd64/sys/Ovfork.S
+++ b/lib/libc/arch/amd64/sys/Ovfork.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: Ovfork.S,v 1.7 2015/10/17 22:40:54 guenther Exp $ */
+/* $OpenBSD: Ovfork.S,v 1.8 2016/05/07 19:05:21 guenther Exp $ */
/* $NetBSD: Ovfork.S,v 1.2 2002/06/03 18:30:33 fvdl Exp $ */
/*-
@@ -39,17 +39,13 @@
#include "SYS.h"
-SYSENTRY(vfork)
+SYSENTRY_HIDDEN(vfork)
popq %r9 /* my rta into r9 */
SYSTRAP(vfork)
jc 1f
jmp *%r9
1:
pushq %r9
-#ifdef __PIC__
- movq PIC_GOT(CERROR), %rcx
- jmp *%rcx
-#else
- jmp CERROR
-#endif
-SYSCALL_END(vfork)
+ SET_ERRNO
+ ret
+SYSCALL_END_HIDDEN(vfork)
diff --git a/lib/libc/arch/amd64/sys/brk.S b/lib/libc/arch/amd64/sys/brk.S
index c59f0036eb0..26fb2893b58 100644
--- a/lib/libc/arch/amd64/sys/brk.S
+++ b/lib/libc/arch/amd64/sys/brk.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: brk.S,v 1.7 2015/09/05 06:22:47 guenther Exp $ */
+/* $OpenBSD: brk.S,v 1.8 2016/05/07 19:05:21 guenther Exp $ */
/* $NetBSD: brk.S,v 1.2 2002/06/03 18:30:33 fvdl Exp $ */
/*-
@@ -51,22 +51,6 @@ __minbrk:
.weak brk
ENTRY(brk)
-#ifdef __PIC__
- movq PIC_GOT(__minbrk),%rdx
- cmpq %rdi,(%rdx)
- jb 1f
- movq (%rdx),%rdi
-1:
- SYSTRAP(break)
- jc 1f
- movq PIC_GOT(__curbrk),%rdx # set up GOT addressing
- movq %rdi,(%rdx)
- xorl %eax,%eax
- ret
-1:
- movq PIC_GOT(CERROR),%rdx
- jmp *%rdx
-#else
cmpq %rdi,__minbrk(%rip)
jb 1f
movq __minbrk(%rip),%rdi
@@ -77,6 +61,6 @@ ENTRY(brk)
xorl %eax,%eax
ret
1:
- jmp CERROR
-#endif
+ SET_ERRNO
+ ret
END(brk)
diff --git a/lib/libc/arch/amd64/sys/cerror.S b/lib/libc/arch/amd64/sys/cerror.S
deleted file mode 100644
index 89bf7f69aa4..00000000000
--- a/lib/libc/arch/amd64/sys/cerror.S
+++ /dev/null
@@ -1,55 +0,0 @@
-/* $OpenBSD: cerror.S,v 1.7 2015/06/01 09:31:40 uebayasi Exp $ */
-/* $NetBSD: cerror.S,v 1.2 2002/06/03 18:30:33 fvdl Exp $ */
-
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * from: @(#)cerror.s 5.1 (Berkeley) 4/23/90
- */
-
-#include <machine/asm.h>
-
-#include "SYS.h"
-
- .globl _C_LABEL(errno)
-
-WEAK_ALIAS(CERROR, _CERROR)
-
-_ENTRY(_CERROR)
-#ifdef __PIC__
- movq PIC_GOT(_C_LABEL(errno)), %rcx
- movl %eax, (%rcx)
-#else
- movl %eax, _C_LABEL(errno)(%rip)
-#endif /* PIC */
- movq $-1,%rax
- ret
-END(_CERROR)
diff --git a/lib/libc/arch/amd64/sys/fork.S b/lib/libc/arch/amd64/sys/fork.S
deleted file mode 100644
index 6582d8a9a32..00000000000
--- a/lib/libc/arch/amd64/sys/fork.S
+++ /dev/null
@@ -1,43 +0,0 @@
-/* $OpenBSD: fork.S,v 1.4 2015/04/07 01:27:06 guenther Exp $ */
-/* $NetBSD: fork.S,v 1.2 2003/02/13 02:50:51 nathanw Exp $ */
-
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * from: @(#)fork.s 5.1 (Berkeley) 4/23/90
- */
-
-#include <machine/asm.h>
-
-#include "SYS.h"
-
-RSYSCALL_HIDDEN(fork)
-WEAK_ALIAS(_thread_fork,_thread_sys_fork)
diff --git a/lib/libc/arch/amd64/sys/sbrk.S b/lib/libc/arch/amd64/sys/sbrk.S
index 06ed6ba7cca..05d289b03b9 100644
--- a/lib/libc/arch/amd64/sys/sbrk.S
+++ b/lib/libc/arch/amd64/sys/sbrk.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sbrk.S,v 1.7 2015/09/05 06:22:47 guenther Exp $ */
+/* $OpenBSD: sbrk.S,v 1.8 2016/05/07 19:05:21 guenther Exp $ */
/* $NetBSD: sbrk.S,v 1.1 2001/06/19 00:25:06 fvdl Exp $ */
/*-
@@ -55,21 +55,6 @@ __curbrk: .quad _end
.weak sbrk
ENTRY(sbrk)
-#ifdef __PIC__
- movq PIC_GOT(__curbrk),%rdx
- movslq %edi, %rax
- movq (%rdx),%rdi
- addq %rax,%rdi
- SYSTRAP(break)
- jc 1f
- movq PIC_GOT(__curbrk),%rdx
- movq (%rdx),%rax
- movq %rdi,(%rdx)
- ret
-1:
- mov PIC_GOT(CERROR),%rdx
- jmp *%rdx
-#else
movq __curbrk(%rip),%rax
movslq %edi,%rsi
movq %rsi,%rdi
@@ -80,6 +65,6 @@ ENTRY(sbrk)
addq %rsi,__curbrk(%rip)
ret
1:
- jmp CERROR
-#endif
+ SET_ERRNO
+ ret
END(sbrk)
diff --git a/lib/libc/arch/amd64/sys/sigprocmask.S b/lib/libc/arch/amd64/sys/sigprocmask.S
index 065088d6548..308c5800b50 100644
--- a/lib/libc/arch/amd64/sys/sigprocmask.S
+++ b/lib/libc/arch/amd64/sys/sigprocmask.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigprocmask.S,v 1.8 2015/10/23 04:39:24 guenther Exp $ */
+/* $OpenBSD: sigprocmask.S,v 1.9 2016/05/07 19:05:21 guenther Exp $ */
/* $NetBSD: sigprocmask.S,v 1.1 2001/06/19 00:25:06 fvdl Exp $ */
/*-
@@ -48,16 +48,12 @@ SYSENTRY_HIDDEN(sigprocmask)
2: SYSTRAP(sigprocmask)
jc 1f
testq %rdx,%rdx # test if old mask requested
- jz out
+ jz 3f
movl %eax,(%rdx) # store old mask
-out:
+3:
xorl %eax,%eax
ret
1:
-#ifdef __PIC__
- movq PIC_GOT(CERROR), %rcx
- jmp *%rcx
-#else
- jmp CERROR
-#endif
+ SET_ERRNO
+ ret
SYSCALL_END_HIDDEN(sigprocmask)
diff --git a/lib/libc/arch/amd64/sys/sigsuspend.S b/lib/libc/arch/amd64/sys/sigsuspend.S
index 43e6ac3be3c..9abb04e1079 100644
--- a/lib/libc/arch/amd64/sys/sigsuspend.S
+++ b/lib/libc/arch/amd64/sys/sigsuspend.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigsuspend.S,v 1.6 2015/10/17 22:40:54 guenther Exp $ */
+/* $OpenBSD: sigsuspend.S,v 1.7 2016/05/07 19:05:21 guenther Exp $ */
/* $NetBSD: sigsuspend.S,v 1.1 2001/06/19 00:25:07 fvdl Exp $ */
/*-
@@ -39,17 +39,9 @@
#include "SYS.h"
-SYSENTRY(sigsuspend)
+SYSENTRY_HIDDEN(sigsuspend)
movl (%rdi),%edi # indirect to mask arg
SYSTRAP(sigsuspend)
- jc 1f
- xorl %eax,%eax # shouldn t happen
+ SET_ERRNO
ret
-1:
-#ifdef __PIC__
- movq PIC_GOT(CERROR), %rcx
- jmp *%rcx
-#else
- jmp CERROR
-#endif
-SYSCALL_END(sigsuspend)
+SYSCALL_END_HIDDEN(sigsuspend)
diff --git a/lib/libc/arch/amd64/sys/syscall.S b/lib/libc/arch/amd64/sys/syscall.S
index 0bf3ccfec47..6568ecc55af 100644
--- a/lib/libc/arch/amd64/sys/syscall.S
+++ b/lib/libc/arch/amd64/sys/syscall.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: syscall.S,v 1.7 2015/10/17 22:40:54 guenther Exp $ */
+/* $OpenBSD: syscall.S,v 1.8 2016/05/07 19:05:21 guenther Exp $ */
/* $NetBSD: syscall.S,v 1.2 2002/06/03 18:30:33 fvdl Exp $ */
/*-
@@ -39,17 +39,4 @@
#include "SYS.h"
-SYSENTRY(syscall)
- movq $0,%rax
- movq %rcx,%r10
- syscall
- jc 1f
- ret
-1:
-#ifdef __PIC__
- movq PIC_GOT(CERROR), %rcx
- jmp *%rcx
-#else
- jmp CERROR
-#endif
-SYSCALL_END(syscall)
+RSYSCALL(syscall)
diff --git a/lib/libc/arch/amd64/sys/tfork_thread.S b/lib/libc/arch/amd64/sys/tfork_thread.S
index 0f67225830e..3477228a40b 100644
--- a/lib/libc/arch/amd64/sys/tfork_thread.S
+++ b/lib/libc/arch/amd64/sys/tfork_thread.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: tfork_thread.S,v 1.5 2015/06/01 09:27:53 uebayasi Exp $ */
+/* $OpenBSD: tfork_thread.S,v 1.6 2016/05/07 19:05:21 guenther Exp $ */
/*-
* Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org>
* Copyright (c) 2003 Alan L. Cox <alc@cs.rice.edu>
@@ -85,10 +85,6 @@ ENTRY(__tfork_thread)
* Branch here if the thread creation fails:
*/
2:
-#ifdef __PIC__
- movq PIC_GOT(CERROR), %rcx
- jmp *%rcx
-#else
- jmp CERROR
-#endif
+ SET_ERRNO
+ ret
END(__tfork_thread)