summaryrefslogtreecommitdiffstats
path: root/lib/libc/arch
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2015-08-23 15:51:28 +0000
committerkettenis <kettenis@openbsd.org>2015-08-23 15:51:28 +0000
commita2e13100bb00cdac36cb40c97ff370932ffd6903 (patch)
treeeaecb6b0f95b1e04e1df5e4935f65a82f6369ce4 /lib/libc/arch
parentFetch the _GLOBAL_OFFSET_TABLE_ pointer in a way that's compatible with the (diff)
downloadwireguard-openbsd-a2e13100bb00cdac36cb40c97ff370932ffd6903.tar.xz
wireguard-openbsd-a2e13100bb00cdac36cb40c97ff370932ffd6903.zip
Make __cerror() use the per-thread errno location if r2 isn't zero. This way
libpthread no longer has to override it which means that we can use a local call and can avoid setting up r30 as a _GLOBAL_OFFSET_TABLE_ pointer, which is hard the way the powerpc ABI works. For now we continue to provide __cerror as a weak symbol, but ___cerror is now protected and internal calls within libc now use ___cerror instead of __cerror. discussed with guenther@
Diffstat (limited to 'lib/libc/arch')
-rw-r--r--lib/libc/arch/powerpc/SYS.h6
-rw-r--r--lib/libc/arch/powerpc/sys/cerror.S28
-rw-r--r--lib/libc/arch/powerpc/sys/sigprocmask.S4
-rw-r--r--lib/libc/arch/powerpc/sys/tfork_thread.S4
4 files changed, 25 insertions, 17 deletions
diff --git a/lib/libc/arch/powerpc/SYS.h b/lib/libc/arch/powerpc/SYS.h
index fdd4e8913e3..6303d68f7b6 100644
--- a/lib/libc/arch/powerpc/SYS.h
+++ b/lib/libc/arch/powerpc/SYS.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: SYS.h,v 1.16 2015/04/07 01:27:06 guenther Exp $ */
+/* $OpenBSD: SYS.h,v 1.17 2015/08/23 15:51:28 kettenis Exp $ */
/*-
* Copyright (c) 1994
* Andrew Cagney. All rights reserved.
@@ -45,13 +45,13 @@
#include "machine/asm.h"
#define _CONCAT(x,y) x##y
-#define PSEUDO_PREFIX(p,x,y) .extern _ASM_LABEL(__cerror) ; \
+#define PSEUDO_PREFIX(p,x,y) .extern _ASM_LABEL(___cerror) ; \
ENTRY(p##x) \
li 0, SYS_##y ; \
/* sc */
#define PSEUDO_SUFFIX cmpwi 0, 0 ; \
beqlr+ ; \
- b PIC_PLT(_ASM_LABEL(__cerror))
+ b _ASM_LABEL(___cerror)
#define PSEUDO_NOERROR_SUFFIX blr
diff --git a/lib/libc/arch/powerpc/sys/cerror.S b/lib/libc/arch/powerpc/sys/cerror.S
index d2cbc5e17c6..db7ba4a84a6 100644
--- a/lib/libc/arch/powerpc/sys/cerror.S
+++ b/lib/libc/arch/powerpc/sys/cerror.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: cerror.S,v 1.9 2012/08/22 22:26:16 deraadt Exp $ */
+/* $OpenBSD: cerror.S,v 1.10 2015/08/23 15:51:28 kettenis Exp $ */
/*
* Copyright (c) 1996 Dale Rahn
@@ -28,28 +28,36 @@
#include "SYS.h"
#include <machine/asm.h>
+#define ERRNOPTR_OFFSET 16
+
WEAK_ALIAS(__cerror, ___cerror)
.text
+ .protected _ASM_LABEL(___cerror)
ASENTRY(___cerror)
+ cmpwi 2, 0
+ bne- .L_threaded
+
#if defined (__PIC__)
- stwu 1, -16(1) /* follow the SVR4 ABI */
mflr 3 /* error value is in r0, use r3 */
- stw 3, 20(1)
- bl _GLOBAL_OFFSET_TABLE_@local-4
- mflr 4
+ bcl 20, 31, 1f
+1: mflr 4
+ addis 4, 4, _GLOBAL_OFFSET_TABLE_-1b@ha
+ addi 4, 4, _GLOBAL_OFFSET_TABLE_-1b@l
lwz 5,_C_LABEL(errno)@got(4)
+ mtlr 3
#else
addis 5, 0, errno@H
ori 5, 5, errno@L
#endif
+ b .L_do_store
+
+.L_threaded:
+ lwz 5, 4(2)
+ lwz 5, ERRNOPTR_OFFSET(5)
+.L_do_store:
stw 0, 0(5)
addi 3, 0, -1
addi 4, 0, -1
-#if defined (__PIC__)
- lwz 0, 20(1)
- mtlr 0
- addi 1, 1, 16 /* follow the SVR4 ABI */
-#endif
blr
diff --git a/lib/libc/arch/powerpc/sys/sigprocmask.S b/lib/libc/arch/powerpc/sys/sigprocmask.S
index 64bc0222a66..4bdb7c7b755 100644
--- a/lib/libc/arch/powerpc/sys/sigprocmask.S
+++ b/lib/libc/arch/powerpc/sys/sigprocmask.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigprocmask.S,v 1.7 2002/10/07 04:47:12 drahn Exp $ */
+/* $OpenBSD: sigprocmask.S,v 1.8 2015/08/23 15:51:28 kettenis Exp $ */
/*
* Copyright (c) 1996 Dale Rahn
@@ -49,7 +49,7 @@ PREFIX(sigprocmask)
/* didnt work? */
cmpwi 0, 0
beq+ .L_sigprocmask_ok
- b PIC_PLT(_ASM_LABEL(__cerror))
+ b _ASM_LABEL(___cerror)
.L_sigprocmask_ok:
lwz 5, 12(1)
diff --git a/lib/libc/arch/powerpc/sys/tfork_thread.S b/lib/libc/arch/powerpc/sys/tfork_thread.S
index aa5f59c966d..4d93fda6e6c 100644
--- a/lib/libc/arch/powerpc/sys/tfork_thread.S
+++ b/lib/libc/arch/powerpc/sys/tfork_thread.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: tfork_thread.S,v 1.2 2012/06/21 00:56:59 guenther Exp $ */
+/* $OpenBSD: tfork_thread.S,v 1.3 2015/08/23 15:51:28 kettenis Exp $ */
/*
* Copyright (c) 2005 Tim Wiess <tim@nop.cx>
@@ -46,4 +46,4 @@ ENTRY(__tfork_thread)
1:
li %r3, -1
2:
- b PIC_PLT(_C_LABEL(__cerror))
+ b _C_LABEL(___cerror)