Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / hp700 / stand / common / exec_som.c
blob6d5bce1c1260ad28afd8234de1fb5a08debc6464
1 /* $NetBSD: exec_som.c,v 1.3 2007/03/03 14:37:54 skrll Exp $ */
3 /* $OpenBSD: exec_som.c,v 1.1 1999/12/23 04:10:30 mickey Exp $ */
5 /*
6 * Copyright (c) 1999 Michael Shalayeff
7 * All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/param.h>
33 #include "libsa.h"
34 #include <machine/exec.h>
35 #include <lib/libsa/exec.h>
37 int
38 som_probe(int fd, union x_header *hdr)
40 return !SOM_BADMAGIC(&hdr->x_som);
44 int
45 som_load(int fd, struct x_param *xp)
47 struct som_filehdr *xf = &xp->xp_hdr->x_som;
48 struct som_exec_aux x;
50 if (lseek(fd, xf->aux_loc, SEEK_SET) < 0 ||
51 read (fd, &x, sizeof(x)) != sizeof(x)) {
52 if (!errno)
53 errno = EIO;
54 return -1;
57 xp->xp_entry = x.a_entry;
59 xp->text.size = round_page(x.a_tsize);
60 xp->data.size = round_page(x.a_dsize);
61 xp->bss.size = x.a_bsize;
62 xp->sym.size = xf->sym_total * sizeof(struct som_sym);
63 xp->str.size = xf->strings_size;
65 xp->text.foff = x.a_tfile;
66 xp->data.foff = x.a_dfile;
67 xp->bss.foff = 0;
68 if (xf->sym_total) {
69 xp->sym.foff = xf->sym_loc;
70 xp->str.foff = xf->strings_loc;
73 xp->text.addr = x.a_tmem;
74 xp->data.addr = x.a_dmem;
75 xp->bss.addr = xp->data.addr + x.a_dsize;
76 xp->sym.addr = xp->bss.addr + xp->bss.size;
77 xp->str.addr = xp->sym.addr + xp->sym.size;
79 return 0;
82 int
83 som_ldsym(int fd, struct x_param *xp)
85 return -1;