summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2001-01-15 12:07:36 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2001-01-15 12:07:36 +0000
commit019940f6d5b6f285b297d37109a9a9f8f56d38e8 (patch)
tree903ae7f277919b6b36a5013ec8aac8f9cfd60bd3 /sys
parent36809cc642eea7b146d94dcfba42f07f27cc8a00 (diff)
Some ECOFF ifdefs and various fixes.
From d@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/alpha/stand/headersize.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/sys/arch/alpha/stand/headersize.c b/sys/arch/alpha/stand/headersize.c
index 70495db3bfb..c8f222d467b 100644
--- a/sys/arch/alpha/stand/headersize.c
+++ b/sys/arch/alpha/stand/headersize.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: headersize.c,v 1.6 2000/12/14 13:47:47 art Exp $ */
+/* $OpenBSD: headersize.c,v 1.7 2001/01/15 12:07:35 art Exp $ */
/* $NetBSD: headersize.c,v 1.5 1996/09/23 04:32:59 cgd Exp $ */
/*
@@ -38,6 +38,7 @@
#include <unistd.h>
#include <stdio.h>
+#include <err.h>
#define HDR_BUFSIZE 512
@@ -47,7 +48,9 @@ main(argc, argv)
char *argv[];
{
char buf[HDR_BUFSIZE], *fname;
+#ifdef ALPHA_BOOT_ECOFF
struct ecoff_exechdr *ecoffp;
+#endif
#ifdef ALPHA_BOOT_ELF
Elf64_Ehdr *elfp;
#endif
@@ -61,20 +64,25 @@ main(argc, argv)
fname = argv[2];
if ((fd = open(fname, O_RDONLY, 0)) == -1)
- err(1, "%s: open failed", 0);
+ err(1, "%s: open failed", fname);
if (read(fd, &buf, HDR_BUFSIZE) < HDR_BUFSIZE)
err(1, "%s: read failed", fname);
+#ifdef ALPHA_BOOT_ECOFF
ecoffp = (struct ecoff_exechdr *)buf;
+#endif
#ifdef ALPHA_BOOT_ELF
elfp = (Elf64_Ehdr *)buf;
#endif
+#ifdef ALPHA_BOOT_ECOFF
if (!ECOFF_BADMAG(ecoffp)) {
- printf("%d\n", ECOFF_TXTOFF(ecoffp));
+ printf("%ld\n", ECOFF_TXTOFF(ecoffp));
}
+ else
+#endif
#ifdef ALPHA_BOOT_ELF
- else if (memcmp(ELFMAG, elfp->e_ident, SELFMAG) == 0) {
+ if (memcmp(ELFMAG, elfp->e_ident, SELFMAG) == 0) {
Elf64_Phdr phdr;
/* XXX assume the first segment is the one we want */
@@ -83,11 +91,12 @@ main(argc, argv)
if (read(fd, (void *)&phdr, sizeof(phdr)) != sizeof(phdr))
err(1, "%s: read phdr failed", fname);
- printf("%d\n", phdr.p_offset + (loadaddr - phdr.p_vaddr));
+ printf("%ld\n", phdr.p_offset + (loadaddr - phdr.p_vaddr));
}
-#endif
else
+#endif
errx(1, "%s: bad magic number", fname);
close(fd);
+ exit(0);
}