1 #ifndef_A_OUT_H 2 #define_A_OUT_H 3
4 #define __GNU_EXEC_MACROS__
5
6 structexec{ 7 unsignedlonga_magic; /* Use macros N_MAGIC, etc for access */ 8 unsigneda_text; /* length of text, in bytes */ 9 unsigneda_data; /* length of data, in bytes */ 10 unsigneda_bss; /* length of uninitialized data area for file, in bytes */ 11 unsigneda_syms; /* length of symbol table data in file, in bytes */ 12 unsigneda_entry; /* start address */ 13 unsigneda_trsize; /* length of relocation info for text, in bytes */ 14 unsigneda_drsize; /* length of relocation info for data, in bytes */ 15 };
16
17 #ifndefN_MAGIC 18 #defineN_MAGIC(exec) ((exec).a_magic)
19 #endif 20
21 #ifndefOMAGIC 22 /* Code indicating object file or impure executable. */ 23 #defineOMAGIC 0407
24 /* Code indicating pure executable. */ 25 #defineNMAGIC 0410
26 /* Code indicating demand-paged executable. */ 27 #defineZMAGIC 0413
28 #endif/* not OMAGIC */ 29
30 #ifndefN_BADMAG 31 #defineN_BADMAG(x) \
32 (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \
33 && N_MAGIC(x) != ZMAGIC)
34 #endif 35
36 #define _N_BADMAG(x) \
37 (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \
38 && N_MAGIC(x) != ZMAGIC)
39
40 #define_N_HDROFF(x) (SEGMENT_SIZE - sizeof (structexec))
41
42 #ifndefN_TXTOFF 43 #defineN_TXTOFF(x) \
44 (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (structexec) : sizeof (structexec))
45 #endif 46
47 #ifndefN_DATOFF 48 #defineN_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
49 #endif 50
51 #ifndefN_TRELOFF 52 #defineN_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
53 #endif 54
55 #ifndefN_DRELOFF 56 #defineN_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)
57 #endif 58
59 #ifndefN_SYMOFF 60 #defineN_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize)
61 #endif 62
63 #ifndefN_STROFF 64 #defineN_STROFF(x) (N_SYMOFF(x) + (x).a_syms)
65 #endif 66
67 /* Address of text segment in memory after it is loaded. */ 68 #ifndefN_TXTADDR 69 #defineN_TXTADDR(x) 0
70 #endif 71
72 /* Address of data segment in memory after it is loaded. 73 Note that it is up to you to define SEGMENT_SIZE 74 on machines not listed here. */ 75 #ifdefined(vax) || defined(hp300) || defined(pyr)
76 #defineSEGMENT_SIZEPAGE_SIZE 77 #endif 78 #ifdefhp300 79 #definePAGE_SIZE 4096
80 #endif 81 #ifdef sony
82 #defineSEGMENT_SIZE 0x2000
83 #endif/* Sony. */ 84 #ifdef is68k
85 #defineSEGMENT_SIZE 0x20000
86 #endif 87 #ifdefined(m68k) && defined(PORTAR)
88 #definePAGE_SIZE 0x400
89 #defineSEGMENT_SIZEPAGE_SIZE 90 #endif 91
92 #definePAGE_SIZE 4096
93 #defineSEGMENT_SIZE 1024
94
95 #define_N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
96
97 #define_N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
98
99 #ifndefN_DATADDR 100 #defineN_DATADDR(x) \
101 (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
102 : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
103 #endif 104
105 /* Address of bss segment in memory after it is loaded. */ 106 #ifndefN_BSSADDR 107 #defineN_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
108 #endif 109
110 #ifndef N_NLIST_DECLARED
111 structnlist{ 112 union{ 113 char *n_name;
114 structnlist *n_next;
115 long n_strx;
116 } n_un;
117 unsignedchar n_type;
118 char n_other;
119 short n_desc;
120 unsignedlong n_value;
121 };
122 #endif 123
124 #ifndefN_UNDF 125 #defineN_UNDF 0
126 #endif 127 #ifndefN_ABS 128 #defineN_ABS 2
129 #endif 130 #ifndefN_TEXT 131 #defineN_TEXT 4
132 #endif 133 #ifndefN_DATA 134 #defineN_DATA 6
135 #endif 136 #ifndefN_BSS 137 #defineN_BSS 8
138 #endif 139 #ifndefN_COMM 140 #defineN_COMM 18
141 #endif 142 #ifndefN_FN 143 #defineN_FN 15
144 #endif 145
146 #ifndefN_EXT 147 #defineN_EXT 1
148 #endif 149 #ifndefN_TYPE 150 #defineN_TYPE 036
151 #endif 152 #ifndefN_STAB 153 #defineN_STAB 0340
154 #endif 155
156 /* The following type indicates the definition of a symbol as being 157 an indirect reference to another symbol. The other symbol 158 appears as an undefined reference, immediately following this symbol. 159
160 Indirection is asymmetrical. The other symbol's value will be used 161 to satisfy requests for the indirect symbol, but not vice versa. 162 If the other symbol does not have a definition, libraries will 163 be searched to find a definition. */ 164 #define N_INDR 0xa
165
166 /* The following symbols refer to set elements. 167 All the N_SET[ATDB] symbols with the same name form one set. 168 Space is allocated for the set in the text section, and each set 169 element's value is stored into one word of the space. 170 The first word of the space is the length of the set (number of elements). 171
172 The address of the set is made into an N_SETV symbol 173 whose name is the same as the name of the set. 174 This symbol acts like a N_DATA global symbol 175 in that it can satisfy undefined external references. */ 176
177 /* These appear as input to LD, in a .o file. */ 178 #define N_SETA 0x14 /* Absolute set element symbol */ 179 #define N_SETT 0x16 /* Text set element symbol */ 180 #define N_SETD 0x18 /* Data set element symbol */ 181 #define N_SETB 0x1A /* Bss set element symbol */ 182
183 /* This is output from LD. */ 184 #define N_SETV 0x1C /* Pointer to set vector in data area. */ 185
186 #ifndef N_RELOCATION_INFO_DECLARED
187
188 /* This structure describes a single relocation to be performed. 189 The text-relocation section of the file is a vector of these structures, 190 all of which apply to the text section. 191 Likewise, the data-relocation section applies to the data section. */ 192
193 struct relocation_info
194 { 195 /* Address (within segment) to be relocated. */ 196 int r_address;
197 /* The meaning of r_symbolnum depends on r_extern. */ 198 unsignedint r_symbolnum:24;
199 /* Nonzero means value is a pc-relative offset 200 and it should be relocated for changes in its own address 201 as well as for changes in the symbol or section specified. */ 202 unsignedint r_pcrel:1;
203 /* Length (as exponent of 2) of the field to be relocated. 204 Thus, a value of 2 indicates 1<<2 bytes. */ 205 unsignedint r_length:2;
206 /* 1 => relocate with value of symbol. 207 r_symbolnum is the index of the symbol 208 in file's the symbol table. 209 0 => relocate with the address of a segment. 210 r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS 211 (the N_EXT bit may be set also, but signifies nothing). */ 212 unsignedint r_extern:1;
213 /* Four bits that aren't used, but when writing an object file 214 it is desirable to clear them. */ 215 unsignedint r_pad:4;
216 };
217 #endif/* no N_RELOCATION_INFO_DECLARED. */ 218
219
220 #endif/* __A_OUT_GNU_H__ */