a.out_x86.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef __A_OUT_GNU_H__
  3. #define __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. #include <unistd.h>
  97. #if defined(__i386__) || defined(__mc68000__)
  98. #define SEGMENT_SIZE 1024
  99. #else
  100. #ifndef SEGMENT_SIZE
  101. #define SEGMENT_SIZE getpagesize()
  102. #endif
  103. #endif
  104. #define _N_SEGMENT_ROUND(x) ALIGN(x, SEGMENT_SIZE)
  105. #define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
  106. #ifndef N_DATADDR
  107. #define N_DATADDR(x) \
  108. (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
  109. : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
  110. #endif
  111. /* Address of bss segment in memory after it is loaded. */
  112. #if !defined (N_BSSADDR)
  113. #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
  114. #endif
  115. #if !defined (N_NLIST_DECLARED)
  116. struct nlist {
  117. union {
  118. char *n_name;
  119. struct nlist *n_next;
  120. long n_strx;
  121. } n_un;
  122. unsigned char n_type;
  123. char n_other;
  124. short n_desc;
  125. unsigned long n_value;
  126. };
  127. #endif /* no N_NLIST_DECLARED. */
  128. #if !defined (N_UNDF)
  129. #define N_UNDF 0
  130. #endif
  131. #if !defined (N_ABS)
  132. #define N_ABS 2
  133. #endif
  134. #if !defined (N_TEXT)
  135. #define N_TEXT 4
  136. #endif
  137. #if !defined (N_DATA)
  138. #define N_DATA 6
  139. #endif
  140. #if !defined (N_BSS)
  141. #define N_BSS 8
  142. #endif
  143. #if !defined (N_FN)
  144. #define N_FN 15
  145. #endif
  146. #if !defined (N_EXT)
  147. #define N_EXT 1
  148. #endif
  149. #if !defined (N_TYPE)
  150. #define N_TYPE 036
  151. #endif
  152. #if !defined (N_STAB)
  153. #define N_STAB 0340
  154. #endif
  155. /* The following type indicates the definition of a symbol as being
  156. an indirect reference to another symbol. The other symbol
  157. appears as an undefined reference, immediately following this symbol.
  158. Indirection is asymmetrical. The other symbol's value will be used
  159. to satisfy requests for the indirect symbol, but not vice versa.
  160. If the other symbol does not have a definition, libraries will
  161. be searched to find a definition. */
  162. #define N_INDR 0xa
  163. /* The following symbols refer to set elements.
  164. All the N_SET[ATDB] symbols with the same name form one set.
  165. Space is allocated for the set in the text section, and each set
  166. element's value is stored into one word of the space.
  167. The first word of the space is the length of the set (number of elements).
  168. The address of the set is made into an N_SETV symbol
  169. whose name is the same as the name of the set.
  170. This symbol acts like a N_DATA global symbol
  171. in that it can satisfy undefined external references. */
  172. /* These appear as input to LD, in a .o file. */
  173. #define N_SETA 0x14 /* Absolute set element symbol */
  174. #define N_SETT 0x16 /* Text set element symbol */
  175. #define N_SETD 0x18 /* Data set element symbol */
  176. #define N_SETB 0x1A /* Bss set element symbol */
  177. /* This is output from LD. */
  178. #define N_SETV 0x1C /* Pointer to set vector in data area. */
  179. #if !defined (N_RELOCATION_INFO_DECLARED)
  180. /* This structure describes a single relocation to be performed.
  181. The text-relocation section of the file is a vector of these structures,
  182. all of which apply to the text section.
  183. Likewise, the data-relocation section applies to the data section. */
  184. struct relocation_info
  185. {
  186. /* Address (within segment) to be relocated. */
  187. int r_address;
  188. /* The meaning of r_symbolnum depends on r_extern. */
  189. unsigned int r_symbolnum:24;
  190. /* Nonzero means value is a pc-relative offset
  191. and it should be relocated for changes in its own address
  192. as well as for changes in the symbol or section specified. */
  193. unsigned int r_pcrel:1;
  194. /* Length (as exponent of 2) of the field to be relocated.
  195. Thus, a value of 2 indicates 1<<2 bytes. */
  196. unsigned int r_length:2;
  197. /* 1 => relocate with value of symbol.
  198. r_symbolnum is the index of the symbol
  199. in file's the symbol table.
  200. 0 => relocate with the address of a segment.
  201. r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
  202. (the N_EXT bit may be set also, but signifies nothing). */
  203. unsigned int r_extern:1;
  204. /* Four bits that aren't used, but when writing an object file
  205. it is desirable to clear them. */
  206. unsigned int r_pad:4;
  207. };
  208. #endif /* no N_RELOCATION_INFO_DECLARED. */
  209. #endif /*__ASSEMBLY__ */
  210. #endif /* __A_OUT_GNU_H__ */