summaryrefslogtreecommitdiff
path: root/sys/arch/amd64
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2011-07-04 00:59:27 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2011-07-04 00:59:27 +0000
commit28cbd449868bde401f307ef8646abd60c069eb40 (patch)
tree8e9a80391a2770ce97a456d37b9e781ac8c83f71 /sys/arch/amd64
parentb0765659789c108c196da4bc37f369ac1d423bcd (diff)
Let custom nlist.c check ELF, but use the i386 values EM_I386 and
ELFCLASS32 since we are building a 32-bit executable. Which is why we have a custom nlist.c here. Suggested by drahn@. ok drahn@ "looks good" deraadt@
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r--sys/arch/amd64/stand/installboot/nlist.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/sys/arch/amd64/stand/installboot/nlist.c b/sys/arch/amd64/stand/installboot/nlist.c
index 2dbdce9babb..0b46cc676af 100644
--- a/sys/arch/amd64/stand/installboot/nlist.c
+++ b/sys/arch/amd64/stand/installboot/nlist.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nlist.c,v 1.10 2011/07/03 21:37:40 krw Exp $ */
+/* $OpenBSD: nlist.c,v 1.11 2011/07/04 00:59:26 krw Exp $ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -281,13 +281,20 @@ __elf_is_okay__(Elf_Ehdr *ehdr)
* Elf_Ehdr structure. These few elements are
* represented in a machine independent fashion.
*/
+
+ /*
+ * We are constructing a 32-bit executable. So we can't
+ * use the libc nlist.c, which would be upset. Manually
+ * check for the i386 values for EI_CLASS and e_machine.
+ */
+
if (IS_ELF(*ehdr) &&
- ehdr->e_ident[EI_CLASS] == ELF_TARG_CLASS &&
+ ehdr->e_ident[EI_CLASS] == ELFCLASS32 &&
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 &&
+ if (ehdr->e_machine == EM_386 &&
ehdr->e_version == ELF_TARG_VER)
retval = 1;
}
@@ -313,7 +320,7 @@ __elf_fdnlist(int fd, struct nlist *list)
/* Make sure obj is OK */
if (pread(fd, &ehdr, sizeof(Elf_Ehdr), (off_t)0) != sizeof(Elf_Ehdr) ||
- /* !__elf_is_okay__(&ehdr) || */ fstat(fd, &st) < 0)
+ !__elf_is_okay__(&ehdr) || fstat(fd, &st) < 0)
return (-1);
/* calculate section header table size */