Commit | Line | Data |
---|---|---|
4b5fb9f4 KB |
1 | /*- |
2 | * Copyright (c) 1992 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * %sccs.include.redist.c% | |
6 | * | |
7 | * @(#)exec.h 7.1 (Berkeley) %G% | |
8 | */ | |
9 | ||
10 | /* Size of a page in an object file. */ | |
11 | #define __LDPGSZ 4096 | |
12 | ||
13 | /* Valid magic number check. */ | |
14 | #define N_BADMAG(ex) \ | |
15 | ((ex).a_magic != NMAGIC && (ex).a_magic != OMAGIC && \ | |
16 | (ex).a_magic != ZMAGIC) | |
17 | ||
18 | /* Address of the bottom of the text segment. */ | |
19 | #define N_TXTADDR(X) 0 | |
20 | ||
21 | /* Address of the bottom of the data segment. */ | |
22 | #define N_DATADDR(ex) \ | |
23 | (N_TXTADDR(ex) + ((ex).a_magic == OMAGIC ? (ex).a_text \ | |
24 | : __LDPGSZ + ((ex).a_text - 1 & ~(__LDPGSZ - 1)))) | |
25 | ||
26 | /* Text segment offset. */ | |
27 | #define N_TXTOFF(ex) \ | |
28 | ((ex).a_magic == ZMAGIC ? __LDPGSZ : sizeof(struct exec)) | |
29 | ||
30 | /* Data segment offset. */ | |
31 | #define N_DATOFF(ex) \ | |
32 | (N_TXTOFF(ex) + ((ex).a_magic != ZMAGIC ? (ex).a_text : \ | |
33 | __LDPGSZ + ((ex).a_text - 1 & ~(__LDPGSZ - 1)))) | |
34 | ||
35 | /* Symbol table offset. */ | |
36 | #define N_SYMOFF(ex) \ | |
37 | (N_TXTOFF(ex) + (ex).a_text + (ex).a_data + (ex).a_trsize + \ | |
38 | (ex).a_drsize) | |
39 | ||
40 | /* String table offset. */ | |
41 | #define N_STROFF(ex) (N_SYMOFF(ex) + (ex).a_syms) | |
42 | ||
43 | /* Description of the object file header (a.out format). */ | |
44 | struct exec { | |
45 | #define OMAGIC 0407 /* old impure format */ | |
46 | #define NMAGIC 0410 /* read-only text */ | |
47 | #define ZMAGIC 0413 /* demand load format */ | |
48 | long a_magic; /* magic number */ | |
49 | ||
50 | u_long a_text; /* text segment size */ | |
51 | u_long a_data; /* initialized data size */ | |
52 | u_long a_bss; /* uninitialized data size */ | |
53 | u_long a_syms; /* symbol table size */ | |
54 | u_long a_entry; /* entry point */ | |
55 | u_long a_trsize; /* text relocation size */ | |
56 | u_long a_drsize; /* data relocation size */ | |
57 | }; |