diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2020-10-01 01:05:41 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2020-10-01 01:05:41 +0000 |
commit | d90e891a92aa8add7b82f48b1c3c2e15eb47a67d (patch) | |
tree | 16701a85391198060dab52f08618393ee7e84b6c /lib | |
parent | f4aa307936fa87d76580027c0c246301d8c56f96 (diff) |
Mark top-level frame for new thread in both CFI and with zero
framepointer, so gdb knows to stop. Inspired by glibc
ok kettenis@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/arch/aarch64/sys/tfork_thread.S | 8 | ||||
-rw-r--r-- | lib/libc/arch/amd64/sys/tfork_thread.S | 10 |
2 files changed, 16 insertions, 2 deletions
diff --git a/lib/libc/arch/aarch64/sys/tfork_thread.S b/lib/libc/arch/aarch64/sys/tfork_thread.S index 6e515c32b24..6dca582bd31 100644 --- a/lib/libc/arch/aarch64/sys/tfork_thread.S +++ b/lib/libc/arch/aarch64/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.3 2018/08/12 17:15:10 mortimer Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.4 2020/10/01 01:05:40 guenther Exp $ */ /* * Copyright (c) 2005 Dale Rahn <drahn@openbsd.org> * @@ -24,8 +24,10 @@ */ ENTRY(__tfork_thread) + .cfi_startproc RETGUARD_SETUP(__tfork_thread, x15) SYSTRAP(__tfork) + .cfi_endproc bcs CERROR /* check if we are parent or child */ @@ -34,8 +36,12 @@ ENTRY(__tfork_thread) ret 1: + .cfi_startproc + .cfi_undefined lr /* child */ + ldr fp, 0 mov x0, x3 blr x2 SYSTRAP(__threxit) + .cfi_endproc END(__tfork_thread) diff --git a/lib/libc/arch/amd64/sys/tfork_thread.S b/lib/libc/arch/amd64/sys/tfork_thread.S index f0d9c494aef..647f070cbcc 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.8 2019/05/10 01:31:30 guenther Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.9 2020/10/01 01:05:40 guenther Exp $ */ /*- * Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org> * Copyright (c) 2003 Alan L. Cox <alc@cs.rice.edu> @@ -45,6 +45,7 @@ */ ENTRY(__tfork_thread) + .cfi_startproc movq %rdx, %r8 movq %rcx, %r9 @@ -52,6 +53,7 @@ ENTRY(__tfork_thread) * Prepare and execute the thread creation syscall */ movl $SYS___tfork, %eax + .cfi_endproc syscall jb 2f @@ -64,6 +66,7 @@ ENTRY(__tfork_thread) /* the retpoline we'll use to call the child's main */ _ALIGN_TRAPS + .cfi_startproc 0: JMP_RETPOLINE(r8) /* @@ -73,6 +76,10 @@ ENTRY(__tfork_thread) */ _ALIGN_TRAPS 1: + /* Mark top frame of new thread in CFI and with zero FP */ + .cfi_undefined rip + .cfi_undefined rsp + xorl %ebp, %ebp movq %r9, %rdi call 0b @@ -89,4 +96,5 @@ ENTRY(__tfork_thread) 2: SET_ERRNO ret + .cfi_endproc END(__tfork_thread) |