summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/arch/powerpc64/SYS.h45
-rw-r--r--lib/libc/arch/powerpc64/string/ffs.S4
-rw-r--r--lib/libc/arch/powerpc64/string/memmove.S8
-rw-r--r--lib/libc/arch/powerpc64/sys/brk.S16
-rw-r--r--lib/libc/arch/powerpc64/sys/sbrk.S13
-rw-r--r--lib/libc/arch/powerpc64/sys/sigpending.S10
-rw-r--r--lib/libc/arch/powerpc64/sys/sigprocmask.S11
-rw-r--r--lib/libc/arch/powerpc64/sys/sigsuspend.S16
8 files changed, 77 insertions, 46 deletions
diff --git a/lib/libc/arch/powerpc64/SYS.h b/lib/libc/arch/powerpc64/SYS.h
index b239fffc8ea..7ab8622b000 100644
--- a/lib/libc/arch/powerpc64/SYS.h
+++ b/lib/libc/arch/powerpc64/SYS.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: SYS.h,v 1.3 2020/07/14 16:48:13 kettenis Exp $ */
+/* $OpenBSD: SYS.h,v 1.4 2020/10/16 23:42:14 deraadt Exp $ */
/*-
* Copyright (c) 1994
* Andrew Cagney. All rights reserved.
@@ -54,40 +54,39 @@
/* offset of errno from %r13 */
#define R13_OFFSET_ERRNO (-TCB_OFFSET + TCB_OFFSET_ERRNO)
-#define _CONCAT(x,y) x##y
-#define PSEUDO_PREFIX(p,x,y) \
- ENTRY(p##x) \
- li %r0, SYS_##y ; \
- /* sc */
-#define PSEUDO_SUFFIX cmpwi %r0, 0 ; \
- beqlr ; \
- stw %r0, R13_OFFSET_ERRNO(%r13); \
- li %r3, -1; \
- blr
-
-#define PSEUDO_NOERROR_SUFFIX blr
-
+#define SYSENTRY(x) .weak _C_LABEL(x); \
+ _C_LABEL(x) = _C_LABEL(_thread_sys_ ## x); \
+ ENTRY(_thread_sys_ ## x)
+#define SYSENTRY_HIDDEN(x) ENTRY(_thread_sys_ ## x)
#define __END_HIDDEN(p,x) END(p##x); \
_HIDDEN_FALIAS(x,p##x); \
END(_HIDDEN(x))
#define __END(p,x) __END_HIDDEN(p,x); END(x)
-
-#define ALIAS(x,y) WEAK_ALIAS(y,_CONCAT(x,y));
+#define ALIAS(x,y) WEAK_ALIAS(y, x ## y);
-#define PREFIX_HIDDEN(x) PSEUDO_PREFIX(_thread_sys_,x,x)
-#define PREFIX(x) ALIAS(_thread_sys_,x) \
- PREFIX_HIDDEN(x)
#define PSEUDO_NOERROR(x,y) ALIAS(_thread_sys_,x) \
- PSEUDO_PREFIX(_thread_sys_,x,y) ; \
+ ENTRY(_thread_sys_ ## x) \
+ RETGUARD_SETUP(_thread_sys_ ## x, %r11); \
+ li %r0, SYS_ ## y ; \
sc ; \
- PSEUDO_NOERROR_SUFFIX; \
+ RETGUARD_CHECK(_thread_sys_ ## x, %r11); \
+ blr; \
__END(_thread_sys_,x)
-#define PSEUDO_HIDDEN(x,y) PSEUDO_PREFIX(_thread_sys_,x,y) ; \
+#define PSEUDO_HIDDEN(x,y) ENTRY(_thread_sys_ ## x) \
+ RETGUARD_SETUP(_thread_sys_ ## x, %r11); \
+ li %r0, SYS_ ## y ; \
sc ; \
- PSEUDO_SUFFIX; \
+ cmpwi %r0, 0 ; \
+ beq .L_ret ; \
+ stw %r0, R13_OFFSET_ERRNO(%r13); \
+ li %r3, -1; \
+ .L_ret: \
+ RETGUARD_CHECK(_thread_sys_ ## x, %r11); \
+ blr; \
__END_HIDDEN(_thread_sys_,x)
+
#define PSEUDO(x,y) ALIAS(_thread_sys_,x) \
PSEUDO_HIDDEN(x,y); \
END(x)
diff --git a/lib/libc/arch/powerpc64/string/ffs.S b/lib/libc/arch/powerpc64/string/ffs.S
index 8e656698ec9..8f6ec55421f 100644
--- a/lib/libc/arch/powerpc64/string/ffs.S
+++ b/lib/libc/arch/powerpc64/string/ffs.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs.S,v 1.1 2020/06/26 20:16:21 naddy Exp $ */
+/* $OpenBSD: ffs.S,v 1.2 2020/10/16 23:42:16 deraadt Exp $ */
/*
* Written by Christian Weisgerber <naddy@openbsd.org>.
* Public domain.
@@ -7,9 +7,11 @@
#include "DEFS.h"
ENTRY(ffs)
+ RETGUARD_SETUP(ffs, %r11);
neg %r4, %r3
and %r3, %r3, %r4
cntlzw %r3, %r3
subfic %r3, %r3, 32
+ RETGUARD_CHECK(ffs, %r11);
blr
END_BUILTIN(ffs)
diff --git a/lib/libc/arch/powerpc64/string/memmove.S b/lib/libc/arch/powerpc64/string/memmove.S
index a944320f390..3c869495983 100644
--- a/lib/libc/arch/powerpc64/string/memmove.S
+++ b/lib/libc/arch/powerpc64/string/memmove.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: memmove.S,v 1.1 2020/06/25 02:34:22 drahn Exp $ */
+/* $OpenBSD: memmove.S,v 1.2 2020/10/16 23:42:16 deraadt Exp $ */
/* $NetBSD: memmove.S,v 1.3 2011/01/15 07:31:12 matt Exp $ */
/* stropt/memmove.S, pl_string_common, pl_linux 10/11/04 11:45:37
@@ -56,6 +56,7 @@ ENTRY(bcopy)
/* void *memmove(void *, const void *, size_t) */
ENTRY(memmove)
+ RETGUARD_SETUP(memmove, %r11);
mr %r8, %r3 /* Save dst (return value) */
cmpd %r4, %r8 /* Branch to reverse if */
@@ -110,8 +111,7 @@ last2:
lbzu %r6, 1(%r4) /* But handle the rest by */
stbu %r6, 1(%r8) /* updating addr by 1 */
bdnz+ last2
-
- blr
+ b done
/* We're here since src < dest. Don't want to overwrite end of */
/* src with start of dest */
@@ -165,6 +165,8 @@ rlast2:
bdnz+ rlast2 /* Dec ctr, and branch if more */
/* bytes left */
+done:
+ RETGUARD_CHECK(memmove, %r11);
blr
END_STRONG(memmove)
END_WEAK(bcopy)
diff --git a/lib/libc/arch/powerpc64/sys/brk.S b/lib/libc/arch/powerpc64/sys/brk.S
index 59de5e0c016..9875e9530f0 100644
--- a/lib/libc/arch/powerpc64/sys/brk.S
+++ b/lib/libc/arch/powerpc64/sys/brk.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: brk.S,v 1.3 2020/07/27 07:10:36 kettenis Exp $ */
+/* $OpenBSD: brk.S,v 1.4 2020/10/16 23:42:16 deraadt Exp $ */
/*
* Copyright (c) 1996 Dale Rahn
@@ -32,7 +32,9 @@
.weak brk
-PSEUDO_PREFIX(,brk,break)
+SYSENTRY(brk)
+ RETGUARD_SETUP(brk, %r11)
+
/* check >= _end, if not make the call for _end */
addis %r5, %r2, .LC0@toc@ha
ld %r5, .LC0@toc@l(%r5) /* # %r5 = &_end */
@@ -47,6 +49,7 @@ PSEUDO_PREFIX(,brk,break)
addis %r6, %r2, __curbrk@toc@ha
addi %r6, %r6, __curbrk@toc@l /* # %r6 = &__curbrk */
+ li %r0, SYS_break
sc
/* check for error */
@@ -54,17 +57,18 @@ PSEUDO_PREFIX(,brk,break)
beq+ .L_brk_ok /* OK so this is stupid but I haven't read b */
stw %r0, R13_OFFSET_ERRNO(%r13)
li %r3, -1
- blr
+ b .L_done
nop
/* update, __curbrk and return */
.L_brk_ok:
std %r7, 0(%r6) /* # remember, %r6=&__curbrk, %r3=new value */
mr %r3, 0 /* # return 0 */
+.L_done:
+ RETGUARD_CHECK(brk, %r11);
blr
END(brk)
- .section .toc,"aw",@progbits
+ .section .toc,"aw",@progbits
.LC0:
- .tc _end[TC],_end
-
+ .tc _end[TC],_end
diff --git a/lib/libc/arch/powerpc64/sys/sbrk.S b/lib/libc/arch/powerpc64/sys/sbrk.S
index 9d738f44749..28f04efa5d8 100644
--- a/lib/libc/arch/powerpc64/sys/sbrk.S
+++ b/lib/libc/arch/powerpc64/sys/sbrk.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sbrk.S,v 1.3 2020/07/27 05:08:57 gkoehler Exp $ */
+/* $OpenBSD: sbrk.S,v 1.4 2020/10/16 23:42:16 deraadt Exp $ */
/*
* Copyright (c) 1996 Dale Rahn
@@ -39,7 +39,9 @@ __curbrk:
.weak sbrk
.text
-PSEUDO_PREFIX(,sbrk,break)
+SYSENTRY(sbrk)
+ RETGUARD_SETUP(sbrk, %r11)
+
/* call break(__curbrk + size) */
addis %r6, %r2, __curbrk@toc@ha
addi %r6, %r6, __curbrk@toc@l /* # %r6 = &__curbrk */
@@ -48,6 +50,7 @@ PSEUDO_PREFIX(,sbrk,break)
add %r3, %r5, %r3 /* # %r3 = new_curbrk */
mr %r7, %r3
+ li %r0, SYS_break
sc
/* check for error */
@@ -55,11 +58,13 @@ PSEUDO_PREFIX(,sbrk,break)
beq+ .L_sbrk_ok
stw %r0, R13_OFFSET_ERRNO(%r13)
li %r3, -1
- blr
+ b .L_done
/* update, __curbrk and return */
.L_sbrk_ok:
std %r7, 0(%r6) /* # remember, %r6=&__curbrk, %r7=new_curbrk */
mr %r3, %r5 /* # remember, %r5=old_curbrk */
+.L_done:
+ RETGUARD_CHECK(sbrk, %r11);
blr
-END(sbrk)
+ END(sbrk)
diff --git a/lib/libc/arch/powerpc64/sys/sigpending.S b/lib/libc/arch/powerpc64/sys/sigpending.S
index 1b36eece3eb..0af6670dd32 100644
--- a/lib/libc/arch/powerpc64/sys/sigpending.S
+++ b/lib/libc/arch/powerpc64/sys/sigpending.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigpending.S,v 1.1 2020/06/25 02:38:28 drahn Exp $ */
+/* $OpenBSD: sigpending.S,v 1.2 2020/10/16 23:42:16 deraadt Exp $ */
/*
* Copyright (c) 2012 Mark Kettenis
*
@@ -20,10 +20,14 @@
#include "SYS.h"
.text
-PREFIX(sigpending)
+SYSENTRY(sigpending)
+ RETGUARD_SETUP(sigpending, %r11)
+ li %r0, SYS_sigpending
+
mr %r5, %r3
sc
stw %r3, 0(%r5)
li %r3, 0
+ RETGUARD_CHECK(sigpending, %r11)
blr
-SYSCALL_END(sigpending)
+SYSCALL_END_HIDDEN(sigpending)
diff --git a/lib/libc/arch/powerpc64/sys/sigprocmask.S b/lib/libc/arch/powerpc64/sys/sigprocmask.S
index edecf31d1be..29342cac89e 100644
--- a/lib/libc/arch/powerpc64/sys/sigprocmask.S
+++ b/lib/libc/arch/powerpc64/sys/sigprocmask.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigprocmask.S,v 1.3 2020/06/28 07:15:30 kettenis Exp $ */
+/* $OpenBSD: sigprocmask.S,v 1.4 2020/10/16 23:42:16 deraadt Exp $ */
/*
* Copyright (c) 1996 Dale Rahn
@@ -30,7 +30,10 @@
#include "SYS.h"
.text
-PREFIX_HIDDEN(sigprocmask)
+SYSENTRY_HIDDEN(sigprocmask)
+ RETGUARD_SETUP(sigprocmask, %r11)
+ li %r0, SYS_sigprocmask
+
stdu %r1, -32(%r1)
std %r5, 16(%r1)
@@ -51,7 +54,7 @@ PREFIX_HIDDEN(sigprocmask)
beq+ .L_sigprocmask_ok
stw %r0, R13_OFFSET_ERRNO(%r13)
li %r3, -1
- blr
+ b .L_end
.L_sigprocmask_ok:
ld %r5, 16(%r1)
@@ -61,5 +64,7 @@ PREFIX_HIDDEN(sigprocmask)
.L_sigprocmask_done:
li %r3, 0
addi %r1, %r1, 32
+.L_end:
+ RETGUARD_CHECK(sigprocmask, %r11)
blr
SYSCALL_END_HIDDEN(sigprocmask)
diff --git a/lib/libc/arch/powerpc64/sys/sigsuspend.S b/lib/libc/arch/powerpc64/sys/sigsuspend.S
index 911b68df272..74b5f0f5153 100644
--- a/lib/libc/arch/powerpc64/sys/sigsuspend.S
+++ b/lib/libc/arch/powerpc64/sys/sigsuspend.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigsuspend.S,v 1.2 2020/06/26 10:31:44 kettenis Exp $ */
+/* $OpenBSD: sigsuspend.S,v 1.3 2020/10/16 23:42:16 deraadt Exp $ */
/*
* Copyright (c) 1996 Dale Rahn <drahn@openbsd.org>
@@ -30,8 +30,18 @@
#include "SYS.h"
.text
-PREFIX_HIDDEN(sigsuspend)
+SYSENTRY(sigsuspend)
+ RETGUARD_SETUP(sigsuspend, %r11)
+ li %r0, SYS_sigsuspend
+
lwz %r3, 0(%r3) /* load the mask */
sc
- PSEUDO_SUFFIX
+
+ cmpwi %r0, 0
+ beq .L_ret
+ stw %r0, R13_OFFSET_ERRNO(%r13)
+ li %r3, -1
+.L_ret:
+ RETGUARD_CHECK(sigsuspend, %r11);
+ blr
SYSCALL_END_HIDDEN(sigsuspend)