a.out.h 6.8 KB

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