xref: /linux/include/uapi/linux/a.out.h (revision fbd576295d6f98b20356d1e6efbc8f976b17c8af)
1607ca46eSDavid Howells #ifndef _UAPI__A_OUT_GNU_H__
2607ca46eSDavid Howells #define _UAPI__A_OUT_GNU_H__
3607ca46eSDavid Howells 
4607ca46eSDavid Howells #define __GNU_EXEC_MACROS__
5607ca46eSDavid Howells 
6607ca46eSDavid Howells #ifndef __STRUCT_EXEC_OVERRIDE__
7607ca46eSDavid Howells 
8607ca46eSDavid Howells #include <asm/a.out.h>
9607ca46eSDavid Howells 
10607ca46eSDavid Howells #endif /* __STRUCT_EXEC_OVERRIDE__ */
11607ca46eSDavid Howells 
12607ca46eSDavid Howells #ifndef __ASSEMBLY__
13607ca46eSDavid Howells 
14607ca46eSDavid Howells /* these go in the N_MACHTYPE field */
15607ca46eSDavid Howells enum machine_type {
16607ca46eSDavid Howells #if defined (M_OLDSUN2)
17607ca46eSDavid Howells   M__OLDSUN2 = M_OLDSUN2,
18607ca46eSDavid Howells #else
19607ca46eSDavid Howells   M_OLDSUN2 = 0,
20607ca46eSDavid Howells #endif
21607ca46eSDavid Howells #if defined (M_68010)
22607ca46eSDavid Howells   M__68010 = M_68010,
23607ca46eSDavid Howells #else
24607ca46eSDavid Howells   M_68010 = 1,
25607ca46eSDavid Howells #endif
26607ca46eSDavid Howells #if defined (M_68020)
27607ca46eSDavid Howells   M__68020 = M_68020,
28607ca46eSDavid Howells #else
29607ca46eSDavid Howells   M_68020 = 2,
30607ca46eSDavid Howells #endif
31607ca46eSDavid Howells #if defined (M_SPARC)
32607ca46eSDavid Howells   M__SPARC = M_SPARC,
33607ca46eSDavid Howells #else
34607ca46eSDavid Howells   M_SPARC = 3,
35607ca46eSDavid Howells #endif
36607ca46eSDavid Howells   /* skip a bunch so we don't run into any of sun's numbers */
37607ca46eSDavid Howells   M_386 = 100,
38607ca46eSDavid Howells   M_MIPS1 = 151,	/* MIPS R3000/R3000 binary */
39607ca46eSDavid Howells   M_MIPS2 = 152		/* MIPS R6000/R4000 binary */
40607ca46eSDavid Howells };
41607ca46eSDavid Howells 
42607ca46eSDavid Howells #if !defined (N_MAGIC)
43607ca46eSDavid Howells #define N_MAGIC(exec) ((exec).a_info & 0xffff)
44607ca46eSDavid Howells #endif
45607ca46eSDavid Howells #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
46607ca46eSDavid Howells #define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
47607ca46eSDavid Howells #define N_SET_INFO(exec, magic, type, flags) \
48607ca46eSDavid Howells 	((exec).a_info = ((magic) & 0xffff) \
49607ca46eSDavid Howells 	 | (((int)(type) & 0xff) << 16) \
50607ca46eSDavid Howells 	 | (((flags) & 0xff) << 24))
51607ca46eSDavid Howells #define N_SET_MAGIC(exec, magic) \
52607ca46eSDavid Howells 	((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
53607ca46eSDavid Howells 
54607ca46eSDavid Howells #define N_SET_MACHTYPE(exec, machtype) \
55607ca46eSDavid Howells 	((exec).a_info = \
56607ca46eSDavid Howells 	 ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
57607ca46eSDavid Howells 
58607ca46eSDavid Howells #define N_SET_FLAGS(exec, flags) \
59607ca46eSDavid Howells 	((exec).a_info = \
60607ca46eSDavid Howells 	 ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
61607ca46eSDavid Howells 
62607ca46eSDavid Howells /* Code indicating object file or impure executable.  */
63607ca46eSDavid Howells #define OMAGIC 0407
64607ca46eSDavid Howells /* Code indicating pure executable.  */
65607ca46eSDavid Howells #define NMAGIC 0410
66607ca46eSDavid Howells /* Code indicating demand-paged executable.  */
67607ca46eSDavid Howells #define ZMAGIC 0413
68607ca46eSDavid Howells /* This indicates a demand-paged executable with the header in the text.
69607ca46eSDavid Howells    The first page is unmapped to help trap NULL pointer references */
70607ca46eSDavid Howells #define QMAGIC 0314
71607ca46eSDavid Howells 
72607ca46eSDavid Howells /* Code indicating core file.  */
73607ca46eSDavid Howells #define CMAGIC 0421
74607ca46eSDavid Howells 
75607ca46eSDavid Howells #if !defined (N_BADMAG)
76607ca46eSDavid Howells #define N_BADMAG(x)	  (N_MAGIC(x) != OMAGIC		\
77607ca46eSDavid Howells 			&& N_MAGIC(x) != NMAGIC		\
78607ca46eSDavid Howells   			&& N_MAGIC(x) != ZMAGIC \
79607ca46eSDavid Howells 		        && N_MAGIC(x) != QMAGIC)
80607ca46eSDavid Howells #endif
81607ca46eSDavid Howells 
82607ca46eSDavid Howells #define _N_HDROFF(x) (1024 - sizeof (struct exec))
83607ca46eSDavid Howells 
84607ca46eSDavid Howells #if !defined (N_TXTOFF)
85607ca46eSDavid Howells #define N_TXTOFF(x) \
86607ca46eSDavid Howells  (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : \
87607ca46eSDavid Howells   (N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec)))
88607ca46eSDavid Howells #endif
89607ca46eSDavid Howells 
90607ca46eSDavid Howells #if !defined (N_DATOFF)
91607ca46eSDavid Howells #define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
92607ca46eSDavid Howells #endif
93607ca46eSDavid Howells 
94607ca46eSDavid Howells #if !defined (N_TRELOFF)
95607ca46eSDavid Howells #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
96607ca46eSDavid Howells #endif
97607ca46eSDavid Howells 
98607ca46eSDavid Howells #if !defined (N_DRELOFF)
99607ca46eSDavid Howells #define N_DRELOFF(x) (N_TRELOFF(x) + N_TRSIZE(x))
100607ca46eSDavid Howells #endif
101607ca46eSDavid Howells 
102607ca46eSDavid Howells #if !defined (N_SYMOFF)
103607ca46eSDavid Howells #define N_SYMOFF(x) (N_DRELOFF(x) + N_DRSIZE(x))
104607ca46eSDavid Howells #endif
105607ca46eSDavid Howells 
106607ca46eSDavid Howells #if !defined (N_STROFF)
107607ca46eSDavid Howells #define N_STROFF(x) (N_SYMOFF(x) + N_SYMSIZE(x))
108607ca46eSDavid Howells #endif
109607ca46eSDavid Howells 
110607ca46eSDavid Howells /* Address of text segment in memory after it is loaded.  */
111607ca46eSDavid Howells #if !defined (N_TXTADDR)
112607ca46eSDavid Howells #define N_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? PAGE_SIZE : 0)
113607ca46eSDavid Howells #endif
114607ca46eSDavid Howells 
115*fbd57629SZack Weinberg /* Address of data segment in memory after it is loaded. */
116607ca46eSDavid Howells #ifndef __KERNEL__
117607ca46eSDavid Howells #include <unistd.h>
118607ca46eSDavid Howells #endif
119607ca46eSDavid Howells #if defined(__i386__) || defined(__mc68000__)
120607ca46eSDavid Howells #define SEGMENT_SIZE	1024
121607ca46eSDavid Howells #else
122607ca46eSDavid Howells #ifndef SEGMENT_SIZE
123607ca46eSDavid Howells #ifndef __KERNEL__
124607ca46eSDavid Howells #define SEGMENT_SIZE   getpagesize()
125607ca46eSDavid Howells #endif
126607ca46eSDavid Howells #endif
127607ca46eSDavid Howells #endif
128607ca46eSDavid Howells 
129607ca46eSDavid Howells #define _N_SEGMENT_ROUND(x) ALIGN(x, SEGMENT_SIZE)
130607ca46eSDavid Howells 
131607ca46eSDavid Howells #define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
132607ca46eSDavid Howells 
133607ca46eSDavid Howells #ifndef N_DATADDR
134607ca46eSDavid Howells #define N_DATADDR(x) \
135607ca46eSDavid Howells     (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
136607ca46eSDavid Howells      : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
137607ca46eSDavid Howells #endif
138607ca46eSDavid Howells 
139607ca46eSDavid Howells /* Address of bss segment in memory after it is loaded.  */
140607ca46eSDavid Howells #if !defined (N_BSSADDR)
141607ca46eSDavid Howells #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
142607ca46eSDavid Howells #endif
143607ca46eSDavid Howells 
144607ca46eSDavid Howells #if !defined (N_NLIST_DECLARED)
145607ca46eSDavid Howells struct nlist {
146607ca46eSDavid Howells   union {
147607ca46eSDavid Howells     char *n_name;
148607ca46eSDavid Howells     struct nlist *n_next;
149607ca46eSDavid Howells     long n_strx;
150607ca46eSDavid Howells   } n_un;
151607ca46eSDavid Howells   unsigned char n_type;
152607ca46eSDavid Howells   char n_other;
153607ca46eSDavid Howells   short n_desc;
154607ca46eSDavid Howells   unsigned long n_value;
155607ca46eSDavid Howells };
156607ca46eSDavid Howells #endif /* no N_NLIST_DECLARED.  */
157607ca46eSDavid Howells 
158607ca46eSDavid Howells #if !defined (N_UNDF)
159607ca46eSDavid Howells #define N_UNDF 0
160607ca46eSDavid Howells #endif
161607ca46eSDavid Howells #if !defined (N_ABS)
162607ca46eSDavid Howells #define N_ABS 2
163607ca46eSDavid Howells #endif
164607ca46eSDavid Howells #if !defined (N_TEXT)
165607ca46eSDavid Howells #define N_TEXT 4
166607ca46eSDavid Howells #endif
167607ca46eSDavid Howells #if !defined (N_DATA)
168607ca46eSDavid Howells #define N_DATA 6
169607ca46eSDavid Howells #endif
170607ca46eSDavid Howells #if !defined (N_BSS)
171607ca46eSDavid Howells #define N_BSS 8
172607ca46eSDavid Howells #endif
173607ca46eSDavid Howells #if !defined (N_FN)
174607ca46eSDavid Howells #define N_FN 15
175607ca46eSDavid Howells #endif
176607ca46eSDavid Howells 
177607ca46eSDavid Howells #if !defined (N_EXT)
178607ca46eSDavid Howells #define N_EXT 1
179607ca46eSDavid Howells #endif
180607ca46eSDavid Howells #if !defined (N_TYPE)
181607ca46eSDavid Howells #define N_TYPE 036
182607ca46eSDavid Howells #endif
183607ca46eSDavid Howells #if !defined (N_STAB)
184607ca46eSDavid Howells #define N_STAB 0340
185607ca46eSDavid Howells #endif
186607ca46eSDavid Howells 
187607ca46eSDavid Howells /* The following type indicates the definition of a symbol as being
188607ca46eSDavid Howells    an indirect reference to another symbol.  The other symbol
189607ca46eSDavid Howells    appears as an undefined reference, immediately following this symbol.
190607ca46eSDavid Howells 
191607ca46eSDavid Howells    Indirection is asymmetrical.  The other symbol's value will be used
192607ca46eSDavid Howells    to satisfy requests for the indirect symbol, but not vice versa.
193607ca46eSDavid Howells    If the other symbol does not have a definition, libraries will
194607ca46eSDavid Howells    be searched to find a definition.  */
195607ca46eSDavid Howells #define N_INDR 0xa
196607ca46eSDavid Howells 
197607ca46eSDavid Howells /* The following symbols refer to set elements.
198607ca46eSDavid Howells    All the N_SET[ATDB] symbols with the same name form one set.
199607ca46eSDavid Howells    Space is allocated for the set in the text section, and each set
200607ca46eSDavid Howells    element's value is stored into one word of the space.
201607ca46eSDavid Howells    The first word of the space is the length of the set (number of elements).
202607ca46eSDavid Howells 
203607ca46eSDavid Howells    The address of the set is made into an N_SETV symbol
204607ca46eSDavid Howells    whose name is the same as the name of the set.
205607ca46eSDavid Howells    This symbol acts like a N_DATA global symbol
206607ca46eSDavid Howells    in that it can satisfy undefined external references.  */
207607ca46eSDavid Howells 
208607ca46eSDavid Howells /* These appear as input to LD, in a .o file.  */
209607ca46eSDavid Howells #define	N_SETA	0x14		/* Absolute set element symbol */
210607ca46eSDavid Howells #define	N_SETT	0x16		/* Text set element symbol */
211607ca46eSDavid Howells #define	N_SETD	0x18		/* Data set element symbol */
212607ca46eSDavid Howells #define	N_SETB	0x1A		/* Bss set element symbol */
213607ca46eSDavid Howells 
214607ca46eSDavid Howells /* This is output from LD.  */
215607ca46eSDavid Howells #define N_SETV	0x1C		/* Pointer to set vector in data area.  */
216607ca46eSDavid Howells 
217607ca46eSDavid Howells #if !defined (N_RELOCATION_INFO_DECLARED)
218607ca46eSDavid Howells /* This structure describes a single relocation to be performed.
219607ca46eSDavid Howells    The text-relocation section of the file is a vector of these structures,
220607ca46eSDavid Howells    all of which apply to the text section.
221607ca46eSDavid Howells    Likewise, the data-relocation section applies to the data section.  */
222607ca46eSDavid Howells 
223607ca46eSDavid Howells struct relocation_info
224607ca46eSDavid Howells {
225607ca46eSDavid Howells   /* Address (within segment) to be relocated.  */
226607ca46eSDavid Howells   int r_address;
227607ca46eSDavid Howells   /* The meaning of r_symbolnum depends on r_extern.  */
228607ca46eSDavid Howells   unsigned int r_symbolnum:24;
229607ca46eSDavid Howells   /* Nonzero means value is a pc-relative offset
230607ca46eSDavid Howells      and it should be relocated for changes in its own address
231607ca46eSDavid Howells      as well as for changes in the symbol or section specified.  */
232607ca46eSDavid Howells   unsigned int r_pcrel:1;
233607ca46eSDavid Howells   /* Length (as exponent of 2) of the field to be relocated.
234607ca46eSDavid Howells      Thus, a value of 2 indicates 1<<2 bytes.  */
235607ca46eSDavid Howells   unsigned int r_length:2;
236607ca46eSDavid Howells   /* 1 => relocate with value of symbol.
237607ca46eSDavid Howells           r_symbolnum is the index of the symbol
238607ca46eSDavid Howells 	  in file's the symbol table.
239607ca46eSDavid Howells      0 => relocate with the address of a segment.
240607ca46eSDavid Howells           r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
241607ca46eSDavid Howells 	  (the N_EXT bit may be set also, but signifies nothing).  */
242607ca46eSDavid Howells   unsigned int r_extern:1;
243607ca46eSDavid Howells   /* Four bits that aren't used, but when writing an object file
244607ca46eSDavid Howells      it is desirable to clear them.  */
245607ca46eSDavid Howells   unsigned int r_pad:4;
246607ca46eSDavid Howells };
247607ca46eSDavid Howells #endif /* no N_RELOCATION_INFO_DECLARED.  */
248607ca46eSDavid Howells 
249607ca46eSDavid Howells #endif /*__ASSEMBLY__ */
250607ca46eSDavid Howells #endif /* _UAPI__A_OUT_GNU_H__ */
251