summaryrefslogtreecommitdiff
path: root/lib/libc/gen
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-05-29 03:05:15 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-05-29 03:05:15 +0000
commit92383d4847f9886583809f9d430a3411aa6e925c (patch)
tree8dd61408135e5791358ad10abf3336e19c8c52f9 /lib/libc/gen
parent84caeb3aa64af21636ab0464cce327de7bc4cc78 (diff)
enable ELF/a.out/ECOFF in machine/exec.h
Diffstat (limited to 'lib/libc/gen')
-rw-r--r--lib/libc/gen/Makefile.inc7
-rw-r--r--lib/libc/gen/elf_hash.c36
-rw-r--r--lib/libc/gen/elf_sup.c60
-rw-r--r--lib/libc/gen/exec_sup.h68
-rw-r--r--lib/libc/gen/nlist.c47
5 files changed, 68 insertions, 150 deletions
diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc
index fa527cc1402..382515210d7 100644
--- a/lib/libc/gen/Makefile.inc
+++ b/lib/libc/gen/Makefile.inc
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile.inc,v 1.4 1996/05/28 14:11:20 etheisen Exp $
+# $OpenBSD: Makefile.inc,v 1.5 1996/05/29 03:05:11 deraadt Exp $
# $NetBSD: Makefile.inc,v 1.71 1996/04/15 23:44:53 jtc Exp $
# @(#)Makefile.inc 8.3 (Berkeley) 4/16/94
@@ -30,11 +30,6 @@ SRCS+= _err.c _errx.c _sys_errlist.c _sys_nerr.c _sys_siglist.c \
# _setjmp() fabs() frexp() infinity isinf() ldexp() modf()
# setjmp() sigsetjmp()
-# machine dependant ELF ABI v1 libc support
-.if (${MACHINE_ARCH} == "i386") || (${MACHINE_ARCH} == "mips")
-SRCS+= elf_sup.c
-.endif
-
.include "${.CURDIR}/arch/${MACHINE_ARCH}/gen/Makefile.inc"
.ifdef _NOTDEF_XXX_
diff --git a/lib/libc/gen/elf_hash.c b/lib/libc/gen/elf_hash.c
index 3ed039f5d00..a5655f7ebf8 100644
--- a/lib/libc/gen/elf_hash.c
+++ b/lib/libc/gen/elf_hash.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: elf_hash.c,v 1.1 1996/05/28 14:11:20 etheisen Exp $ */
+/* $OpenBSD: elf_hash.c,v 1.2 1996/05/29 03:05:12 deraadt Exp $ */
/*
* Copyright (c) 1995, 1996 Erik Theisen
* All rights reserved.
@@ -25,6 +25,19 @@
* (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/types.h>
+#include <sys/param.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/file.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/exec.h>
+
#include <elf_abi.h>
/*
@@ -34,16 +47,15 @@
*/
unsigned long
elf_hash(name)
- const unsigned char *name;
+ const unsigned char *name;
{
- register unsigned long h = 0, g;
+ register unsigned long h = 0, g;
- while(*name)
- {
- h = (h << 4) + *name++;
- if (g = h & 0xf0000000)
- h ^= g >> 24;
- h &= ~g;
- }
- return h;
-} /* end elf_hash() */
+ while (*name) {
+ h = (h << 4) + *name++;
+ if (g = h & 0xf0000000)
+ h ^= g >> 24;
+ h &= ~g;
+ }
+ return h;
+}
diff --git a/lib/libc/gen/elf_sup.c b/lib/libc/gen/elf_sup.c
deleted file mode 100644
index 38bdce85ba5..00000000000
--- a/lib/libc/gen/elf_sup.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/* $OpenBSD: elf_sup.c,v 1.2 1996/05/28 14:11:21 etheisen Exp $ */
-/*
- * Copyright (c) 1995, 1996 Erik Theisen
- * All rights reserved.
- *
- * 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. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission
- *
- * 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 "exec_sup.h"
-
-/*
- * __elf_is_okay__ - Determine if ehdr really
- * is ELF and valid for the target platform.
- *
- * WARNING: This is NOT a ELF ABI function and
- * as such it's use should be restricted.
- */
-int
-__elf_is_okay__(ehdr)
- register Elf32_Ehdr *ehdr;
-{
- register int retval = 0;
-
- /*
- * We need to check magic, class size, endianess,
- * and version before we look at the rest of the
- * Elf32_Ehdr structure. These few elements are
- * represented in a machine independant fashion.
- */
- if(IS_ELF(*ehdr) &&
- ehdr->e_ident[EI_CLASS] == ELF_TARG_CLASS &&
- ehdr->e_ident[EI_DATA] == ELF_TARG_DATA &&
- ehdr->e_ident[EI_VERSION] == ELF_TARG_VER) {
-
- /* Now check the machine dependant header */
- if(ehdr->e_machine == ELF_TARG_MACH &&
- ehdr->e_version == ELF_TARG_VER)
- retval = 1;
- }
- return retval;
-} /* end __elf_is_okay__() */
diff --git a/lib/libc/gen/exec_sup.h b/lib/libc/gen/exec_sup.h
deleted file mode 100644
index f46ca9e0b11..00000000000
--- a/lib/libc/gen/exec_sup.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* $OpenBSD: exec_sup.h,v 1.1 1996/05/28 14:11:21 etheisen Exp $ */
-/*
- * Copyright (c) 1995, 1996 Erik Theisen
- * All rights reserved.
- *
- * 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. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission
- *
- * 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.
- */
-
-#ifndef _EXEC_SUP_H_
-#define _EXEC_SUP_H_
-
-#define DO_AOUT /* Always do a.out */
-
-#if defined (__i386__) || defined (__mips__)
-#define DO_ELF
-#define ELF_TARG_VER 1 /* The ver for which this code is intended */
-#include <elf_abi.h>
-int __elf_is_okay__ (Elf32_Ehdr *ehdr); /* XXX - should this be hidden??? */
-#endif /* ELF machines */
-
-#if defined (__i386__)
- #define ELF_TARG_CLASS ELFCLASS32
- #define ELF_TARG_DATA ELFDATA2LSB
- #define ELF_TARG_MACH EM_386
-
-#elif defined (__mips__)
- #define ELF_TARG_CLASS ELFCLASS32
- #define ELF_TARG_DATA ELFDATA2LSB
- #define ELF_TARG_MACH EM_MIPS
-
-#elif defined (__alpha__)
- #define DO_ECOFF
-
-#elif defined (pica)
- #define DO_ECOFF
-
-#endif /* Machines */
-
-#ifdef DO_AOUT
-#include <sys/types.h>
-#include <a.out.h>
-#endif
-
-#ifdef DO_ECOFF
-#include <sys/exec_ecoff.h>
-#endif
-
-#endif /* _EXEC_SUP_H_ */
diff --git a/lib/libc/gen/nlist.c b/lib/libc/gen/nlist.c
index 1f5458189a0..cf0b63e3398 100644
--- a/lib/libc/gen/nlist.c
+++ b/lib/libc/gen/nlist.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nlist.c,v 1.8 1996/05/28 14:11:21 etheisen Exp $ */
+/* $OpenBSD: nlist.c,v 1.9 1996/05/29 03:05:14 deraadt Exp $ */
/* $NetBSD: nlist.c,v 1.7 1996/05/16 20:49:20 cgd Exp $ */
/*
@@ -35,11 +35,10 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: nlist.c,v 1.8 1996/05/28 14:11:21 etheisen Exp $";
+static char rcsid[] = "$OpenBSD: nlist.c,v 1.9 1996/05/29 03:05:14 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
-#include "exec_sup.h" /* determine targ OMFs for a given machine */
-
+#include <sys/types.h>
#include <sys/param.h>
#include <sys/mman.h>
#include <sys/stat.h>
@@ -49,6 +48,15 @@ static char rcsid[] = "$OpenBSD: nlist.c,v 1.8 1996/05/28 14:11:21 etheisen Exp
#include <stdio.h>
#include <string.h>
#include <unistd.h>
+#include <a.out.h> /* pulls in nlist.h */
+
+#ifdef DO_ELF
+#include <elf_abi.h>
+#endif
+
+#ifdef DO_ECOFF
+#include <sys/exec_ecoff.h>
+#endif
#define ISLAST(p) (p->n_un.n_name == 0 || p->n_un.n_name[0] == 0)
@@ -243,6 +251,37 @@ out:
#endif /* DO_ECOFF */
#ifdef DO_ELF
+/*
+ * __elf_is_okay__ - Determine if ehdr really
+ * is ELF and valid for the target platform.
+ *
+ * WARNING: This is NOT a ELF ABI function and
+ * as such it's use should be restricted.
+ */
+int
+__elf_is_okay__(ehdr)
+ register Elf32_Ehdr *ehdr;
+{
+ register int retval = 0;
+ /*
+ * We need to check magic, class size, endianess,
+ * and version before we look at the rest of the
+ * Elf32_Ehdr structure. These few elements are
+ * represented in a machine independant fashion.
+ */
+ if (IS_ELF(*ehdr) &&
+ ehdr->e_ident[EI_CLASS] == ELF_TARG_CLASS &&
+ ehdr->e_ident[EI_DATA] == ELF_TARG_DATA &&
+ ehdr->e_ident[EI_VERSION] == ELF_TARG_VER) {
+
+ /* Now check the machine dependant header */
+ if (ehdr->e_machine == ELF_TARG_MACH &&
+ ehdr->e_version == ELF_TARG_VER)
+ retval = 1;
+ }
+ return retval;
+}
+
int
__elf_fdnlist(fd, list)
register int fd;