a.out.h 7.1 KB

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