1 #ifndef__A_OUT_GNU_H__ 2 #define__A_OUT_GNU_H__ 3
4 #define __GNU_EXEC_MACROS__
5
6 #ifndef __STRUCT_EXEC_OVERRIDE__
7
8 structexec 9 { 10 unsignedlonga_info; /* Use macros N_MAGIC, etc for access */ 11 unsigneda_text; /* length of text, in bytes */ 12 unsigneda_data; /* length of data, in bytes */ 13 unsigneda_bss; /* length of uninitialized data area for file, in bytes */ 14 unsigneda_syms; /* length of symbol table data in file, in bytes */ 15 unsigneda_entry; /* start address */ 16 unsigneda_trsize; /* length of relocation info for text, in bytes */ 17 unsigneda_drsize; /* length of relocation info for data, in bytes */ 18 };
19
20 #endif/* __STRUCT_EXEC_OVERRIDE__ */ 21
22 /* these go in the N_MACHTYPE field */ 23 enummachine_type{ 24 #ifdefined (M_OLDSUN2)
25 M__OLDSUN2 = M_OLDSUN2,
26 #else 27 M_OLDSUN2 = 0,
28 #endif 29 #ifdefined (M_68010)
30 M__68010 = M_68010,
31 #else 32 M_68010 = 1,
33 #endif 34 #ifdefined (M_68020)
35 M__68020 = M_68020,
36 #else 37 M_68020 = 2,
38 #endif 39 #ifdefined (M_SPARC)
40 M__SPARC = M_SPARC,
41 #else 42 M_SPARC = 3,
43 #endif 44 /* skip a bunch so we don't run into any of sun's numbers */ 45 M_386 = 100,
46 };
47
48 #if !defined (N_MAGIC)
49 #defineN_MAGIC(exec) ((exec).a_info & 0xffff)
50 #endif 51 #define N_MACHTYPE(exec) ((enummachine_type)(((exec).a_info >> 16) & 0xff))
52 #defineN_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
53 #define N_SET_INFO(exec, magic, type, flags) \
54 ((exec).a_info = ((magic) & 0xffff) \
55 | (((int)(type) & 0xff) << 16) \
56 | (((flags) & 0xff) << 24))
57 #define N_SET_MAGIC(exec, magic) \
58 ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
59
60 #define N_SET_MACHTYPE(exec, machtype) \
61 ((exec).a_info = \
62 ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
63
64 #define N_SET_FLAGS(exec, flags) \
65 ((exec).a_info = \
66 ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
67
68 /* Code indicating object file or impure executable. */ 69 #defineOMAGIC 0407
70 /* Code indicating pure executable. */ 71 #defineNMAGIC 0410
72 /* Code indicating demand-paged executable. */ 73 #defineZMAGIC 0413
74 /* This indicates a demand-paged executable with the header in the text. 75 The first page is unmapped to help trap NULL pointer references */ 76 #defineQMAGIC 0314
77
78 /* Code indicating core file. */ 79 #defineCMAGIC 0421
80
81 #if !defined (N_BADMAG)
82 #defineN_BADMAG(x) (N_MAGIC(x) != OMAGIC \
83 && N_MAGIC(x) != NMAGIC \
84 && N_MAGIC(x) != ZMAGIC \
85 && N_MAGIC(x) != QMAGIC)
86 #endif 87
88 #define_N_HDROFF(x) (1024 - sizeof (structexec))
89
90 #if !defined (N_TXTOFF)
91 #defineN_TXTOFF(x) \
92 (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (structexec) : \
93 (N_MAGIC(x) == QMAGIC ? 0 : sizeof (structexec)))
94 #endif 95
96 #if !defined (N_DATOFF)
97 #defineN_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
98 #endif 99
100 #if !defined (N_TRELOFF)
101 #defineN_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
102 #endif 103
104 #if !defined (N_DRELOFF)
105 #defineN_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)
106 #endif 107
108 #if !defined (N_SYMOFF)
109 #defineN_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize)
110 #endif 111
112 #if !defined (N_STROFF)
113 #defineN_STROFF(x) (N_SYMOFF(x) + (x).a_syms)
114 #endif 115
116 /* Address of text segment in memory after it is loaded. */ 117 #if !defined (N_TXTADDR)
118 #defineN_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? PAGE_SIZE : 0)
119 #endif 120
121 /* Address of data segment in memory after it is loaded. 122 Note that it is up to you to define SEGMENT_SIZE 123 on machines not listed here. */ 124 #ifdefined(vax) || defined(hp300) || defined(pyr)
125 #defineSEGMENT_SIZE page_size
126 #endif 127 #ifdef sony
128 #defineSEGMENT_SIZE 0x2000
129 #endif/* Sony. */ 130 #ifdef is68k
131 #defineSEGMENT_SIZE 0x20000
132 #endif 133 #ifdefined(m68k) && defined(PORTAR)
134 #definePAGE_SIZE 0x400
135 #defineSEGMENT_SIZEPAGE_SIZE 136 #endif 137
138 #ifdeflinux 139 #include <asm/page.h>
140 #defineSEGMENT_SIZE 1024
141 #endif 142
143 #define_N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
144
145 #define_N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
146
147 #ifndefN_DATADDR 148 #defineN_DATADDR(x) \
149 (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
150 : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
151 #endif 152
153 /* Address of bss segment in memory after it is loaded. */ 154 #if !defined (N_BSSADDR)
155 #defineN_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
156 #endif 157
158 #if !defined (N_NLIST_DECLARED)
159 structnlist{ 160 union{ 161 char *n_name;
162 structnlist *n_next;
163 long n_strx;
164 } n_un;
165 unsignedchar n_type;
166 char n_other;
167 short n_desc;
168 unsignedlongn_value;
169 };
170 #endif/* no N_NLIST_DECLARED. */ 171
172 #if !defined (N_UNDF)
173 #defineN_UNDF 0
174 #endif 175 #if !defined (N_ABS)
176 #defineN_ABS 2
177 #endif 178 #if !defined (N_TEXT)
179 #defineN_TEXT 4
180 #endif 181 #if !defined (N_DATA)
182 #defineN_DATA 6
183 #endif 184 #if !defined (N_BSS)
185 #defineN_BSS 8
186 #endif 187 #if !defined (N_FN)
188 #defineN_FN 15
189 #endif 190
191 #if !defined (N_EXT)
192 #defineN_EXT 1
193 #endif 194 #if !defined (N_TYPE)
195 #defineN_TYPE 036
196 #endif 197 #if !defined (N_STAB)
198 #defineN_STAB 0340
199 #endif 200
201 /* The following type indicates the definition of a symbol as being 202 an indirect reference to another symbol. The other symbol 203 appears as an undefined reference, immediately following this symbol. 204
205 Indirection is asymmetrical. The other symbol's value will be used 206 to satisfy requests for the indirect symbol, but not vice versa. 207 If the other symbol does not have a definition, libraries will 208 be searched to find a definition. */ 209 #define N_INDR 0xa
210
211 /* The following symbols refer to set elements. 212 All the N_SET[ATDB] symbols with the same name form one set. 213 Space is allocated for the set in the text section, and each set 214 element's value is stored into one word of the space. 215 The first word of the space is the length of the set (number of elements). 216
217 The address of the set is made into an N_SETV symbol 218 whose name is the same as the name of the set. 219 This symbol acts like a N_DATA global symbol 220 in that it can satisfy undefined external references. */ 221
222 /* These appear as input to LD, in a .o file. */ 223 #define N_SETA 0x14 /* Absolute set element symbol */ 224 #define N_SETT 0x16 /* Text set element symbol */ 225 #define N_SETD 0x18 /* Data set element symbol */ 226 #define N_SETB 0x1A /* Bss set element symbol */ 227
228 /* This is output from LD. */ 229 #define N_SETV 0x1C /* Pointer to set vector in data area. */ 230
231 #if !defined (N_RELOCATION_INFO_DECLARED)
232 /* This structure describes a single relocation to be performed. 233 The text-relocation section of the file is a vector of these structures, 234 all of which apply to the text section. 235 Likewise, the data-relocation section applies to the data section. */ 236
237 struct relocation_info
238 { 239 /* Address (within segment) to be relocated. */ 240 int r_address;
241 /* The meaning of r_symbolnum depends on r_extern. */ 242 unsignedint r_symbolnum:24;
243 /* Nonzero means value is a pc-relative offset 244 and it should be relocated for changes in its own address 245 as well as for changes in the symbol or section specified. */ 246 unsignedint r_pcrel:1;
247 /* Length (as exponent of 2) of the field to be relocated. 248 Thus, a value of 2 indicates 1<<2 bytes. */ 249 unsignedint r_length:2;
250 /* 1 => relocate with value of symbol. 251 r_symbolnum is the index of the symbol 252 in file's the symbol table. 253 0 => relocate with the address of a segment. 254 r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS 255 (the N_EXT bit may be set also, but signifies nothing). */ 256 unsignedint r_extern:1;
257 /* Four bits that aren't used, but when writing an object file 258 it is desirable to clear them. */ 259 #ifdef NS32K
260 unsigned r_bsr:1;
261 unsigned r_disp:1;
262 unsignedr_pad:2;
263 #else 264 unsignedintr_pad:4;
265 #endif 266 };
267 #endif/* no N_RELOCATION_INFO_DECLARED. */ 268
269
270 #endif/* __A_OUT_GNU_H__ */