diff options
author | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2002-03-19 21:17:53 +0000 |
---|---|---|
committer | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2002-03-19 21:17:53 +0000 |
commit | 8f33d111e439e13c8b82f8d71c055f0d60ff5d61 (patch) | |
tree | 7027d295448ce0793682b774a2d87c9a0160a47f | |
parent | ab19372b556f5725cda99f78f7f4302f476368ad (diff) |
prepare to support both formats simultaneously.
-rw-r--r-- | usr.bin/pmdb/aout_syms.c | 14 | ||||
-rw-r--r-- | usr.bin/pmdb/elf_syms.c | 16 |
2 files changed, 17 insertions, 13 deletions
diff --git a/usr.bin/pmdb/aout_syms.c b/usr.bin/pmdb/aout_syms.c index 6ef5fd89981..6c7fdedb0a8 100644 --- a/usr.bin/pmdb/aout_syms.c +++ b/usr.bin/pmdb/aout_syms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aout_syms.c,v 1.3 2002/03/15 17:49:51 art Exp $ */ +/* $OpenBSD: aout_syms.c,v 1.4 2002/03/19 21:17:52 fgsch Exp $ */ /* * Copyright (c) 2002 Federico Schwindt <fgsch@openbsd.org> * All rights reserved. @@ -77,26 +77,28 @@ int sym_check_aout(const char *name, struct pstate *ps) { struct exec ahdr; + int error = 0; int fd; if ((fd = open(name, O_RDONLY)) < 0) - return (-1); + return (1); if (pread(fd, &ahdr, sizeof(ahdr), 0) != sizeof(ahdr)) { #ifndef IGNORE_PREAD_ERRORS - return (-1); + error = 1; #endif } if (N_BADMAG(ahdr)) { - return (-1); + error = 1; } close(fd); - ps->ps_sops = &aout_sops; + if (!error) + ps->ps_sops = &aout_sops; - return (0); + return (error); } struct sym_table * diff --git a/usr.bin/pmdb/elf_syms.c b/usr.bin/pmdb/elf_syms.c index f566a930b6c..492551c5d65 100644 --- a/usr.bin/pmdb/elf_syms.c +++ b/usr.bin/pmdb/elf_syms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: elf_syms.c,v 1.3 2002/03/15 17:49:51 art Exp $ */ +/* $OpenBSD: elf_syms.c,v 1.4 2002/03/19 21:17:52 fgsch Exp $ */ /* * Copyright (c) 2002 Artur Grabowski <art@openbsd.org> * All rights reserved. @@ -79,29 +79,31 @@ int sym_check_elf(const char *name, struct pstate *ps) { Elf_Ehdr ehdr; + int error = 0; int fd; if ((fd = open(name, O_RDONLY)) < 0) - return (-1); + return (1); if (pread(fd, &ehdr, sizeof(Elf_Ehdr), 0) != sizeof(Elf_Ehdr)) - return (-1); + error = 1; #ifndef __NetBSD__ - if (!IS_ELF(ehdr) || + if (!error && !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 || ehdr.e_machine != ELF_TARG_MACH || ehdr.e_version != ELF_TARG_VER) - return (-1); + error = 1; #endif close(fd); - ps->ps_sops = &elf_sops; + if (!error) + ps->ps_sops = &elf_sops; - return (0); + return (error); } struct sym_table * |