summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2023-11-18 16:26:18 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2023-11-18 16:26:18 +0000
commiteebaec8bf69b2db1088ab7a84b8bc96a3d02473e (patch)
tree01c4cdb241357ce61e341e655dd01bce0c5d750d /lib
parent9039430940e09de13f4467d9fd1a12296a6746f4 (diff)
crt0 uses a helper function in a MD src/libexec/ld.so .h file (rather than
reproducing the relevant defines and code in a different place) to perform minor relocations. If things go very wrong, it would call _dl_exit() -- a locally defined crt0 function which is syscall exit(2). We don't need to call exit(2) for this obscure case which doesn't happen and provides no debugging information. An 'abort' is going to provide better information. So let's change the function name to _dso_abort() and make it a single illegal instruction. ok guenther
Diffstat (limited to 'lib')
-rw-r--r--lib/csu/aarch64/md_init.h8
-rw-r--r--lib/csu/alpha/md_init.h10
-rw-r--r--lib/csu/amd64/md_init.h10
-rw-r--r--lib/csu/arm/md_init.h8
-rw-r--r--lib/csu/boot.h4
-rw-r--r--lib/csu/hppa/boot_md.h4
-rw-r--r--lib/csu/hppa/md_init.h14
-rw-r--r--lib/csu/i386/md_init.h10
-rw-r--r--lib/csu/m88k/md_init.h7
-rw-r--r--lib/csu/mips64/boot_md.h4
-rw-r--r--lib/csu/mips64/md_init.h16
-rw-r--r--lib/csu/powerpc/md_init.h10
-rw-r--r--lib/csu/powerpc64/md_init.h10
-rw-r--r--lib/csu/riscv64/md_init.h6
-rw-r--r--lib/csu/sh/md_init.h10
-rw-r--r--lib/csu/sparc64/md_init.h8
16 files changed, 53 insertions, 86 deletions
diff --git a/lib/csu/aarch64/md_init.h b/lib/csu/aarch64/md_init.h
index 71356c6e93c..c02b804f407 100644
--- a/lib/csu/aarch64/md_init.h
+++ b/lib/csu/aarch64/md_init.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: md_init.h,v 1.11 2023/03/31 18:46:24 kettenis Exp $ */
+/* $OpenBSD: md_init.h,v 1.12 2023/11/18 16:26:16 deraadt Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
@@ -112,10 +112,6 @@
" \n" \
" b ___start \n" \
" \n" \
- "_dl_exit: \n" \
- " mov x8, #" STR(SYS_exit) " \n" \
- " svc #0 \n" \
- " dsb nsh \n" \
- " isb \n" \
+ "_csu_abort: \n" \
" udf #0 \n" \
".previous");
diff --git a/lib/csu/alpha/md_init.h b/lib/csu/alpha/md_init.h
index d503c751913..76c80b2d561 100644
--- a/lib/csu/alpha/md_init.h
+++ b/lib/csu/alpha/md_init.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: md_init.h,v 1.12 2020/10/15 16:30:23 deraadt Exp $ */
+/* $OpenBSD: md_init.h,v 1.13 2023/11/18 16:26:16 deraadt Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
* All rights reserved.
@@ -95,11 +95,9 @@
" mov $9, $16 \n" \
" mov 0, $17 \n" \
" jsr $26, ___start \n" \
- ".globl _dl_exit \n" \
- ".type _dl_exit@function \n" \
- "_dl_exit: \n" \
- " lda $0, " STR(SYS_exit) " \n" \
- " callsys \n" \
+ ".globl _csu_abort \n" \
+ ".type _csu_abort@function \n" \
+ "_csu_abort: \n" \
" halt ")
#define MD_START_ARGS char **sp, void (*cleanup)(void)
diff --git a/lib/csu/amd64/md_init.h b/lib/csu/amd64/md_init.h
index 948e7c928bb..fa9e812c87d 100644
--- a/lib/csu/amd64/md_init.h
+++ b/lib/csu/amd64/md_init.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: md_init.h,v 1.10 2023/04/25 04:10:21 deraadt Exp $ */
+/* $OpenBSD: md_init.h,v 1.11 2023/11/18 16:26:16 deraadt Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
@@ -107,12 +107,10 @@
" addq $8,%rsp \n" \
" jmp ___start \n" \
" \n" \
- " .global _dl_exit \n" \
- " .type _dl_exit,@function \n" \
+ " .global _csu_abort \n" \
+ " .type _csu_abort,@function \n" \
" .align 8 \n" \
- "_dl_exit: \n" \
+ "_csu_abort: \n" \
" endbr64 \n" \
- " movl $ " STR(SYS_exit) ", %eax \n" \
- " syscall \n" \
" int3 \n" \
" .previous")
diff --git a/lib/csu/arm/md_init.h b/lib/csu/arm/md_init.h
index 3a9b581b6dc..63bfc8bee1d 100644
--- a/lib/csu/arm/md_init.h
+++ b/lib/csu/arm/md_init.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: md_init.h,v 1.17 2020/10/19 17:57:40 naddy Exp $ */
+/* $OpenBSD: md_init.h,v 1.18 2023/11/18 16:26:16 deraadt Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
@@ -154,10 +154,6 @@
".L__DYNAMIC: \n" \
" .long _DYNAMIC(GOTOFF) \n" \
" \n" \
- "_dl_exit: \n" \
- " mov r12, #" STR(SYS_exit) " \n" \
- " swi #0 \n" \
- " dsb nsh \n" \
- " isb \n" \
+ "_csu_abort: \n" \
" udf #0 \n" \
".previous");
diff --git a/lib/csu/boot.h b/lib/csu/boot.h
index 72cbfee007b..da6d424bdeb 100644
--- a/lib/csu/boot.h
+++ b/lib/csu/boot.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: boot.h,v 1.34 2022/10/21 18:14:09 deraadt Exp $ */
+/* $OpenBSD: boot.h,v 1.35 2023/11/18 16:26:15 deraadt Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -40,7 +40,7 @@
#include <machine/reloc.h>
__dead
-void _dl_exit(int);
+void _csu_abort(void);
#include "archdep.h"
diff --git a/lib/csu/hppa/boot_md.h b/lib/csu/hppa/boot_md.h
index a770f7af4bb..0a8f4060781 100644
--- a/lib/csu/hppa/boot_md.h
+++ b/lib/csu/hppa/boot_md.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: boot_md.h,v 1.4 2022/10/27 19:40:21 deraadt Exp $ */
+/* $OpenBSD: boot_md.h,v 1.5 2023/11/18 16:26:16 deraadt Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -40,7 +40,7 @@
#include <machine/reloc.h>
__dead
-void _dl_exit(int);
+void _csu_abort(void);
#include "archdep.h"
diff --git a/lib/csu/hppa/md_init.h b/lib/csu/hppa/md_init.h
index 5abe6daff30..7b0813e18fe 100644
--- a/lib/csu/hppa/md_init.h
+++ b/lib/csu/hppa/md_init.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: md_init.h,v 1.15 2020/10/15 16:30:23 deraadt Exp $ */
+/* $OpenBSD: md_init.h,v 1.16 2023/11/18 16:26:16 deraadt Exp $ */
/*
* Copyright (c) 2003 Dale Rahn. All rights reserved.
@@ -137,17 +137,13 @@
" copy %dp, %r19 \n" \
" .exit \n" \
" .procend \n" \
- " .export _dl_exit, entry \n" \
- " .type _dl_exit,@function \n" \
- " .label _dl_exit \n" \
+ " .export _csu_abort, entry \n" \
+ " .type _csu_abort,@function \n" \
+ " .label _csu_abort \n" \
" .proc \n" \
" .callinfo frame=0, calls \n" \
" .entry \n" \
- "_dl_exit: \n" \
- " stw %rp, -24(%sp) \n" \
- " ldil L%0xc0000000, %r1 \n" \
- " ble 4(%sr7, %r1) \n" \
- " ldi " STR(SYS_exit) ", %t1 \n" \
+ "_csu_abort: \n" \
" break 0,0 \n" \
" .exit \n" \
" .procend")
diff --git a/lib/csu/i386/md_init.h b/lib/csu/i386/md_init.h
index efd601d12bc..f401328e79e 100644
--- a/lib/csu/i386/md_init.h
+++ b/lib/csu/i386/md_init.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: md_init.h,v 1.12 2023/04/25 04:06:06 deraadt Exp $ */
+/* $OpenBSD: md_init.h,v 1.13 2023/11/18 16:26:16 deraadt Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
@@ -114,10 +114,8 @@
" call ___start # ___start(argc,argv,envp,0) \n" \
" \n" \
" .align 4 \n" \
- " .globl _dl_exit \n" \
- " .type _dl_exit,@function \n" \
- "_dl_exit: \n" \
- " mov $" STR(SYS_exit) ", %eax\n" \
- " int $0x80 \n" \
+ " .globl _csu_abort \n" \
+ " .type _csu_abort,@function \n" \
+ "_csu_abort: \n" \
" int3 \n" \
" .previous")
diff --git a/lib/csu/m88k/md_init.h b/lib/csu/m88k/md_init.h
index f73ed3e23bf..6f37b9d2f6f 100644
--- a/lib/csu/m88k/md_init.h
+++ b/lib/csu/m88k/md_init.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: md_init.h,v 1.9 2020/10/15 16:30:23 deraadt Exp $ */
+/* $OpenBSD: md_init.h,v 1.10 2023/11/18 16:26:16 deraadt Exp $ */
/*
* Copyright (c) 2012 Miodrag Vallat.
@@ -99,9 +99,6 @@
" addu %r4, %r4, 4 \n" \
" /* envp = argv + argc + 1 */ \n" \
\
- "_dl_exit: \n" \
- " or %r13, %r0, " STR(SYS_exit) " \n" \
- " tb0 0, %r0, 450 \n" \
- " or %r0, %r0, %r0 \n" \
+ "_csu_abort: \n" \
" tb0 0, %r0, 130 /* breakpoint */ \n" \
" .previous");
diff --git a/lib/csu/mips64/boot_md.h b/lib/csu/mips64/boot_md.h
index 09fb17f4d6f..8c2f6ec417a 100644
--- a/lib/csu/mips64/boot_md.h
+++ b/lib/csu/mips64/boot_md.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: boot_md.h,v 1.3 2022/10/27 19:40:23 deraadt Exp $ */
+/* $OpenBSD: boot_md.h,v 1.4 2023/11/18 16:26:16 deraadt Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -40,7 +40,7 @@
#include <machine/reloc.h>
__dead
-void _dl_exit(int);
+void _csu_abort(int);
#include "archdep.h"
diff --git a/lib/csu/mips64/md_init.h b/lib/csu/mips64/md_init.h
index ad4e70af95d..0f5045d4a0b 100644
--- a/lib/csu/mips64/md_init.h
+++ b/lib/csu/mips64/md_init.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: md_init.h,v 1.20 2020/10/20 15:26:59 visa Exp $ */
+/* $OpenBSD: md_init.h,v 1.21 2023/11/18 16:26:16 deraadt Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
@@ -140,14 +140,12 @@
" dla $t9, ___start \n" \
" jr $t9 \n" \
" .end __start \n" \
- " .globl _dl_exit \n" \
- " .ent _dl_exit \n" \
- " .type _dl_exit, @function \n" \
- "_dl_exit: \n" \
- " li $v0, " STR(SYS_exit) " \n" \
- " syscall \n" \
- " teq $zero, $zero, 0x52 \n" \
- " .end _dl_exit \n" \
+ " .globl _csu_abort \n" \
+ " .ent _csu_abort \n" \
+ " .type _csu_abort, @function \n" \
+ "_csu_abort: \n" \
+ " teq zero, zero, 0x52 \n" \
+ " .end _csu_abort \n" \
" .previous")
struct kframe {
diff --git a/lib/csu/powerpc/md_init.h b/lib/csu/powerpc/md_init.h
index fa4a3f514fb..7c206e640b2 100644
--- a/lib/csu/powerpc/md_init.h
+++ b/lib/csu/powerpc/md_init.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: md_init.h,v 1.11 2020/10/15 16:30:23 deraadt Exp $ */
+/* $OpenBSD: md_init.h,v 1.12 2023/11/18 16:26:16 deraadt Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
@@ -119,10 +119,8 @@ __asm( \
" \n" \
" .text \n" \
" .align 2 \n" \
-" .globl _dl_exit \n" \
-" .type _dl_exit, @function \n" \
-"_dl_exit: \n" \
-" li %r0, " STR(SYS_exit) " \n" \
-" sc \n" \
+" .globl _csu_abort \n" \
+" .type _csu_abort, @function \n" \
+"_csu_abort: \n" \
" .long 0 # illegal \n" \
)
diff --git a/lib/csu/powerpc64/md_init.h b/lib/csu/powerpc64/md_init.h
index e2054bd5754..110cc5b2ed6 100644
--- a/lib/csu/powerpc64/md_init.h
+++ b/lib/csu/powerpc64/md_init.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: md_init.h,v 1.4 2020/10/15 16:30:23 deraadt Exp $ */
+/* $OpenBSD: md_init.h,v 1.5 2023/11/18 16:26:16 deraadt Exp $ */
/*
* Copyright (c) 2020 Dale Rahn <drahn@openbsd.org>
@@ -111,10 +111,8 @@ __asm( \
" li %r6, 0 \n" \
" bl ___start \n" \
" \n" \
-" .globl _dl_exit \n" \
-" .type _dl_exit, @function \n" \
-"_dl_exit: \n" \
-" li %r0, " STR(SYS_exit) " \n" \
-" sc \n" \
+" .globl _csu_abort \n" \
+" .type _csu_abort, @function \n" \
+"_csu_abort: \n" \
" .long 0 # illegal \n" \
)
diff --git a/lib/csu/riscv64/md_init.h b/lib/csu/riscv64/md_init.h
index 1f454384c58..62bf4638547 100644
--- a/lib/csu/riscv64/md_init.h
+++ b/lib/csu/riscv64/md_init.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: md_init.h,v 1.3 2021/07/22 18:16:13 kettenis Exp $ */
+/* $OpenBSD: md_init.h,v 1.4 2023/11/18 16:26:16 deraadt Exp $ */
/*
* Copyright (c) 2020 Dale Rahn <drahn@openbsd.org>
*
@@ -107,8 +107,6 @@
" j ___start \n" \
" .size _start, .-_start \n" \
" .size __start, .-__start \n" \
- "_dl_exit: \n" \
- " li t0, " STR(SYS_exit) " \n" \
- " ecall \n" \
+ "_csu_abort: \n" \
" unimp \n" \
".previous");
diff --git a/lib/csu/sh/md_init.h b/lib/csu/sh/md_init.h
index f2940122c4a..b75014616d5 100644
--- a/lib/csu/sh/md_init.h
+++ b/lib/csu/sh/md_init.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: md_init.h,v 1.10 2020/10/15 16:30:23 deraadt Exp $ */
+/* $OpenBSD: md_init.h,v 1.11 2023/11/18 16:26:16 deraadt Exp $ */
/* $NetBSD: dot_init.h,v 1.3 2005/12/24 22:02:10 perry Exp $ */
/*-
@@ -131,10 +131,8 @@ __asm(".section " #section "\n" \
" .long _DYNAMIC - .L_offbase \n" \
\
" .align 2 \n" \
- " .globl _dl_exit \n" \
- " .type _dl_exit,@function \n" \
- "_dl_exit: \n" \
- " mov #" STR(SYS_exit) ", r0 \n" \
- " .word 0xc380 /* trapa #0x80 */ \n" \
+ " .globl _csu_abort \n" \
+ " .type _csu_abort,@function \n" \
+ "_csu_abort: \n" \
" sleep /* illegal */ \n" \
".previous")
diff --git a/lib/csu/sparc64/md_init.h b/lib/csu/sparc64/md_init.h
index 09f0f0cc1ec..7857bacdf23 100644
--- a/lib/csu/sparc64/md_init.h
+++ b/lib/csu/sparc64/md_init.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: md_init.h,v 1.9 2020/10/15 16:30:23 deraadt Exp $ */
+/* $OpenBSD: md_init.h,v 1.10 2023/11/18 16:26:16 deraadt Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
@@ -100,10 +100,8 @@
" ba,pt %icc, ___start \n" \
" clr %o1 \n" \
" \n" \
- " .global _dl_exit \n" \
- "_dl_exit: \n" \
- " mov " STR(SYS_exit) ", %g1 \n" \
- " t 0 \n" \
+ " .global _csu_abort \n" \
+ "_csu_abort: \n" \
" unimp \n" \
" .previous")