1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef _UAPI__A_OUT_GNU_H__
3 #define _UAPI__A_OUT_GNU_H__
5 #define __GNU_EXEC_MACROS__
7 #ifndef __STRUCT_EXEC_OVERRIDE__
11 #endif /* __STRUCT_EXEC_OVERRIDE__ */
15 /* these go in the N_MACHTYPE field */
17 #if defined (M_OLDSUN2)
18 M__OLDSUN2
= M_OLDSUN2
,
37 /* skip a bunch so we don't run into any of sun's numbers */
39 M_MIPS1
= 151, /* MIPS R3000/R3000 binary */
40 M_MIPS2
= 152 /* MIPS R6000/R4000 binary */
43 #if !defined (N_MAGIC)
44 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
46 #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
47 #define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
48 #define N_SET_INFO(exec, magic, type, flags) \
49 ((exec).a_info = ((magic) & 0xffff) \
50 | (((int)(type) & 0xff) << 16) \
51 | (((flags) & 0xff) << 24))
52 #define N_SET_MAGIC(exec, magic) \
53 ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
55 #define N_SET_MACHTYPE(exec, machtype) \
57 ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
59 #define N_SET_FLAGS(exec, flags) \
61 ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
63 /* Code indicating object file or impure executable. */
65 /* Code indicating pure executable. */
67 /* Code indicating demand-paged executable. */
69 /* This indicates a demand-paged executable with the header in the text.
70 The first page is unmapped to help trap NULL pointer references */
73 /* Code indicating core file. */
76 #if !defined (N_BADMAG)
77 #define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \
78 && N_MAGIC(x) != NMAGIC \
79 && N_MAGIC(x) != ZMAGIC \
80 && N_MAGIC(x) != QMAGIC)
83 #define _N_HDROFF(x) (1024 - sizeof (struct exec))
85 #if !defined (N_TXTOFF)
87 (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : \
88 (N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec)))
91 #if !defined (N_DATOFF)
92 #define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
95 #if !defined (N_TRELOFF)
96 #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
99 #if !defined (N_DRELOFF)
100 #define N_DRELOFF(x) (N_TRELOFF(x) + N_TRSIZE(x))
103 #if !defined (N_SYMOFF)
104 #define N_SYMOFF(x) (N_DRELOFF(x) + N_DRSIZE(x))
107 #if !defined (N_STROFF)
108 #define N_STROFF(x) (N_SYMOFF(x) + N_SYMSIZE(x))
111 /* Address of text segment in memory after it is loaded. */
112 #if !defined (N_TXTADDR)
113 #define N_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? PAGE_SIZE : 0)
116 /* Address of data segment in memory after it is loaded. */
120 #if defined(__i386__) || defined(__mc68000__)
121 #define SEGMENT_SIZE 1024
125 #define SEGMENT_SIZE getpagesize()
130 #define _N_SEGMENT_ROUND(x) ALIGN(x, SEGMENT_SIZE)
132 #define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
135 #define N_DATADDR(x) \
136 (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
137 : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
140 /* Address of bss segment in memory after it is loaded. */
141 #if !defined (N_BSSADDR)
142 #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
145 #if !defined (N_NLIST_DECLARED)
149 struct nlist
*n_next
;
152 unsigned char n_type
;
155 unsigned long n_value
;
157 #endif /* no N_NLIST_DECLARED. */
159 #if !defined (N_UNDF)
165 #if !defined (N_TEXT)
168 #if !defined (N_DATA)
181 #if !defined (N_TYPE)
184 #if !defined (N_STAB)
188 /* The following type indicates the definition of a symbol as being
189 an indirect reference to another symbol. The other symbol
190 appears as an undefined reference, immediately following this symbol.
192 Indirection is asymmetrical. The other symbol's value will be used
193 to satisfy requests for the indirect symbol, but not vice versa.
194 If the other symbol does not have a definition, libraries will
195 be searched to find a definition. */
198 /* The following symbols refer to set elements.
199 All the N_SET[ATDB] symbols with the same name form one set.
200 Space is allocated for the set in the text section, and each set
201 element's value is stored into one word of the space.
202 The first word of the space is the length of the set (number of elements).
204 The address of the set is made into an N_SETV symbol
205 whose name is the same as the name of the set.
206 This symbol acts like a N_DATA global symbol
207 in that it can satisfy undefined external references. */
209 /* These appear as input to LD, in a .o file. */
210 #define N_SETA 0x14 /* Absolute set element symbol */
211 #define N_SETT 0x16 /* Text set element symbol */
212 #define N_SETD 0x18 /* Data set element symbol */
213 #define N_SETB 0x1A /* Bss set element symbol */
215 /* This is output from LD. */
216 #define N_SETV 0x1C /* Pointer to set vector in data area. */
218 #if !defined (N_RELOCATION_INFO_DECLARED)
219 /* This structure describes a single relocation to be performed.
220 The text-relocation section of the file is a vector of these structures,
221 all of which apply to the text section.
222 Likewise, the data-relocation section applies to the data section. */
224 struct relocation_info
226 /* Address (within segment) to be relocated. */
228 /* The meaning of r_symbolnum depends on r_extern. */
229 unsigned int r_symbolnum
:24;
230 /* Nonzero means value is a pc-relative offset
231 and it should be relocated for changes in its own address
232 as well as for changes in the symbol or section specified. */
233 unsigned int r_pcrel
:1;
234 /* Length (as exponent of 2) of the field to be relocated.
235 Thus, a value of 2 indicates 1<<2 bytes. */
236 unsigned int r_length
:2;
237 /* 1 => relocate with value of symbol.
238 r_symbolnum is the index of the symbol
239 in file's the symbol table.
240 0 => relocate with the address of a segment.
241 r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
242 (the N_EXT bit may be set also, but signifies nothing). */
243 unsigned int r_extern
:1;
244 /* Four bits that aren't used, but when writing an object file
245 it is desirable to clear them. */
246 unsigned int r_pad
:4;
248 #endif /* no N_RELOCATION_INFO_DECLARED. */
250 #endif /*__ASSEMBLY__ */
251 #endif /* _UAPI__A_OUT_GNU_H__ */