Commit | Line | Data |
---|---|---|
68608c33 CT |
1 | /* |
2 | * Copyright (c) 1992 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * This software was developed by the Computer Systems Engineering group | |
6 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and | |
7 | * contributed to Berkeley. | |
8 | * | |
9 | * %sccs.include.redist.c% | |
10 | * | |
11 | * @(#)exec.h 7.1 (Berkeley) %G% | |
12 | * | |
13 | * from: $Header: exec.h,v 1.7 92/07/01 23:51:32 torek Exp $ | |
14 | */ | |
15 | ||
16 | /* | |
17 | * __LDPGSZ is the page size used by the linker and by exec(). | |
18 | * It may be some multiple of the ``normal'' page size, so that, e.g., | |
19 | * the same binaries can be run on hardware with different page sizes | |
20 | * that otherwise use the same instruction set. It must be no larger | |
21 | * than CLBYTES (in param.h). | |
22 | */ | |
23 | #define __LDPGSZ 8192 | |
24 | ||
25 | /* Valid magic number check. */ | |
26 | #define N_BADMAG(ex) \ | |
27 | ((ex).a_magic != ZMAGIC && (ex).a_magic != NMAGIC && \ | |
28 | (ex).a_magic != OMAGIC) | |
29 | ||
30 | /* | |
31 | * N_TXTADDR is the address of the first executable instruction: that is, | |
32 | * the place the pc could begin after an a.out is loaded, in order to run | |
33 | * the instructions in that a.out. The pc will actually be set to ex.a_entry | |
34 | * but this is the first place it could possibly reference. | |
35 | * | |
36 | * On the SPARC, binaries begin at __LDPGSZ, i.e., page 1. | |
37 | */ | |
38 | #define N_TXTADDR(ex) 8192 | |
39 | ||
40 | /* Address of the bottom of the data segment. */ | |
41 | #define N_DATADDR(ex) \ | |
42 | (N_TXTADDR(ex) + ((ex).a_magic == OMAGIC ? (ex).a_text \ | |
43 | : __LDPGSZ + ((ex).a_text - 1 & ~(__LDPGSZ - 1)))) | |
44 | ||
45 | /* | |
46 | * N_TXTOFF is the offset within an a.out file of the first executable | |
47 | * instruction: that is, the offset in the a.out of the byte that winds | |
48 | * up at N_TXTADDR. | |
49 | * | |
50 | * On the SPARC, the a.out header is included in the executable when running | |
51 | * a ZMAGIC file (but not for OMAGIC and NMAGIC). | |
52 | */ | |
53 | #define N_TXTOFF(ex) ((ex).a_magic == ZMAGIC ? 0 : sizeof(struct exec)) | |
54 | ||
55 | /* Data segment offset. */ | |
56 | #define N_DATOFF(ex) \ | |
57 | (N_TXTOFF(ex) + ((ex).a_magic != ZMAGIC ? (ex).a_text : \ | |
58 | __LDPGSZ + ((ex).a_text - 1 & ~(__LDPGSZ - 1)))) | |
59 | ||
60 | /* Symbol table offset. */ | |
61 | #define N_SYMOFF(ex) \ | |
62 | (N_TXTOFF(ex) + (ex).a_text + (ex).a_data + (ex).a_trsize + \ | |
63 | (ex).a_drsize) | |
64 | ||
65 | /* String table offset. */ | |
66 | #define N_STROFF(ex) (N_SYMOFF(ex) + (ex).a_syms) | |
67 | ||
68 | /* Description of the object file header (a.out format). */ | |
69 | struct exec { | |
70 | u_char a_dynamic:1; /* dynamically linked */ | |
71 | u_char a_toolversion:7;/* Sun toolset version XXX */ | |
72 | ||
73 | #define MID_ZERO 0 /* unknown - implementation dependent */ | |
74 | #define MID_SUN010 1 /* sun 68010/68020 binary */ | |
75 | #define MID_SUN020 2 /* sun 68020-only binary */ | |
76 | #define MID_SUN_SPARC 3 /* sparc binary */ | |
77 | #define MID_HP200 200 /* hp200 (68010) BSD binary */ | |
78 | #define MID_HP300 300 /* hp300 (68020+68881) BSD binary */ | |
79 | #define MID_HPUX 0x20C /* hp200/300 HP-UX binary */ | |
80 | #define MID_HPUX800 0x20B /* hp800 HP-UX binary */ | |
81 | u_char a_mid; /* machine ID */ | |
82 | ||
83 | #define OMAGIC 0407 /* old impure format */ | |
84 | #define NMAGIC 0410 /* read-only text */ | |
85 | #define ZMAGIC 0413 /* demand load format */ | |
86 | u_short a_magic; /* magic number */ | |
87 | ||
88 | u_long a_text; /* text segment size */ | |
89 | u_long a_data; /* initialized data size */ | |
90 | u_long a_bss; /* uninitialized data size */ | |
91 | u_long a_syms; /* symbol table size */ | |
92 | u_long a_entry; /* entry point */ | |
93 | u_long a_trsize; /* text relocation size */ | |
94 | u_long a_drsize; /* data relocation size */ | |
95 | }; | |
96 | #define a_machtype a_mid /* SUN compatibility */ |