1 /* $NetBSD: pecoff_exec.h,v 1.9 2005/12/11 12:20:23 christos Exp $ */
2
3 /*
4 * Copyright (c) 2000 Masaru OKI
5 * Copyright (c) 1994, 1995, 1998 Scott Bartram
6 * All rights reserved.
7 *
8 * adapted from sys/sys/exec_ecoff.h
9 * based on Intel iBCS2
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #ifndef _PECOFF_EXEC_H_
35 #define _PECOFF_EXEC_H_
36
37 struct pecoff_dos_filehdr {
38 u_int16_t d_magic; /* +0x00 'MZ' */
39 u_int8_t d_stub[0x3a];
40 u_int32_t d_peofs; /* +0x3c */
41 };
42
43 #define PECOFF_DOS_MAGIC 0x5a4d
44 #define PECOFF_DOS_HDR_SIZE (sizeof(struct pecoff_dos_filehdr))
45
46 #define DOS_BADMAG(dp) ((dp)->d_magic != PECOFF_DOS_MAGIC)
47
48 /* magic */
49 #define COFF_OMAGIC 0407 /* text not write-protected; data seg
50 is contiguous with text */
51 #define COFF_NMAGIC 0410 /* text is write-protected; data starts
52 at next seg following text */
53 #define COFF_ZMAGIC 0413 /* text and data segs are aligned for
54 direct paging */
55 #define COFF_SMAGIC 0443 /* shared lib */
56
57 #define COFF_LDPGSZ 4096 /* XXX */
58
59 struct pecoff_imghdr {
60 long i_vaddr;
61 long i_size;
62 };
63
64 struct pecoff_opthdr {
65 long w_base;
66 long w_salign;
67 long w_falign;
68 long w_osvers;
69 long w_imgvers;
70 long w_subvers;
71 long w_rsvd;
72 long w_imgsize;
73 long w_hdrsize;
74 long w_chksum;
75 u_short w_subsys;
76 u_short w_dllflags;
77 long w_ssize;
78 long w_cssize;
79 long w_hsize;
80 long w_chsize;
81 long w_lflag;
82 long w_nimghdr;
83 struct pecoff_imghdr w_imghdr[16];
84 };
85
86
87 /* s_flags for PE */
88 #define COFF_STYP_DISCARD 0x2000000
89 #define COFF_STYP_EXEC 0x20000000
90 #define COFF_STYP_READ 0x40000000
91 #define COFF_STYP_WRITE 0x80000000
92
93 #define PECOFF_HDR_SIZE (COFF_HDR_SIZE + sizeof(struct pecoff_opthdr))
94
95 #define NETBSDPE_ABI_VERSION 0x00000002
96
97 struct pecoff_args1 { /* obsoleted */
98 u_long a_base;
99 u_long a_entry;
100 u_long a_end;
101 u_long a_subsystem;
102 struct pecoff_imghdr a_imghdr[16];
103 u_long a_ldbase;
104 u_long a_ldexport;
105 };
106 struct pecoff_args {
107 u_long a_abiversion;
108 u_long a_zero; /* always 0 */
109 u_long a_entry;
110 u_long a_end;
111 u_long a_ldbase;
112 u_long a_ldexport;
113 struct pecoff_opthdr a_opthdr;
114 };
115
116 extern const struct emul emul_pecoff;
117
118 struct exec_package;
119 int exec_pecoff_makecmds (struct lwp *, struct exec_package *);
120 int pecoff_copyargs (struct lwp *, struct exec_package *,
121 struct ps_strings *, char **, void *);
122
123 #endif
Cache object: 60d2f6dc485096a190e61a55ad3db8e4
|