summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authormickey <mickey@openbsd.org>1998-07-14 15:21:43 +0000
committermickey <mickey@openbsd.org>1998-07-14 15:21:43 +0000
commitae0359c4c36d62bbbb1b70a6c226af731092d2e2 (patch)
tree101287d18a589c9a2aa2b9f9c37487763062dd9c /sys
parentsome ecoff support; untested, but compiles (diff)
downloadwireguard-openbsd-ae0359c4c36d62bbbb1b70a6c226af731092d2e2.tar.xz
wireguard-openbsd-ae0359c4c36d62bbbb1b70a6c226af731092d2e2.zip
HP object file formats
Diffstat (limited to 'sys')
-rw-r--r--sys/lib/libsa/exec_som.c78
-rw-r--r--sys/sys/exec_som.h129
2 files changed, 207 insertions, 0 deletions
diff --git a/sys/lib/libsa/exec_som.c b/sys/lib/libsa/exec_som.c
new file mode 100644
index 00000000000..5885c3f57c8
--- /dev/null
+++ b/sys/lib/libsa/exec_som.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright 1996 1995 by Open Software Foundation, Inc.
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appears in all copies and
+ * that both the copyright notice and this permission notice appear in
+ * supporting documentation.
+ *
+ * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
+ * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/exec_som.h>
+
+int
+som_recog(struct file *fp, objfmt_t ofmt, void *hdr)
+{
+ struct header *filehdr = *(struct header **)hdr;
+
+ return (filehdr->system_id == CPU_PA_RISC1_0 ||
+ filehdr->system_id == CPU_PA_RISC1_1);
+}
+
+int
+som_load(struct file *fp, objfmt_t ofmt, void *hdr)
+{
+ struct loader_info *lp = &ofmt->info;
+ struct header filehdr;
+ struct som_exec_auxhdr x;
+ register int result;
+
+ /*
+ * first read in the hp file header, there is a pointer to the "exec"
+ * structure in the header.
+ */
+
+ result = read_file(fp, 0, (vm_offset_t)&filehdr, sizeof(filehdr));
+ if (result)
+ return (result);
+
+ /*
+ * now read in the hp800 equivalent of an exec structure
+ */
+
+ result = read_file(fp, (vm_offset_t)filehdr.aux_header_location,
+ (vm_offset_t)&x, sizeof(x));
+ if (result)
+ return (result);
+
+ lp->text_start = x.exec_tmem;
+ lp->text_size = round_page(x.exec_tsize);
+ lp->text_offset = x.exec_tfile;
+ lp->data_start = x.exec_dmem;
+ lp->data_size = round_page(x.exec_dsize);
+ lp->data_offset = x.exec_dfile;
+ lp->bss_size = x.exec_bsize;
+
+ lp->entry_1 = x.exec_flags;
+ lp->entry_2 = filehdr.presumed_dp;
+
+ lp->sym_offset[0] = 0;
+ lp->sym_size[0] = 0;
+
+ lp->str_offset = 0;
+ lp->str_size = 0;
+
+ return 0;
+}
+
diff --git a/sys/sys/exec_som.h b/sys/sys/exec_som.h
new file mode 100644
index 00000000000..49bae609df8
--- /dev/null
+++ b/sys/sys/exec_som.h
@@ -0,0 +1,129 @@
+/* $OpenBSD: exec_som.h,v 1.1 1998/07/14 15:23:21 mickey Exp $ */
+
+/*
+ * (c) Copyright 1991 HEWLETT-PACKARD COMPANY
+ *
+ * To anyone who acknowledges that this file is provided "AS IS"
+ * without any express or implied warranty:
+ * permission to use, copy, modify, and distribute this file
+ * for any purpose is hereby granted without fee, provided that
+ * the above copyright notice and this notice appears in all
+ * copies, and that the name of Hewlett-Packard Company not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific, written prior permission.
+ * Hewlett-Packard Company makes no representations about the
+ * suitability of this software for any purpose.
+ */
+
+/*
+ * Copyright (c) 1990,1994 The University of Utah and
+ * the Computer Systems Laboratory (CSL). All rights reserved.
+ *
+ * THE UNIVERSITY OF UTAH AND CSL PROVIDE THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION, AND DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM ITS USE.
+ *
+ * CSL requests users of this software to return to csl-dist@cs.utah.edu any
+ * improvements that they make and grant CSL redistribution rights.
+ *
+ * Utah $Hdr: som.h 1.2 94/12/14$
+ */
+
+/*
+ * HP object formats
+ */
+
+#ifndef _EXEC_SOM_H_
+#define _EXEC_SOM_H_
+
+struct aux_id {
+ u_int mandatory : 1;
+ u_int copy : 1;
+ u_int append : 1;
+ u_int ignore : 1;
+ u_int reserved : 12;
+ u_int type : 16;
+ u_int length;
+};
+
+struct som_exec_auxhdr {
+ struct aux_id som_auxhdr; /* som auxiliary header header */
+ long exec_tsize; /* text size in bytes */
+ long exec_tmem; /* offset of text in memory */
+ long exec_tfile; /* location of text in file */
+ long exec_dsize; /* initialized data */
+ long exec_dmem; /* offset of data in memory */
+ long exec_dfile; /* location of data in file */
+ long exec_bsize; /* uninitialized data (bss) */
+ long exec_entry; /* offset of entrypoint */
+ long exec_flags; /* loader flags */
+ long exec_bfill; /* bss initialization value */
+};
+
+struct sys_clock {
+ u_int secs;
+ u_int nanosecs;
+};
+
+/*
+ * system_id values
+ */
+
+#define MID_HP800 800 /* hp800 BSD binary */
+#define MID_HPUX 0x20b /* HP-UX or OSF SOM binary */
+
+/*
+ * a_magic values
+ */
+
+#define EXEC_MAGIC 0x0107 /* normal executable */
+#define SHARE_MAGIC 0x0108 /* shared executable */
+#define DEMAND_MAGIC 0x010B /* demand-load executable */
+
+
+struct header {
+ short int system_id; /* magic number - system */
+ short int a_magic; /* magic number - file type */
+ u_int version_id; /* version id; format= YYMMDDHH */
+ struct sys_clock file_time; /* system clock- zero if unused */
+ u_int entry_space; /* idx of space containing entry pt */
+ u_int entry_subspace; /* idx of subspace for entry point */
+ u_int entry_offset; /* offset of entry point */
+ u_int aux_header_location; /* auxiliary header location */
+ u_int aux_header_size; /* auxiliary header size */
+ u_int som_length; /* length in bytes of entire som*/
+ u_int presumed_dp; /* DP val assumed during compilation */
+ u_int space_location; /* loc in file of space dictionary */
+ u_int space_total; /* number of space entries */
+ u_int subspace_location; /* location of subspace entries */
+ u_int subspace_total; /* number of subspace entries */
+ u_int loader_fixup_location; /* space reference array */
+ u_int loader_fixup_total; /* total number of space ref recs */
+ u_int space_strings_location; /* file location of string area
+ for space and subspace names */
+ u_int space_strings_size; /* size of string area for space
+ and subspace names */
+ u_int init_array_location; /* location in file of init pointers */
+ u_int init_array_total; /* number of init. pointers */
+ u_int compiler_location; /* loc in file of module dictionary*/
+ u_int compiler_total; /* number of modules */
+ u_int symbol_location; /* loc in file of symbol dictionary*/
+ u_int symbol_total; /* number of symbol records */
+ u_int fixup_request_location; /* loc in file of fix_up requests */
+ u_int fixup_request_total; /* number of fixup requests */
+ u_int symbol_strings_location; /* file location of string area
+ for module and symbol names */
+ u_int symbol_strings_size; /* size of string area for
+ module and symbol names */
+ u_int unloadable_sp_location; /* byte offset of first byte of
+ data for unloadable spaces */
+ u_int unloadable_sp_size; /* bytes of data for unloadable spaces*/
+ u_int checksum;
+};
+
+typedef struct {
+ struct header fhdr;
+ struct som_exec_auxhdr ehdr;
+} som_exec;
+
+#endif /* _EXEC_SOM_H_