a.out.h 7.3 KB

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