summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2022-12-24 10:49:20 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2022-12-24 10:49:20 +0000
commitecd2971d1cb9dbe6c04dbc327fe0af24bb3cbfb5 (patch)
treee1f97cf87b7dccedb75229b8f51c6fa8e74bd703 /lib/libc
parent167cb6a1bce33efa36c00a2cf0d1006078ae8c99 (diff)
Don't use a literal pool in .text to load the setjmp magic value as this is
incompatible with executable-only code. ok deraadt@, guenther@
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/arch/aarch64/gen/_setjmp.S11
-rw-r--r--lib/libc/arch/aarch64/gen/setjmp.S12
-rw-r--r--lib/libc/arch/aarch64/gen/sigsetjmp.S8
3 files changed, 13 insertions, 18 deletions
diff --git a/lib/libc/arch/aarch64/gen/_setjmp.S b/lib/libc/arch/aarch64/gen/_setjmp.S
index c646f803acb..91c8c2d4065 100644
--- a/lib/libc/arch/aarch64/gen/_setjmp.S
+++ b/lib/libc/arch/aarch64/gen/_setjmp.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: _setjmp.S,v 1.5 2022/05/24 22:35:27 guenther Exp $ */
+/* $OpenBSD: _setjmp.S,v 1.6 2022/12/24 10:49:19 kettenis Exp $ */
/*-
* Copyright (c) 2014 Andrew Turner
* Copyright (c) 2014 The FreeBSD Foundation
@@ -36,7 +36,8 @@
ENTRY(_setjmp)
RETGUARD_SETUP(_setjmp, x15)
/* Store the magic value and stack pointer */
- ldr x8, .Lmagic
+ movz x8, #(_JB_MAGIC__SETJMP & 0xffff)
+ movk x8, #(_JB_MAGIC__SETJMP >> 16), lsl #16
mov x9, sp
stp x8, x9, [x0], #16
@@ -62,9 +63,6 @@ ENTRY(_setjmp)
mov x0, #0
RETGUARD_CHECK(_setjmp, x15)
ret
- .align 3
-.Lmagic:
- .quad _JB_MAGIC__SETJMP
END_STRONG(_setjmp)
ENTRY(_longjmp)
@@ -72,7 +70,8 @@ ENTRY(_longjmp)
RETGUARD_LOAD_RANDOM(_longjmp, x15)
/* Check the magic value */
ldr x8, [x0], #8
- ldr x9, .Lmagic
+ movz x9, #(_JB_MAGIC__SETJMP & 0xffff)
+ movk x9, #(_JB_MAGIC__SETJMP >> 16), lsl #16
cmp x8, x9
b.ne .Lbotch
diff --git a/lib/libc/arch/aarch64/gen/setjmp.S b/lib/libc/arch/aarch64/gen/setjmp.S
index 3fa2282c454..23dd54f8751 100644
--- a/lib/libc/arch/aarch64/gen/setjmp.S
+++ b/lib/libc/arch/aarch64/gen/setjmp.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: setjmp.S,v 1.5 2022/05/24 22:35:27 guenther Exp $ */
+/* $OpenBSD: setjmp.S,v 1.6 2022/12/24 10:49:19 kettenis Exp $ */
/*-
* Copyright (c) 2014 Andrew Turner
* Copyright (c) 2014 The FreeBSD Foundation
@@ -45,7 +45,8 @@ ENTRY(setjmp)
mov x0, x2
/* Store the magic value and stack pointer */
- ldr x8, .Lmagic
+ movz x8, #(_JB_MAGIC_SETJMP & 0xffff)
+ movk x8, #(_JB_MAGIC_SETJMP >> 16), lsl #16
mov x9, sp
stp x8, x9, [x0], #16
@@ -69,10 +70,6 @@ ENTRY(setjmp)
mov x0, #0
RETGUARD_CHECK(setjmp, x15)
ret
-
- .align 3
-.Lmagic:
- .quad _JB_MAGIC_SETJMP
END_STRONG(setjmp)
ENTRY(longjmp)
@@ -89,7 +86,8 @@ ENTRY(longjmp)
mov x0, x2
/* Check the magic value */
ldr x8, [x0], #8
- ldr x9, .Lmagic
+ movz x9, #(_JB_MAGIC_SETJMP & 0xffff)
+ movk x9, #(_JB_MAGIC_SETJMP >> 16), lsl #16
cmp x8, x9
b.ne .Lbotch
diff --git a/lib/libc/arch/aarch64/gen/sigsetjmp.S b/lib/libc/arch/aarch64/gen/sigsetjmp.S
index 559985459a4..73429973eeb 100644
--- a/lib/libc/arch/aarch64/gen/sigsetjmp.S
+++ b/lib/libc/arch/aarch64/gen/sigsetjmp.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigsetjmp.S,v 1.2 2017/03/22 07:31:35 guenther Exp $ */
+/* $OpenBSD: sigsetjmp.S,v 1.3 2022/12/24 10:49:19 kettenis Exp $ */
/*-
* Copyright (c) 2014 The FreeBSD Foundation
* All rights reserved.
@@ -39,14 +39,12 @@ END(sigsetjmp)
ENTRY(siglongjmp)
/* Load the _setjmp magic */
- ldr x2, .Lmagic
+ movz x2, #(_JB_MAGIC__SETJMP & 0xffff)
+ movk x2, #(_JB_MAGIC__SETJMP >> 16), lsl #16
ldr x3, [x0]
/* Check the magic */
cmp x2, x3
b.eq _HIDDEN(_longjmp)
b _HIDDEN(longjmp)
-.Lmagic:
- .align 3
- .quad _JB_MAGIC__SETJMP
END(siglongjmp)