source: vendor/emx/current/src/include/defs.h

Last change on this file was 18, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 11.7 KB
Line 
1/* defs.h -- Various definitions for emx development utilities
2 Copyright (c) 1992-1998 Eberhard Mattes
3
4This file is part of emx.
5
6emx is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11emx is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with emx; see the file COPYING. If not, write to
18the Free Software Foundation, 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA. */
20
21
22#define FALSE 0
23#define TRUE 1
24
25#ifdef __GNUC__
26#define NORETURN2 __attribute__ ((noreturn))
27#define ATTR_PRINTF(s,f) __attribute__ ((__format__ (__printf__, s, f)))
28#else
29#define NORETURN2
30#define ATTR_PRINTF(s,f)
31#endif
32
33
34/* Stabs constants. */
35
36#define N_EXT 0x01 /* Symbol is external */
37#define N_ABS 0x02 /* Absolute address */
38#define N_TEXT 0x04 /* In .text segment */
39#define N_DATA 0x06 /* In .data segment */
40#define N_BSS 0x08 /* In .bss segment */
41
42#define N_INDR 0x0a
43#define N_WEAKU 0x0d /* Includes N_EXT! */
44
45#define N_SETA 0x14
46#define N_SETT 0x16
47#define N_SETD 0x18
48
49#define N_GSYM 0x20
50#define N_FUN 0x24
51#define N_STSYM 0x26
52#define N_LCSYM 0x28
53#define N_RSYM 0x40
54#define N_SLINE 0x44
55#define N_SO 0x64
56#define N_LSYM 0x80
57#define N_SOL 0x84
58#define N_PSYM 0xa0
59#define N_LBRAC 0xc0
60#define N_RBRAC 0xe0
61
62#define N_IMP1 0x68 /* Import reference (emx specific) */
63#define N_IMP2 0x6a /* Import definition (emx specific) */
64
65/* The maximum OMF record size supported by OMF linkers. This value
66 includes the record type, length and checksum fields. */
67
68#define MAX_REC_SIZE 1024
69
70/* OMF record types. To get the 32-bit variant of a record type, add
71 REC32. */
72
73#define THEADR 0x80 /* Translator module header record */
74#define COMENT 0x88 /* Comment record */
75#define MODEND 0x8a /* Module end record */
76#define EXTDEF 0x8c /* External names definition record */
77#define TYPDEF 0x8e /* Type definition record */
78#define PUBDEF 0x90 /* Public names definition record */
79#define LINNUM 0x94 /* Line numbers record */
80#define LNAMES 0x96 /* List of names record */
81#define SEGDEF 0x98 /* Segment definition record */
82#define GRPDEF 0x9a /* Group definition record */
83#define FIXUPP 0x9c /* Fixup record */
84#define LEDATA 0xa0 /* Logical enumerated data record */
85#define LIDATA 0xa2 /* Logical iterated data record */
86#define COMDEF 0xb0 /* Communal names definition record */
87#define COMDAT 0xc2 /* Common block */
88#define ALIAS 0xc6 /* Alias definition record */
89#define LIBHDR 0xf0 /* Library header */
90#define LIBEND 0xf1 /* Library end */
91
92/* Add this constant (using the | operator) to get the 32-bit variant
93 of a record type. Some fields will contain 32-bit values instead
94 of 16-bit values. */
95
96#define REC32 0x01
97
98/* BIND_OFFSET is the offset from the beginning of the emxbind patch
99 area to the data fields of that area. The first BIND_OFFSET bytes
100 of the emxbind patch area are used for storing the emx version
101 number. */
102
103#define BIND_OFFSET 16
104
105
106typedef unsigned char byte;
107typedef unsigned short word;
108typedef unsigned long dword;
109
110/* The header of an a.out file. */
111
112struct a_out_header
113{
114 word magic; /* Magic word, must be 0407 */
115 byte machtype; /* Machine type */
116 byte flags; /* Flags */
117 long text_size; /* Length of text, in bytes */
118 long data_size; /* Length of initialized data, in bytes */
119 long bss_size; /* Length of uninitialized data, in bytes */
120 long sym_size; /* Length of symbol table, in bytes */
121 long entry; /* Start address (entry point) */
122 long trsize; /* Length of relocation info for text, bytes */
123 long drsize; /* Length of relocation info for data, bytes */
124};
125
126/* This is the layout of a relocation table entry. */
127
128struct reloc
129{
130 dword address; /* Fixup location */
131 dword symbolnum:24; /* Symbol number or segment */
132 dword pcrel:1; /* Self-relative fixup if non-zero */
133 dword length:2; /* Fixup size (0: 1 byte, 1: 2, 2: 4 bytes) */
134 dword ext:1; /* Reference to symbol or segment */
135 dword unused:4; /* Not used */
136};
137
138/* This is the layout of a symbol table entry. */
139
140struct nlist
141{
142 dword string; /* Offset in string table */
143 byte type; /* Type of the symbol */
144 byte other; /* Other information */
145 word desc; /* More information */
146 dword value; /* Value (address) */
147};
148
149/* This is the header of a DOS executable file. */
150
151struct exe1_header
152{
153 word magic; /* Magic number, "MZ" (0x5a4d) */
154 word last_page; /* Number of bytes in last page */
155 word pages; /* Size of the file in 512-byte pages */
156 word reloc_size; /* Number of relocation entries */
157 word hdr_size; /* Size of header in 16-byte paragraphs */
158 word min_alloc; /* Minimum allocation (paragraphs) */
159 word max_alloc; /* Maximum allocation (paragraphs) */
160 word ss, sp; /* Initial stack pointer */
161 word chksum; /* Checksum */
162 word ip, cs; /* Entry point */
163 word reloc_ptr; /* Location of the relocation table */
164 word ovl; /* Overlay number */
165};
166
167/* This is an additional header of a DOS executable file. It contains
168 a pointer to the new EXE header. */
169
170struct exe2_header
171{
172 word res1[16]; /* Reserved */
173 word new_lo; /* Low word of the location of the header */
174 word new_hi; /* High word of the location of the header */
175};
176
177/* This is the layout of the OS/2 LX header. */
178
179struct os2_header
180{
181 word magic; /* Magic number, "LX" (0x584c) */
182 byte byte_order; /* Byte order */
183 byte word_order; /* Word order */
184 dword level; /* Format level */
185 word cpu; /* CPU type */
186 word os; /* Operating system type */
187 dword ver; /* Module version */
188 dword mod_flags; /* Module flags */
189 dword mod_pages; /* Number of pages in the EXE file */
190 dword entry_obj; /* Object number for EIP */
191 dword entry_eip; /* Entry point */
192 dword stack_obj; /* Object number for ESP */
193 dword stack_esp; /* Stack */
194 dword pagesize; /* System page size */
195 dword pageshift; /* Page offset shift */
196 dword fixup_size; /* Fixup section size */
197 dword fixup_checksum; /* Fixup section checksum */
198 dword loader_size; /* Loader section size */
199 dword loader_checksum; /* Loader section checksum */
200 dword obj_offset; /* Object table offset */
201 dword obj_count; /* Number of objects in module */
202 dword pagemap_offset; /* Object page table offset */
203 dword itermap_offset; /* Object iterated pages offset */
204 dword rsctab_offset; /* Resource table offset */
205 dword rsctab_count; /* Number of resource table entries */
206 dword resname_offset; /* Resident name table offset */
207 dword entry_offset; /* Entry table offset */
208 dword moddir_offset; /* Module directives offset */
209 dword moddir_count; /* Number of module directives */
210 dword fixpage_offset; /* Fixup page table offset */
211 dword fixrecord_offset; /* Fixup record table offset */
212 dword impmod_offset; /* Import module table offset */
213 dword impmod_count; /* Number of import module table entries */
214 dword impprocname_offset; /* Import procedure table offset */
215 dword page_checksum_offset; /* Per page checksum table offset */
216 dword enum_offset; /* Data pages offset */
217 dword preload_count; /* Number of preload pages */
218 dword nonresname_offset; /* Non-resident name table offset */
219 dword nonresname_size; /* Non-resident name table size */
220 dword nonresname_checksum; /* Non-resident name table checksum */
221 dword auto_obj; /* Auto data segment object number */
222 dword debug_offset; /* Debug information offset */
223 dword debug_size; /* Debug information size */
224 dword instance_preload; /* Number of instance preload pages */
225 dword instance_demand; /* Number of instance load-on-demand pages */
226 dword heap_size; /* Heap size */
227 dword stack_size; /* Stack size */
228 dword reserved[5]; /* Reserved */
229};
230
231/* This is the layout of an object table entry. */
232
233struct object
234{
235 dword virt_size; /* Virtual size */
236 dword virt_base; /* Relocation base address */
237 dword attr_flags; /* Object attributes and flags */
238 dword map_first; /* Page table index */
239 dword map_count; /* Number of page table entries */
240 dword reserved; /* Reserved */
241};
242
243/* This is the layout of the emxbind patch area for DOS. It is
244 located at the beginning of the loadable image. */
245
246struct dos_bind_header
247{
248 byte hdr[BIND_OFFSET]; /* emx version number */
249 byte bind_flag; /* Non-zero if this program is bound */
250 byte fill_1; /* Padding for proper alignment */
251 word hdr_loc_lo; /* Location of the a.out header */
252 word hdr_loc_hi; /* (split into two words due to alignment) */
253 byte options[64]; /* emx options to be used under DOS */
254};
255
256/* This is the layout of the emxbind patch area for OS/2. It is
257 located at the beginning of the data segment. This table contains
258 information required for dumping core and for forking. */
259
260struct os2_bind_header
261{
262 dword text_base; /* Base address of the text segment */
263 dword text_end; /* End address of the text segment */
264 dword data_base; /* Base address of initialized data */
265 dword data_end; /* End address of initialized data */
266 dword bss_base; /* Base address of uninitialized data */
267 dword bss_end; /* End address of uninitialized data */
268 dword heap_base; /* Base address of the heap */
269 dword heap_end; /* End address of the heap */
270 dword heap_brk; /* End address of the used heap space */
271 dword heap_off; /* Location of heap data in the executable */
272 dword os2_dll; /* Address of the import table for (I1) */
273 dword stack_base; /* Base address of the stack */
274 dword stack_end; /* End address of the stack */
275 dword flags; /* Flags (DLL) and interface number */
276 dword reserved[2]; /* Not yet used */
277 byte options[64]; /* emx options to be used under OS/2 */
278};
279
280#pragma pack(1)
281
282struct omf_rec
283{
284 byte rec_type;
285 word rec_len;
286};
287
288#pragma pack()
Note: See TracBrowser for help on using the repository browser.