a.out.h 7.1 KB

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