summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormortimer <mortimer@cvs.openbsd.org>2018-07-03 23:14:06 +0000
committermortimer <mortimer@cvs.openbsd.org>2018-07-03 23:14:06 +0000
commit7aefc4f8037c6e66630a59b4e627e17b6a3cdb2f (patch)
tree10292d1b48a8c20d907cf7e2f0296fd4ac9fc670 /lib
parent8e58489b257b1aa53deea6bd33d90e6de1e2ab94 (diff)
Add retguard macros for libc.
ok deraadt
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/arch/amd64/gen/fabs.S4
-rw-r--r--lib/libc/arch/amd64/gen/flt_rounds.S4
-rw-r--r--lib/libc/arch/amd64/gen/fpgetmask.S4
-rw-r--r--lib/libc/arch/amd64/gen/fpgetround.S4
-rw-r--r--lib/libc/arch/amd64/gen/fpgetsticky.S4
-rw-r--r--lib/libc/arch/amd64/gen/fpsetmask.S4
-rw-r--r--lib/libc/arch/amd64/gen/fpsetround.S4
-rw-r--r--lib/libc/arch/amd64/gen/fpsetsticky.S4
-rw-r--r--lib/libc/arch/amd64/gen/modf.S4
-rw-r--r--lib/libc/arch/amd64/net/htonl.S4
-rw-r--r--lib/libc/arch/amd64/net/htons.S4
-rw-r--r--lib/libc/arch/amd64/net/ntohl.S4
-rw-r--r--lib/libc/arch/amd64/net/ntohs.S4
-rw-r--r--lib/libc/arch/amd64/string/bcmp.S4
-rw-r--r--lib/libc/arch/amd64/string/bzero.S2
-rw-r--r--lib/libc/arch/amd64/string/ffs.S6
-rw-r--r--lib/libc/arch/amd64/string/memchr.S4
-rw-r--r--lib/libc/arch/amd64/string/memmove.S5
-rw-r--r--lib/libc/arch/amd64/string/memset.S2
-rw-r--r--lib/libc/arch/amd64/string/strchr.S8
-rw-r--r--lib/libc/arch/amd64/string/strcmp.S4
-rw-r--r--lib/libc/arch/amd64/string/strlen.S4
-rw-r--r--lib/libc/arch/amd64/string/strrchr.S4
23 files changed, 72 insertions, 23 deletions
diff --git a/lib/libc/arch/amd64/gen/fabs.S b/lib/libc/arch/amd64/gen/fabs.S
index 441bccc17ab..fa032729f5d 100644
--- a/lib/libc/arch/amd64/gen/fabs.S
+++ b/lib/libc/arch/amd64/gen/fabs.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: fabs.S,v 1.7 2015/05/29 08:50:12 uebayasi Exp $ */
+/* $OpenBSD: fabs.S,v 1.8 2018/07/03 23:14:05 mortimer Exp $ */
/* $NetBSD: fabs.S,v 1.1 2001/06/19 00:25:02 fvdl Exp $ */
#include <machine/asm.h>
@@ -9,10 +9,12 @@
*/
ENTRY(fabs)
+ RETGUARD_SETUP(fabs, r11)
movsd %xmm0, -8(%rsp)
fldl -8(%rsp)
fabs
fstpl -8(%rsp)
movsd -8(%rsp),%xmm0
+ RETGUARD_CHECK(fabs, r11)
ret
END(fabs)
diff --git a/lib/libc/arch/amd64/gen/flt_rounds.S b/lib/libc/arch/amd64/gen/flt_rounds.S
index 7b2c284d459..2830a1707b9 100644
--- a/lib/libc/arch/amd64/gen/flt_rounds.S
+++ b/lib/libc/arch/amd64/gen/flt_rounds.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: flt_rounds.S,v 1.7 2017/08/19 18:23:00 deraadt Exp $ */
+/* $OpenBSD: flt_rounds.S,v 1.8 2018/07/03 23:14:05 mortimer Exp $ */
/* $NetBSD: flt_rounds.S,v 1.2 2002/06/06 23:04:35 fvdl Exp $ */
/*
@@ -16,6 +16,7 @@ _map:
.byte 0 /* round to zero */
ENTRY(__flt_rounds)
+ RETGUARD_SETUP(__flt_rounds, r11)
fnstcw -4(%rsp)
movl -4(%rsp),%eax
shrl $10,%eax
@@ -26,5 +27,6 @@ ENTRY(__flt_rounds)
#else
movb _map(,%rax,1),%al
#endif
+ RETGUARD_CHECK(__flt_rounds, r11)
ret
END_STRONG(__flt_rounds)
diff --git a/lib/libc/arch/amd64/gen/fpgetmask.S b/lib/libc/arch/amd64/gen/fpgetmask.S
index f0492049b32..58b77a8916f 100644
--- a/lib/libc/arch/amd64/gen/fpgetmask.S
+++ b/lib/libc/arch/amd64/gen/fpgetmask.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: fpgetmask.S,v 1.2 2015/05/29 08:50:12 uebayasi Exp $ */
+/* $OpenBSD: fpgetmask.S,v 1.3 2018/07/03 23:14:05 mortimer Exp $ */
/* $NetBSD: fpgetmask.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $ */
/*
@@ -20,10 +20,12 @@ ENTRY(_fpgetmask)
#else
ENTRY(fpgetmask)
#endif
+ RETGUARD_SETUP(fpgetmask, r11)
fnstcw -4(%rsp)
movl -4(%rsp),%eax
notl %eax
andl $63,%eax
+ RETGUARD_CHECK(fpgetmask, r11)
ret
#ifdef WEAK_ALIAS
END(_fpgetmask)
diff --git a/lib/libc/arch/amd64/gen/fpgetround.S b/lib/libc/arch/amd64/gen/fpgetround.S
index 69c09f0d0f1..a76f9c77a77 100644
--- a/lib/libc/arch/amd64/gen/fpgetround.S
+++ b/lib/libc/arch/amd64/gen/fpgetround.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: fpgetround.S,v 1.2 2015/05/29 08:50:12 uebayasi Exp $ */
+/* $OpenBSD: fpgetround.S,v 1.3 2018/07/03 23:14:05 mortimer Exp $ */
/* $NetBSD: fpgetround.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $ */
/*
@@ -19,10 +19,12 @@ ENTRY(_fpgetround)
#else
ENTRY(fpgetround)
#endif
+ RETGUARD_SETUP(fpgetround, r11)
fnstcw -4(%rsp)
movl -4(%rsp),%eax
rorl $10,%eax
andl $3,%eax
+ RETGUARD_CHECK(fpgetround, r11)
ret
#ifdef WEAK_ALIAS
END(_fpgetround)
diff --git a/lib/libc/arch/amd64/gen/fpgetsticky.S b/lib/libc/arch/amd64/gen/fpgetsticky.S
index 4217ee6da12..7f077168423 100644
--- a/lib/libc/arch/amd64/gen/fpgetsticky.S
+++ b/lib/libc/arch/amd64/gen/fpgetsticky.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: fpgetsticky.S,v 1.2 2015/05/29 08:50:12 uebayasi Exp $ */
+/* $OpenBSD: fpgetsticky.S,v 1.3 2018/07/03 23:14:05 mortimer Exp $ */
/* $NetBSD: fpgetsticky.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $ */
/*
@@ -20,11 +20,13 @@ ENTRY(_fpgetsticky)
#else
ENTRY(fpgetsticky)
#endif
+ RETGUARD_SETUP(fpgetsticky, r11)
fnstsw -4(%rsp)
stmxcsr -8(%rsp)
movl -4(%rsp),%eax
orl -8(%rsp),%eax
andl $63,%eax
+ RETGUARD_CHECK(fpgetsticky, r11)
ret
#ifdef WEAK_ALIAS
END(_fpgetsticky)
diff --git a/lib/libc/arch/amd64/gen/fpsetmask.S b/lib/libc/arch/amd64/gen/fpsetmask.S
index 8e3dc9b3999..27e6c3f6685 100644
--- a/lib/libc/arch/amd64/gen/fpsetmask.S
+++ b/lib/libc/arch/amd64/gen/fpsetmask.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: fpsetmask.S,v 1.2 2015/05/29 08:50:12 uebayasi Exp $ */
+/* $OpenBSD: fpsetmask.S,v 1.3 2018/07/03 23:14:05 mortimer Exp $ */
/* $NetBSD: fpsetmask.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $ */
/*
@@ -21,6 +21,7 @@ ENTRY(_fpsetmask)
#else
ENTRY(fpsetmask)
#endif
+ RETGUARD_SETUP(fpsetmask, r11)
fnstcw -4(%rsp)
stmxcsr -8(%rsp)
andl $63,%edi
@@ -39,6 +40,7 @@ ENTRY(fpsetmask)
fldcw -4(%rsp)
ldmxcsr -8(%rsp)
andl $63,%eax
+ RETGUARD_CHECK(fpsetmask, r11)
ret
#ifdef WEAK_ALIAS
END(_fpsetmask)
diff --git a/lib/libc/arch/amd64/gen/fpsetround.S b/lib/libc/arch/amd64/gen/fpsetround.S
index 9e6151dd257..398cfda35df 100644
--- a/lib/libc/arch/amd64/gen/fpsetround.S
+++ b/lib/libc/arch/amd64/gen/fpsetround.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: fpsetround.S,v 1.2 2015/05/29 08:50:12 uebayasi Exp $ */
+/* $OpenBSD: fpsetround.S,v 1.3 2018/07/03 23:14:05 mortimer Exp $ */
/* $NetBSD: fpsetround.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $ */
/*
@@ -22,6 +22,7 @@ ENTRY(_fpsetround)
#else
ENTRY(fpsetround)
#endif
+ RETGUARD_SETUP(fpsetround, r11)
fnstcw -4(%rsp)
stmxcsr -8(%rsp)
@@ -46,6 +47,7 @@ ENTRY(fpsetround)
ldmxcsr -8(%rsp)
fldcw -4(%rsp)
+ RETGUARD_CHECK(fpsetround, r11)
ret
#ifdef WEAK_ALIAS
END(_fpsetround)
diff --git a/lib/libc/arch/amd64/gen/fpsetsticky.S b/lib/libc/arch/amd64/gen/fpsetsticky.S
index 5715b449e99..a6ef2e6ac11 100644
--- a/lib/libc/arch/amd64/gen/fpsetsticky.S
+++ b/lib/libc/arch/amd64/gen/fpsetsticky.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: fpsetsticky.S,v 1.3 2015/05/29 08:50:12 uebayasi Exp $ */
+/* $OpenBSD: fpsetsticky.S,v 1.4 2018/07/03 23:14:05 mortimer Exp $ */
/* $NetBSD: fpsetsticky.S,v 1.5 2004/03/09 17:16:13 drochner Exp $ */
/*
@@ -22,6 +22,7 @@ ENTRY(_fpsetsticky)
#else
ENTRY(fpsetsticky)
#endif
+ RETGUARD_SETUP(fpsetsticky, r11)
fnstenv -28(%rsp)
stmxcsr -32(%rsp)
@@ -43,6 +44,7 @@ ENTRY(fpsetsticky)
ldmxcsr -32(%rsp)
fldenv -28(%rsp)
+ RETGUARD_CHECK(fpsetsticky, r11)
ret
#ifdef WEAK_ALIAS
END(_fpsetsticky)
diff --git a/lib/libc/arch/amd64/gen/modf.S b/lib/libc/arch/amd64/gen/modf.S
index 50525e80d72..394e682b086 100644
--- a/lib/libc/arch/amd64/gen/modf.S
+++ b/lib/libc/arch/amd64/gen/modf.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: modf.S,v 1.5 2015/05/29 08:50:12 uebayasi Exp $ */
+/* $OpenBSD: modf.S,v 1.6 2018/07/03 23:14:05 mortimer Exp $ */
/* $NetBSD: modf.S,v 1.1 2001/06/19 00:25:03 fvdl Exp $ */
/*-
@@ -51,6 +51,7 @@
/* With CHOP mode on, frndint behaves as TRUNC does. Useful. */
ENTRY(modf)
+ RETGUARD_SETUP(modf, r11)
/*
* Set chop mode.
@@ -88,5 +89,6 @@ ENTRY(modf)
fstpl -8(%rsp)
movsd -8(%rsp),%xmm0
+ RETGUARD_CHECK(modf, r11)
ret
END(modf)
diff --git a/lib/libc/arch/amd64/net/htonl.S b/lib/libc/arch/amd64/net/htonl.S
index 5d05f5a144e..2895aa4e612 100644
--- a/lib/libc/arch/amd64/net/htonl.S
+++ b/lib/libc/arch/amd64/net/htonl.S
@@ -1,11 +1,13 @@
-/* $OpenBSD: htonl.S,v 1.2 2015/05/29 09:25:28 uebayasi Exp $ */
+/* $OpenBSD: htonl.S,v 1.3 2018/07/03 23:14:05 mortimer Exp $ */
/* Written by Artur Grabowski. Public Domain */
#include <machine/asm.h>
ENTRY(htonl)
+ RETGUARD_SETUP(htonl, r11)
movl %edi,%eax
bswapl %eax
+ RETGUARD_CHECK(htonl, r11)
ret
END(htonl)
diff --git a/lib/libc/arch/amd64/net/htons.S b/lib/libc/arch/amd64/net/htons.S
index 36382f7a39a..51a268d4e4e 100644
--- a/lib/libc/arch/amd64/net/htons.S
+++ b/lib/libc/arch/amd64/net/htons.S
@@ -1,11 +1,13 @@
-/* $OpenBSD: htons.S,v 1.3 2015/05/29 09:25:28 uebayasi Exp $ */
+/* $OpenBSD: htons.S,v 1.4 2018/07/03 23:14:05 mortimer Exp $ */
/* Written by Artur Grabowski. Public Domain */
#include <machine/asm.h>
ENTRY(htons)
+ RETGUARD_SETUP(htons, r11)
movl %edi,%eax
xchgb %ah,%al
+ RETGUARD_CHECK(htons, r11)
ret
END(htons)
diff --git a/lib/libc/arch/amd64/net/ntohl.S b/lib/libc/arch/amd64/net/ntohl.S
index bdd66ad1c88..cd4c34cc492 100644
--- a/lib/libc/arch/amd64/net/ntohl.S
+++ b/lib/libc/arch/amd64/net/ntohl.S
@@ -1,11 +1,13 @@
-/* $OpenBSD: ntohl.S,v 1.3 2015/05/29 09:25:28 uebayasi Exp $ */
+/* $OpenBSD: ntohl.S,v 1.4 2018/07/03 23:14:05 mortimer Exp $ */
/* Written by Artur Grabowski. Public Domain */
#include <machine/asm.h>
ENTRY(ntohl)
+ RETGUARD_SETUP(ntohl, r11)
movl %edi,%eax
bswapl %eax
+ RETGUARD_CHECK(ntohl, r11)
ret
END(ntohl)
diff --git a/lib/libc/arch/amd64/net/ntohs.S b/lib/libc/arch/amd64/net/ntohs.S
index ea2cdd2a32e..c5d740fd64c 100644
--- a/lib/libc/arch/amd64/net/ntohs.S
+++ b/lib/libc/arch/amd64/net/ntohs.S
@@ -1,11 +1,13 @@
-/* $OpenBSD: ntohs.S,v 1.3 2015/05/29 09:25:28 uebayasi Exp $ */
+/* $OpenBSD: ntohs.S,v 1.4 2018/07/03 23:14:05 mortimer Exp $ */
/* Written by Artur Grabowski. Public Domain */
#include <machine/asm.h>
ENTRY(ntohs)
+ RETGUARD_SETUP(ntohs, r11)
movl %edi,%eax
xchgb %ah,%al
+ RETGUARD_CHECK(ntohs, r11)
ret
END(ntohs)
diff --git a/lib/libc/arch/amd64/string/bcmp.S b/lib/libc/arch/amd64/string/bcmp.S
index d0b20aa9aca..a9b4d463c2f 100644
--- a/lib/libc/arch/amd64/string/bcmp.S
+++ b/lib/libc/arch/amd64/string/bcmp.S
@@ -1,6 +1,7 @@
#include "DEFS.h"
ENTRY(bcmp)
+ RETGUARD_SETUP(bcmp, r11)
xorl %eax,%eax /* clear return value */
cld /* set compare direction forward */
@@ -17,5 +18,6 @@ ENTRY(bcmp)
je L2
L1: incl %eax
-L2: ret
+L2: RETGUARD_CHECK(bcmp, r11)
+ ret
END_WEAK(bcmp)
diff --git a/lib/libc/arch/amd64/string/bzero.S b/lib/libc/arch/amd64/string/bzero.S
index f692b57632a..5ffe391736c 100644
--- a/lib/libc/arch/amd64/string/bzero.S
+++ b/lib/libc/arch/amd64/string/bzero.S
@@ -7,6 +7,7 @@
#include "DEFS.h"
ENTRY(bzero)
+ RETGUARD_SETUP(bzero, r11)
movq %rsi,%rdx
cld /* set fill direction forward */
@@ -37,5 +38,6 @@ L1: movq %rdx,%rcx /* zero remainder by bytes */
rep
stosb
+ RETGUARD_CHECK(bzero, r11)
ret
END_WEAK(bzero)
diff --git a/lib/libc/arch/amd64/string/ffs.S b/lib/libc/arch/amd64/string/ffs.S
index 329b1e0c2ac..dcba4ce7f1a 100644
--- a/lib/libc/arch/amd64/string/ffs.S
+++ b/lib/libc/arch/amd64/string/ffs.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs.S,v 1.5 2018/01/18 08:23:44 guenther Exp $ */
+/* $OpenBSD: ffs.S,v 1.6 2018/07/03 23:14:05 mortimer Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
@@ -8,13 +8,15 @@
#include "DEFS.h"
ENTRY(ffs)
+ RETGUARD_SETUP(ffs, r11)
bsfl %edi,%eax
jz L1 /* ZF is set if all bits are 0 */
incl %eax /* bits numbered from 1, not 0 */
- ret
+ jmp L2
_ALIGN_TEXT
L1: xorl %eax,%eax /* clear result */
+L2: RETGUARD_CHECK(ffs, r11)
ret
END(ffs)
.protected ffs
diff --git a/lib/libc/arch/amd64/string/memchr.S b/lib/libc/arch/amd64/string/memchr.S
index 9394c7e738c..e7983d62aac 100644
--- a/lib/libc/arch/amd64/string/memchr.S
+++ b/lib/libc/arch/amd64/string/memchr.S
@@ -7,6 +7,7 @@
#include "DEFS.h"
ENTRY(memchr)
+ RETGUARD_SETUP(memchr, r11)
movb %sil,%al /* set character to search for */
movq %rdx,%rcx /* set length of search */
testq %rcx,%rcx /* test for len == 0 */
@@ -16,7 +17,8 @@ ENTRY(memchr)
scasb
jne L1 /* scan failed, return null */
leaq -1(%rdi),%rax /* adjust result of scan */
- ret
+ jmp L2
L1: xorq %rax,%rax
+L2: RETGUARD_CHECK(memchr, r11)
ret
END_STRONG(memchr)
diff --git a/lib/libc/arch/amd64/string/memmove.S b/lib/libc/arch/amd64/string/memmove.S
index da244c332a1..496a0a37930 100644
--- a/lib/libc/arch/amd64/string/memmove.S
+++ b/lib/libc/arch/amd64/string/memmove.S
@@ -45,6 +45,7 @@ ENTRY(bcopy)
/* fall into memmove */
ENTRY(memmove)
+ RETGUARD_SETUP(memmove, r10)
movq %rdi,%r11 /* save dest */
movq %rdx,%rcx
movq %rdi,%rax
@@ -55,6 +56,7 @@ ENTRY(memmove)
jmp 2f /* nope */
ENTRY(memcpy)
+ RETGUARD_SETUP(memmove, r10)
movq %rdi,%r11 /* save dest */
movq %rdx,%rcx
2:
@@ -68,7 +70,7 @@ ENTRY(memcpy)
rep
movsb
movq %r11,%rax
- ret
+ jmp 3f
1:
addq %rcx,%rdi /* copy backwards. */
addq %rcx,%rsi
@@ -86,6 +88,7 @@ ENTRY(memcpy)
movsq
movq %r11,%rax
cld
+3: RETGUARD_CHECK(memmove, r10)
ret
#ifdef memcpy_in_asm
END_BUILTIN(memcpy)
diff --git a/lib/libc/arch/amd64/string/memset.S b/lib/libc/arch/amd64/string/memset.S
index 2a8645cb1c3..4bced6566d1 100644
--- a/lib/libc/arch/amd64/string/memset.S
+++ b/lib/libc/arch/amd64/string/memset.S
@@ -7,6 +7,7 @@
#include "DEFS.h"
ENTRY(memset)
+ RETGUARD_SETUP(memset, r10)
movq %rsi,%rax
andq $0xff,%rax
movq %rdx,%rcx
@@ -52,5 +53,6 @@ L1: rep
stosb
movq %r11,%rax
+ RETGUARD_CHECK(memset, r10)
ret
END_BUILTIN(memset)
diff --git a/lib/libc/arch/amd64/string/strchr.S b/lib/libc/arch/amd64/string/strchr.S
index 4711116c36a..e5180354eca 100644
--- a/lib/libc/arch/amd64/string/strchr.S
+++ b/lib/libc/arch/amd64/string/strchr.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: strchr.S,v 1.8 2015/11/14 21:53:03 guenther Exp $ */
+/* $OpenBSD: strchr.S,v 1.9 2018/07/03 23:14:05 mortimer Exp $ */
/* $NetBSD: strchr.S,v 1.7 2014/03/22 19:16:34 jakllsch Exp $ */
/*-
@@ -44,6 +44,8 @@ WEAK_ALIAS(index, strchr)
*/
ENTRY(strchr)
+ RETGUARD_SETUP(strchr, r8)
+ RETGUARD_PUSH(r8)
movabsq $0x0101010101010101,%r8
movzbq %sil,%rdx /* value to search for (c) */
@@ -85,7 +87,7 @@ ENTRY(strchr)
bsf %r11,%r11 /* 7, 15, 23 ... 63 */
8: shr $3,%r11 /* 0, 1, 2 .. 7 */
lea -8(%r11,%rdi),%rax
- ret
+ jmp 12f
/* End of string, check whether char is before NUL */
_ALIGN_TEXT /* adds three byte nop */
@@ -97,6 +99,8 @@ ENTRY(strchr)
cmp %r11,%rax
jae 8b /* return 'found' if same - searching for NUL */
11: xor %eax,%eax /* char not found */
+12: RETGUARD_POP(r11)
+ RETGUARD_CHECK(strchr, r11)
ret
/* Source misaligned: read aligned word and make low bytes invalid */
diff --git a/lib/libc/arch/amd64/string/strcmp.S b/lib/libc/arch/amd64/string/strcmp.S
index 11df374cc70..ab5964d1ff1 100644
--- a/lib/libc/arch/amd64/string/strcmp.S
+++ b/lib/libc/arch/amd64/string/strcmp.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: strcmp.S,v 1.7 2015/11/14 21:53:03 guenther Exp $ */
+/* $OpenBSD: strcmp.S,v 1.8 2018/07/03 23:14:05 mortimer Exp $ */
/* $NetBSD: strcmp.S,v 1.2 2014/03/22 19:16:34 jakllsch Exp $ */
/*
@@ -9,6 +9,7 @@
#include "DEFS.h"
ENTRY(strcmp)
+ RETGUARD_SETUP(strcmp, r11)
/*
* Align s1 to word boundary.
* Consider unrolling loop?
@@ -68,5 +69,6 @@ ENTRY(strcmp)
movzbq %al,%rax
movzbq %dl,%rdx
subq %rdx,%rax
+ RETGUARD_CHECK(strcmp, r11)
ret
END_STRONG(strcmp)
diff --git a/lib/libc/arch/amd64/string/strlen.S b/lib/libc/arch/amd64/string/strlen.S
index 8fbc7b2d4f4..881c5f1e34f 100644
--- a/lib/libc/arch/amd64/string/strlen.S
+++ b/lib/libc/arch/amd64/string/strlen.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: strlen.S,v 1.7 2015/12/11 00:05:46 mmcc Exp $ */
+/* $OpenBSD: strlen.S,v 1.8 2018/07/03 23:14:05 mortimer Exp $ */
/* $NetBSD: strlen.S,v 1.6 2014/03/22 19:16:34 jakllsch Exp $ */
/*-
@@ -112,6 +112,7 @@
*/
ENTRY(strlen)
+ RETGUARD_SETUP(strlen, r11)
movabsq $0x0101010101010101,%r8
test $7,%dil
@@ -139,6 +140,7 @@ ENTRY(strlen)
bsf %rdx,%rdx /* 7, 15, 23 ... 63 */
shr $3,%rdx /* 0, 1, 2 ... 7 */
lea -8(%rax,%rdx),%rax
+ RETGUARD_CHECK(strlen, r11)
ret
/* Misaligned, read aligned word and make low bytes non-zero */
diff --git a/lib/libc/arch/amd64/string/strrchr.S b/lib/libc/arch/amd64/string/strrchr.S
index b5ef58806fc..ca4bd3a492a 100644
--- a/lib/libc/arch/amd64/string/strrchr.S
+++ b/lib/libc/arch/amd64/string/strrchr.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: strrchr.S,v 1.8 2015/11/14 21:53:03 guenther Exp $ */
+/* $OpenBSD: strrchr.S,v 1.9 2018/07/03 23:14:05 mortimer Exp $ */
/* $NetBSD: strrchr.S,v 1.3 2014/03/22 19:16:34 jakllsch Exp $ */
/*
@@ -11,6 +11,7 @@
WEAK_ALIAS(rindex, strrchr)
ENTRY(strrchr)
+ RETGUARD_SETUP(strrchr, r11)
movzbq %sil,%rcx
/* zero return value */
@@ -120,5 +121,6 @@ ENTRY(strrchr)
jne .Lloop
.Ldone:
+ RETGUARD_CHECK(strrchr, r11)
ret
END_STRONG(strrchr)