a.out.h 7.2 KB

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