Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/irix Added code to match IRIX N32 binaries
details: https://anonhg.NetBSD.org/src/rev/28b46f05690f
branches: trunk
changeset: 518245:28b46f05690f
user: manu <manu%NetBSD.org@localhost>
date: Mon Nov 26 21:36:24 2001 +0000
description:
Added code to match IRIX N32 binaries
diffstat:
sys/compat/irix/files.irix | 3 +-
sys/compat/irix/irix_exec.c | 119 ++++++++++++++++++++++++++++++++++--
sys/compat/irix/irix_exec.h | 29 ++++++++-
sys/compat/irix/irix_exec_elf32.c | 65 ++++++++++++++++++++
sys/compat/irix/irix_syscall.h | 17 ++++-
sys/compat/irix/irix_syscallargs.h | 7 +-
sys/compat/irix/irix_syscalls.c | 14 ++--
sys/compat/irix/irix_sysent.c | 20 +++---
sys/compat/irix/syscalls.master | 12 +-
9 files changed, 251 insertions(+), 35 deletions(-)
diffs (truncated from 447 to 300 lines):
diff -r 01e4c46f6bda -r 28b46f05690f sys/compat/irix/files.irix
--- a/sys/compat/irix/files.irix Mon Nov 26 21:20:35 2001 +0000
+++ b/sys/compat/irix/files.irix Mon Nov 26 21:36:24 2001 +0000
@@ -1,4 +1,5 @@
-# $NetBSD: files.irix,v 1.1 2001/09/22 18:51:35 manu Exp $
+# $NetBSD: files.irix,v 1.2 2001/11/26 21:36:24 manu Exp $
#
file compat/irix/irix_exec.c compat_irix
+file compat/irix/irix_exec_elf32.c compat_irix & exec_elf32
diff -r 01e4c46f6bda -r 28b46f05690f sys/compat/irix/irix_exec.c
--- a/sys/compat/irix/irix_exec.c Mon Nov 26 21:20:35 2001 +0000
+++ b/sys/compat/irix/irix_exec.c Mon Nov 26 21:36:24 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: irix_exec.c,v 1.2 2001/11/13 02:08:31 lukem Exp $ */
+/* $NetBSD: irix_exec.c,v 1.3 2001/11/26 21:36:24 manu Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -17,8 +17,8 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
@@ -37,25 +37,36 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: irix_exec.c,v 1.2 2001/11/13 02:08:31 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irix_exec.c,v 1.3 2001/11/26 21:36:24 manu Exp $");
+
+#ifndef ELFSIZE
+#define ELFSIZE 32 /* XXX should die */
+#endif
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/exec.h>
+#include <sys/exec_elf.h>
#include <sys/malloc.h>
#include <sys/syscall.h>
+#include <compat/common/compat_util.h>
+
#include <compat/irix/irix_types.h>
#include <compat/irix/irix_exec.h>
+static int ELFNAME2(irix,mipsopt_signature) __P((struct proc *,
+ struct exec_package *epp, Elf_Ehdr *eh));
+
extern char sigcode[], esigcode[];
extern struct sysent sysent[];
+
#ifndef __HAVE_SYSCALL_INTERN
void syscall __P((void));
#else
-void irix_syscall_intern __P((struct proc *));
+void syscall_intern __P((struct proc *));
#endif
const struct emul emul_irix = {
@@ -77,17 +88,111 @@
trapsignal,
sigcode,
esigcode,
+ setregs,
NULL,
NULL,
NULL,
#ifdef __HAVE_SYSCALL_INTERN
- irix_syscall_intern,
+ syscall_intern,
#else
syscall,
#endif
};
+static int
+ELFNAME2(irix,mipsopt_signature)(p, epp, eh)
+ struct proc *p;
+ struct exec_package *epp;
+ Elf_Ehdr *eh;
+{
+ size_t shsize;
+ int strndx;
+ size_t i;
+ static const char signature[] = ".MIPS.options";
+ char* strtable;
+ Elf_Shdr *sh;
+
+ int error;
+
+ /*
+ * load the section header table
+ */
+ shsize = eh->e_shnum * sizeof(Elf_Shdr);
+ sh = (Elf_Shdr *) malloc(shsize, M_TEMP, M_WAITOK);
+ error = exec_read_from(p, epp->ep_vp, eh->e_shoff, sh, shsize);
+ if (error)
+ goto out;
+
+ /*
+ * Now let's find the string table. If it does not exists, give up.
+ */
+ strndx = (int)(eh->e_shstrndx);
+ if (strndx == SHN_UNDEF) {
+ error = ENOEXEC;
+ goto out;
+ }
+
+ /*
+ * strndx is the index in section header table of the string table
+ * section get the whole string table in strtable, and then we
+ * get access to the names
+ * s->sh_name is the offset of the section name in strtable.
+ */
+ strtable = malloc(sh[strndx].sh_size, M_TEMP, M_WAITOK);
+ error = exec_read_from(p, epp->ep_vp, sh[strndx].sh_offset, strtable,
+ sh[strndx].sh_size);
+ if (error)
+ goto out;
+
+ for (i = 0; i < eh->e_shnum; i++) {
+ Elf_Shdr *s = &sh[i];
+ if (!memcmp((void*)(&(strtable[s->sh_name])), signature,
+ sizeof(signature))) {
+#ifdef DEBUG_IRIX
+ printf("irix_mipsopt_sig=%s\n",&(strtable[s->sh_name]));
+#endif
+ error = 0;
+ goto out;
+ }
+ }
+ error = ENOEXEC;
+
+out:
+ free(sh, M_TEMP);
+ free(strtable, M_TEMP);
+ return (error);
+}
+
+
int
-exec_irix_probe(char **path) {
+ELFNAME2(irix,probe)(p, epp, eh, itp, pos)
+ struct proc *p;
+ struct exec_package *epp;
+ void *eh;
+ char *itp;
+ vaddr_t *pos;
+{
+ const char *bp;
+ int error;
+ size_t len;
+
+#ifdef DEBUG_IRIX
+ printf("irix_probe()\n");
+#endif
+ if ((error = ELFNAME2(irix,mipsopt_signature)(p, epp, eh)) != 0)
+ return error;
+
+ if (itp[0]) {
+ if ((error = emul_find(p, NULL, epp->ep_esch->es_emul->e_path,
+ itp, &bp, 0)))
+ return error;
+ if ((error = copystr(bp, itp, MAXPATHLEN, &len)))
+ return error;
+ free((void *)bp, M_TEMP);
+ }
+ *pos = ELF_NO_ADDR;
+#ifdef DEBUG_IRIX
+ printf("irix_probe: returning 0\n");
+#endif
return 0;
}
diff -r 01e4c46f6bda -r 28b46f05690f sys/compat/irix/irix_exec.h
--- a/sys/compat/irix/irix_exec.h Mon Nov 26 21:20:35 2001 +0000
+++ b/sys/compat/irix/irix_exec.h Mon Nov 26 21:36:24 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: irix_exec.h,v 1.1 2001/09/22 18:51:36 manu Exp $ */
+/* $NetBSD: irix_exec.h,v 1.2 2001/11/26 21:36:24 manu Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -39,7 +39,32 @@
#ifndef _IRIX_EXEC_H_
#define _IRIX_EXEC_H_
-int exec_irix_probe __P((char **));
+#include <sys/types.h>
+#include <sys/exec.h>
+#include <sys/exec_elf.h>
+
+#ifdef EXEC_ELF32
+#define IRIX_AUX_ARGSIZ howmany(ELF_AUX_ENTRIES * sizeof(Aux32Info), \
+ sizeof (Elf32_Addr))
+
+int irix_elf32_copyargs __P((struct exec_package *, struct ps_strings *,
+ char **, void *));
+
+int irix_elf32_probe __P((struct proc *, struct exec_package *, void *,
+ char *, vaddr_t *));
+#endif
+
+#ifdef EXEC_ELF64
+#define IRIX_AUX_ARGSIZ howmany(ELF_AUX_ENTRIES * sizeof(Aux64Info), \
+ sizeof (Elf64_Addr))
+
+int irix_elf64_copyargs __P((struct exec_package *, struct ps_strings *,
+ char **, void *));
+
+int irix_elf64_probe __P((struct proc *, struct exec_package *, void *,
+ char *, vaddr_t *));
+#endif
+
extern const struct emul emul_irix;
#endif /* !_IRIX_EXEC_H_ */
diff -r 01e4c46f6bda -r 28b46f05690f sys/compat/irix/irix_exec_elf32.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/irix/irix_exec_elf32.c Mon Nov 26 21:36:24 2001 +0000
@@ -0,0 +1,65 @@
+/* $NetBSD: irix_exec_elf32.c,v 1.1 2001/11/26 21:36:24 manu Exp $ */
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Emmanuel Dreyfus.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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 <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: irix_exec_elf32.c,v 1.1 2001/11/26 21:36:24 manu Exp $");
+
+#ifndef ELFSIZE
+#define ELFSIZE 32 /* XXX should die */
+#endif
+
+#include <sys/types.h>
+#include <sys/exec.h>
+#include <sys/exec_elf.h>
+
+#include <compat/irix/irix_exec.h>
+
+int
+ELFNAME2(irix,copyargs)(pack, arginfo, stackp, argp)
+ struct exec_package *pack;
+ struct ps_strings *arginfo;
+ char **stackp;
+ void *argp;
+{
+ /* Align the stack frame on a 16 bytes boundary */
+ *stackp = (char *)(((unsigned long)*stackp) & ~0xfUL);
+
+ return ELFNAME(copyargs)(pack, arginfo, stackp, argp);
+
+ *stackp = (char *)((unsigned long)*stackp - 16);
+}
diff -r 01e4c46f6bda -r 28b46f05690f sys/compat/irix/irix_syscall.h
--- a/sys/compat/irix/irix_syscall.h Mon Nov 26 21:20:35 2001 +0000
+++ b/sys/compat/irix/irix_syscall.h Mon Nov 26 21:36:24 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: irix_syscall.h,v 1.2 2001/11/13 02:08:31 lukem Exp $ */
Home |
Main Index |
Thread Index |
Old Index