summaryrefslogtreecommitdiff
path: root/libexec/ld.so/amd64
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2017-01-24 07:48:38 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2017-01-24 07:48:38 +0000
commitc66416e633310f06dfbeaa655d3e2826d4c42dc6 (patch)
tree871022ef5bc45fdadb9027dd35c237840f023803 /libexec/ld.so/amd64
parenta25395adead1f5541203d945e1c673202a0c6395 (diff)
On fatal errors, kill ourselves with thrkill(0,9,NULL) instead of
simply exiting, via helper functions _dl_die(), _dl_diedie(), and _dl_oom(). prompted by a complaint from jsing@ ok jsing@ deraadt@
Diffstat (limited to 'libexec/ld.so/amd64')
-rw-r--r--libexec/ld.so/amd64/ldasm.S3
-rw-r--r--libexec/ld.so/amd64/rtld_machine.c26
-rw-r--r--libexec/ld.so/amd64/syscall.h4
3 files changed, 14 insertions, 19 deletions
diff --git a/libexec/ld.so/amd64/ldasm.S b/libexec/ld.so/amd64/ldasm.S
index 76a1945733e..3407f0b0472 100644
--- a/libexec/ld.so/amd64/ldasm.S
+++ b/libexec/ld.so/amd64/ldasm.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldasm.S,v 1.25 2016/08/28 06:15:32 guenther Exp $ */
+/* $OpenBSD: ldasm.S,v 1.26 2017/01/24 07:48:37 guenther Exp $ */
/*
* Copyright (c) 2002,2004 Dale Rahn
@@ -101,6 +101,7 @@ DL_SYSCALL2(getcwd,__getcwd)
DL_SYSCALL2(set_tcb,__set_tcb)
DL_SYSCALL2(_syscall,__syscall)
DL_SYSCALL(sysctl)
+DL_SYSCALL(thrkill)
1:
/* error: result = -errno; - handled here. */
diff --git a/libexec/ld.so/amd64/rtld_machine.c b/libexec/ld.so/amd64/rtld_machine.c
index 14de6c96ce9..7e6c65ed80b 100644
--- a/libexec/ld.so/amd64/rtld_machine.c
+++ b/libexec/ld.so/amd64/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.27 2017/01/23 10:30:58 guenther Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.28 2017/01/24 07:48:37 guenther Exp $ */
/*
* Copyright (c) 2002,2004 Dale Rahn
@@ -188,10 +188,8 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
if (rels == NULL)
return(0);
- if (relrel > numrel) {
- _dl_printf("relacount > numrel: %ld > %ld\n", relrel, numrel);
- _dl_exit(20);
- }
+ if (relrel > numrel)
+ _dl_die("relacount > numrel: %ld > %ld", relrel, numrel);
/*
* unprotect some segments if we need it.
@@ -209,10 +207,8 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
Elf_Addr *where;
#ifdef DEBUG
- if (ELF_R_TYPE(rels->r_info) != R_TYPE(RELATIVE)) {
- _dl_printf("RELACOUNT wrong\n");
- _dl_exit(20);
- }
+ if (ELF_R_TYPE(rels->r_info) != R_TYPE(RELATIVE))
+ _dl_die("RELACOUNT wrong");
#endif
where = (Elf_Addr *)(rels->r_offset + loff);
*where = rels->r_addend + loff;
@@ -225,10 +221,8 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
type = ELF_R_TYPE(rels->r_info);
- if (RELOC_ERROR(type)) {
- _dl_printf("relocation error %d idx %ld\n", type, i);
- _dl_exit(20);
- }
+ if (RELOC_ERROR(type))
+ _dl_die("relocation error %d idx %ld", type, i);
if (type == R_TYPE(NONE))
continue;
@@ -362,10 +356,8 @@ _dl_bind(elf_object_t *object, int index)
this = NULL;
ooff = _dl_find_symbol(symn, &this,
SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym, object, &sobj);
- if (this == NULL) {
- _dl_printf("lazy binding failed!\n");
- *(volatile int *)0 = 0; /* XXX */
- }
+ if (this == NULL)
+ _dl_die("lazy binding failed!");
buf.newval = ooff + this->st_value + rel->r_addend;
diff --git a/libexec/ld.so/amd64/syscall.h b/libexec/ld.so/amd64/syscall.h
index 0af7eefea86..4f992e0a031 100644
--- a/libexec/ld.so/amd64/syscall.h
+++ b/libexec/ld.so/amd64/syscall.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: syscall.h,v 1.24 2017/01/21 01:15:00 guenther Exp $ */
+/* $OpenBSD: syscall.h,v 1.25 2017/01/24 07:48:37 guenther Exp $ */
/*
* Copyright (c) 2001 Niklas Hallqvist
@@ -58,6 +58,8 @@ int _dl_utrace(const char *, const void *, size_t);
int _dl_getentropy(char *, size_t);
int _dl_sendsyslog(const char *, size_t, int);
void _dl_set_tcb(void *);
+__dead
+void _dl_thrkill(pid_t, int, void *);
static inline void *
_dl_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset)