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