diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2017-08-27 21:59:53 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2017-08-27 21:59:53 +0000 |
commit | 7f5398b1f45a6105b16eeb5672676e0ada0e6d37 (patch) | |
tree | 7ed36e3384bee80b519d279b09da113e8d23a450 /libexec/ld.so/sh | |
parent | 1f33e8fe5544ebb65e81ef2b4c9a5924e3e5a7f2 (diff) |
Replace heaps of hand-written syscall stubs with a simpler framework
which is largely MI.
ok visa kettenis
Diffstat (limited to 'libexec/ld.so/sh')
-rw-r--r-- | libexec/ld.so/sh/Makefile.inc | 4 | ||||
-rw-r--r-- | libexec/ld.so/sh/SYS.h | 54 | ||||
-rw-r--r-- | libexec/ld.so/sh/ldasm.S | 69 | ||||
-rw-r--r-- | libexec/ld.so/sh/syscall.h | 8 |
4 files changed, 60 insertions, 75 deletions
diff --git a/libexec/ld.so/sh/Makefile.inc b/libexec/ld.so/sh/Makefile.inc index 9f63b862d5b..2eae76fc6da 100644 --- a/libexec/ld.so/sh/Makefile.inc +++ b/libexec/ld.so/sh/Makefile.inc @@ -1,8 +1,6 @@ -# $OpenBSD: Makefile.inc,v 1.6 2016/08/15 03:09:02 guenther Exp $ +# $OpenBSD: Makefile.inc,v 1.7 2017/08/27 21:59:52 deraadt Exp $ CFLAGS += -fpic CFLAGS+=-m4-nofpu AFLAGS += -D_STANDALONE -CPPFLAGS += -I${.CURDIR}/../../lib/libc/arch/sh -LIBCSRCDIR=${.CURDIR}/../../lib/libc LDADD= `$(CC) -print-libgcc-file-name` diff --git a/libexec/ld.so/sh/SYS.h b/libexec/ld.so/sh/SYS.h new file mode 100644 index 00000000000..12aecd690f2 --- /dev/null +++ b/libexec/ld.so/sh/SYS.h @@ -0,0 +1,54 @@ +/* $OpenBSD: SYS.h,v 1.1 2017/08/27 21:59:52 deraadt Exp $ */ + +/* + * Copyright (c) 2006 Dale Rahn + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include <machine/asm.h> +#include <sys/syscall.h> + +#define SYSTRAP(x) \ + mov.l 903f, r0; \ + .word 0xc380; /* trapa #0x80; */ \ + bra 904f; \ + nop; \ + .align 2; \ + 903: .long (SYS_ ## x); \ + 904: + +#define DL_SYSCALL(n) \ + .global __CONCAT(_dl_,n) ;\ + .type __CONCAT(_dl_,n)%function ;\ +__CONCAT(_dl_,n): ;\ + SYSTRAP(n) ;\ + bf .L_cerr ;\ + nop ;\ + rts ;\ + nop + +.L_cerr: + neg r0, r0 + rts + nop diff --git a/libexec/ld.so/sh/ldasm.S b/libexec/ld.so/sh/ldasm.S index 13916795ec9..1900fbda227 100644 --- a/libexec/ld.so/sh/ldasm.S +++ b/libexec/ld.so/sh/ldasm.S @@ -1,4 +1,4 @@ -/* $OpenBSD: ldasm.S,v 1.28 2017/01/24 07:48:37 guenther Exp $ */ +/* $OpenBSD: ldasm.S,v 1.29 2017/08/27 21:59:52 deraadt Exp $ */ /* * Copyright (c) 2006 Dale Rahn @@ -29,7 +29,6 @@ #define DL_DATA_SIZE (16 * 4) /* XXX */ #include <machine/asm.h> #include <sys/syscall.h> -#include <SYS.h> ENTRY(_dl_start) mov r15, r12 // save for later @@ -131,69 +130,3 @@ ENTRY(_dl_bind_start) .L_dl_bind: .long _dl_bind-.L_call_dl_bind .size _dl_bind_start, .-dl_bind_start - - - /* STUB */ - - -/* ld.so SYSCALLS */ - -#define DL_SYSCALL(n) DL_SYSCALL2(n,n) -#define DL_SYSCALL2(n,c) \ - .global __CONCAT(_dl_,n) ;\ - .type __CONCAT(_dl_,n)%function ;\ -__CONCAT(_dl_,n): ;\ - SYSTRAP(c) ;\ - bf .L_cerr ;\ - nop ;\ - rts ;\ - nop - -#define DL_SYSCALL_NOERR(n) DL_SYSCALL2_NOERR(n,n) -#define DL_SYSCALL2_NOERR(n,c) \ - .global __CONCAT(_dl_,n) ;\ - .type __CONCAT(_dl_,n)%function ;\ -__CONCAT(_dl_,n): ;\ - SYSTRAP(c) ;\ - rts ;\ - nop - - - .section ".text" - .align 4 -DL_SYSCALL(close) - - - .global _dl_exit - .type _dl_exit%function -_dl_exit: - SYSTRAP(exit) -1: - bra 1b - nop - -DL_SYSCALL_NOERR(issetugid) -DL_SYSCALL_NOERR(getthrid) -DL_SYSCALL(thrkill) -DL_SYSCALL2(_syscall,__syscall) -DL_SYSCALL(munmap) -DL_SYSCALL(mprotect) -DL_SYSCALL(open) -DL_SYSCALL(read) - -.L_cerr: - neg r0, r0 - rts - nop - -DL_SYSCALL(write) -DL_SYSCALL(fstat) -DL_SYSCALL(readlink) -DL_SYSCALL(utrace) -DL_SYSCALL(getentropy) -DL_SYSCALL(sendsyslog) -DL_SYSCALL(pledge) -DL_SYSCALL2(getcwd,__getcwd) -DL_SYSCALL(sysctl) -DL_SYSCALL(getdents) - diff --git a/libexec/ld.so/sh/syscall.h b/libexec/ld.so/sh/syscall.h index 58b5b3d9de1..79ff012f0a8 100644 --- a/libexec/ld.so/sh/syscall.h +++ b/libexec/ld.so/sh/syscall.h @@ -1,4 +1,4 @@ -/* $OpenBSD: syscall.h,v 1.24 2017/01/24 07:48:37 guenther Exp $ */ +/* $OpenBSD: syscall.h,v 1.25 2017/08/27 21:59:52 deraadt Exp $ */ /* * Copyright (c) 2001 Niklas Hallqvist @@ -43,7 +43,7 @@ __dead void _dl_exit(int); int _dl_issetugid(void); int _dl_getthrid(void); -long _dl__syscall(quad_t, ...); +long _dl___syscall(quad_t, ...); int _dl_mprotect(const void *, size_t, int); int _dl_munmap(const void *, size_t); int _dl_open(const char *, int); @@ -53,7 +53,7 @@ ssize_t _dl_getdents(int, char *, size_t); int _dl_sysctl(const int *, u_int, void *, size_t *, void *, size_t); ssize_t _dl_readlink(const char *, char *, size_t); int _dl_pledge(const char *, const char **); -int _dl_getcwd(char *, size_t); +int _dl___getcwd(char *, size_t); int _dl_utrace(const char *, const void *, size_t); int _dl_getentropy(char *, size_t); int _dl_sendsyslog(const char *, size_t, int); @@ -63,7 +63,7 @@ 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) { - return (void *)_dl__syscall(SYS_mmap, addr, len, prot, + return (void *)_dl___syscall(SYS_mmap, addr, len, prot, flags, fd, 0, offset); } |