a.out.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. #ifndef __A_OUT_GNU_H__
  2. #define __A_OUT_GNU_H__
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #define __GNU_EXEC_MACROS__
  7. #ifndef __STRUCT_EXEC_OVERRIDE__
  8. struct exec
  9. {
  10. unsigned long a_info; /* Use macros N_MAGIC, etc for access */
  11. unsigned a_text; /* size of text, in bytes */
  12. unsigned a_data; /* size of data, in bytes */
  13. unsigned a_bss; /* size of uninitialized data area, in bytes */
  14. unsigned a_syms; /* length of symbol table data, in bytes */
  15. unsigned a_entry; /* start address */
  16. unsigned a_trsize; /* size of reloc info for text, in bytes */
  17. unsigned a_drsize; /* size of reloc info for data, in bytes */
  18. #if defined (sequent) && defined (i386)
  19. struct gdtbl
  20. { /* Global Descriptor Table */
  21. unsigned g_code[2];
  22. unsigned g_data[2];
  23. unsigned g_desc[2];
  24. } a_gdtbl;
  25. unsigned a_shdata; /* size of initialized shared data */
  26. unsigned a_shbss; /* size of uninitialized shared data */
  27. unsigned a_shdrsize; /* size of shared data relocation */
  28. unsigned a_bootstrap[11]; /* bootstrap for standalone */
  29. unsigned a_reserved[3]; /* reserved for future use */
  30. unsigned a_version; /* object version */
  31. #endif /* Sequent Symmetry, Dynix 3.x */
  32. };
  33. #endif /* __STRUCT_EXEC_OVERRIDE__ */
  34. /* these go in the N_MACHTYPE field */
  35. enum machine_type {
  36. #if defined (M_OLDSUN2)
  37. M__OLDSUN2 = M_OLDSUN2,
  38. #else
  39. M_OLDSUN2 = 0,
  40. #endif
  41. #if defined (M_68010)
  42. M__68010 = M_68010,
  43. #else
  44. M_68010 = 1,
  45. #endif
  46. #if defined (M_68020)
  47. M__68020 = M_68020,
  48. #else
  49. M_68020 = 2,
  50. #endif
  51. #if defined (M_SPARC)
  52. M__SPARC = M_SPARC,
  53. #else
  54. M_SPARC = 3,
  55. #endif
  56. /* skip a bunch so we don't run into any of sun's numbers */
  57. M_386 = 100
  58. };
  59. #if defined (sequent) && defined (i386)
  60. /* Dynix 3 wants the magic number to be the whole first longword. */
  61. #define N_MAGIC(exec) ((exec).a_info)
  62. #define N_MACHTYPE(exec) 0
  63. #define N_FLAGS(exec) 0
  64. #define N_SET_INFO(exec, magic, type, flags) N_SET_MAGIC ((exec), (magic))
  65. #define N_SET_MAGIC(exec, magic) ((exec).a_info = (magic))
  66. #define N_SET_MACHTYPE(exec, machtype) ((void) 0)
  67. #define N_SET_FLAGS(exec, flags) ((void) 0)
  68. #define OMAGIC 0x12eb /* impure format - for .o's */
  69. #define ZMAGIC 0x22eb /* demand load format - zero at zero */
  70. #define NMAGIC you lose /* syntax error -- no pure format */
  71. #define N_BADMAG(x) (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != ZMAGIC)
  72. #define N_ADDRADJ(x) (N_MAGIC(x) == ZMAGIC ? SEGMENT_SIZE : 0)
  73. #define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text - N_ADDRADJ(x))
  74. #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data + (x).a_shdata)
  75. #define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize + (x).a_shdrsize)
  76. #define N_TXTADDR(x) SEGMENT_SIZE
  77. #define N_COMM 0x0a /** conflicts with N_INDR **/
  78. #define N_FN 0x0c
  79. /* Note that the Dynix binutils believe that N_SET[TDB] are
  80. N_SH{DATA,BSS,COMM} -- be wary when mixing GNU & Dynix objects. */
  81. #define PAGE_SIZE 4096
  82. #define SEGMENT_SIZE PAGE_SIZE
  83. #else /* !(sequent && i386) */
  84. #if !defined (N_MAGIC)
  85. #define N_MAGIC(exec) ((exec).a_info & 0xffff)
  86. #endif
  87. #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
  88. #define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
  89. #define N_SET_INFO(exec, magic, type, flags) \
  90. ((exec).a_info = ((magic) & 0xffff) \
  91. | (((int)(type) & 0xff) << 16) \
  92. | (((flags) & 0xff) << 24))
  93. #define N_SET_MAGIC(exec, magic) \
  94. ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
  95. #define N_SET_MACHTYPE(exec, machtype) \
  96. ((exec).a_info = \
  97. ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
  98. #define N_SET_FLAGS(exec, flags) \
  99. ((exec).a_info = \
  100. ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
  101. #endif /* sequent && i386 */
  102. #ifndef OMAGIC
  103. /* Code indicating object file or impure executable. */
  104. #define OMAGIC 0407
  105. /* Code indicating pure executable. */
  106. #define NMAGIC 0410
  107. /* Code indicating demand-paged executable. */
  108. #define ZMAGIC 0413
  109. #endif /* not OMAGIC */
  110. #if !defined (N_BADMAG)
  111. #define N_BADMAG(x) \
  112. (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \
  113. && N_MAGIC(x) != ZMAGIC)
  114. #endif
  115. #define _N_BADMAG(x) \
  116. (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \
  117. && N_MAGIC(x) != ZMAGIC)
  118. #ifndef sparc
  119. #define _N_HDROFF(x) (SEGMENT_SIZE - sizeof (struct exec))
  120. #else
  121. #define _N_HDROFF(x) (- sizeof (struct exec))
  122. #endif
  123. #if !defined (N_TXTOFF)
  124. #define N_TXTOFF(x) \
  125. (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : sizeof (struct exec))
  126. #endif
  127. #if !defined (N_DATOFF)
  128. #define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
  129. #endif
  130. #if !defined (N_TRELOFF)
  131. #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
  132. #endif
  133. #if !defined (N_DRELOFF)
  134. #define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)
  135. #endif
  136. #if !defined (N_SYMOFF)
  137. #define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize)
  138. #endif
  139. #if !defined (N_STROFF)
  140. #define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms)
  141. #endif
  142. /* Address of text segment in memory after it is loaded. */
  143. #if !defined (N_TXTADDR)
  144. #define N_TXTADDR(x) 0
  145. #endif
  146. /* Address of data segment in memory after it is loaded.
  147. Note that it is up to you to define SEGMENT_SIZE
  148. on machines not listed here. */
  149. #if defined (hp300) || defined (mips)
  150. #define PAGE_SIZE 4096
  151. #endif
  152. #if defined (sparc) || defined (NeXT)
  153. #define PAGE_SIZE 0x2000
  154. #endif
  155. #if defined (sony) || (defined (sun) && defined (mc68000))
  156. #define SEGMENT_SIZE 0x2000
  157. #endif /* Sony or 68k Sun. */
  158. #ifdef is68k
  159. #define SEGMENT_SIZE 0x20000
  160. #endif
  161. #if defined(m68k) && defined(PORTAR)
  162. #define PAGE_SIZE 0x400
  163. #endif
  164. #if defined(i386) && !defined(sequent)
  165. /* For COFF encapsulation. */
  166. #define SEGMENT_SIZE 0x400000
  167. #endif
  168. #ifndef SEGMENT_SIZE
  169. /* This used to be first in this paragraph and under:
  170. if (defined(vax) || defined(hp300) || defined(pyr) || defined(sparc) \
  171. || (defined(m68k) && defined(PORTAR)) \
  172. || defined (NeXT) || defined (mips)) */
  173. #define SEGMENT_SIZE PAGE_SIZE
  174. #endif
  175. #ifndef PAGE_SIZE
  176. /* This value is for i386-minix, but that has no predefine.
  177. Making it default will only cause confusion on machines
  178. which have no proper value defined. */
  179. #define PAGE_SIZE 16
  180. #endif
  181. #define PAGSIZ PAGE_SIZE
  182. #define SEGSIZ SEGMENT_SIZE
  183. #define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
  184. #define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
  185. #ifndef N_DATADDR
  186. #define N_DATADDR(x) \
  187. (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
  188. : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
  189. #endif
  190. /* Address of bss segment in memory after it is loaded. */
  191. #if !defined (N_BSSADDR)
  192. #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
  193. #endif
  194. #if !defined (N_NLIST_DECLARED)
  195. struct nlist {
  196. union {
  197. char *n_name;
  198. struct nlist *n_next;
  199. long n_strx;
  200. } n_un;
  201. unsigned char n_type;
  202. char n_other;
  203. short n_desc;
  204. unsigned long n_value;
  205. };
  206. #endif /* no N_NLIST_DECLARED. */
  207. #if !defined (N_UNDF)
  208. #define N_UNDF 0
  209. #endif
  210. #if !defined (N_ABS)
  211. #define N_ABS 2
  212. #endif
  213. #if !defined (N_TEXT)
  214. #define N_TEXT 4
  215. #endif
  216. #if !defined (N_DATA)
  217. #define N_DATA 6
  218. #endif
  219. #if !defined (N_BSS)
  220. #define N_BSS 8
  221. #endif
  222. #if !defined (N_COMM)
  223. #define N_COMM 18
  224. #endif
  225. #if !defined (N_FN)
  226. #define N_FN 15
  227. #endif
  228. #if !defined (N_EXT)
  229. #define N_EXT 1
  230. #endif
  231. #if !defined (N_TYPE)
  232. #define N_TYPE 036
  233. #endif
  234. #if !defined (N_STAB)
  235. #define N_STAB 0340
  236. #endif
  237. /* The following type indicates the definition of a symbol as being
  238. an indirect reference to another symbol. The other symbol
  239. appears as an undefined reference, immediately following this symbol.
  240. Indirection is asymmetrical. The other symbol's value will be used
  241. to satisfy requests for the indirect symbol, but not vice versa.
  242. If the other symbol does not have a definition, libraries will
  243. be searched to find a definition. */
  244. #define N_INDR 0xa
  245. /* The following symbols refer to set elements.
  246. All the N_SET[ATDB] symbols with the same name form one set.
  247. Space is allocated for the set in the text section, and each set
  248. element's value is stored into one word of the space.
  249. The first word of the space is the length of the set (number of elements).
  250. The address of the set is made into an N_SETV symbol
  251. whose name is the same as the name of the set.
  252. This symbol acts like a N_DATA global symbol
  253. in that it can satisfy undefined external references. */
  254. /* These appear as input to LD, in a .o file. */
  255. #define N_SETA 0x14 /* Absolute set element symbol */
  256. #define N_SETT 0x16 /* Text set element symbol */
  257. #define N_SETD 0x18 /* Data set element symbol */
  258. #define N_SETB 0x1A /* Bss set element symbol */
  259. /* This is output from LD. */
  260. #define N_SETV 0x1C /* Pointer to set vector in data area. */
  261. #if !defined (N_RELOCATION_INFO_DECLARED)
  262. /* This structure describes a single relocation to be performed.
  263. The text-relocation section of the file is a vector of these structures,
  264. all of which apply to the text section.
  265. Likewise, the data-relocation section applies to the data section. */
  266. struct relocation_info
  267. {
  268. /* Address (within segment) to be relocated. */
  269. int r_address;
  270. /* The meaning of r_symbolnum depends on r_extern. */
  271. unsigned int r_symbolnum:24;
  272. /* Nonzero means value is a pc-relative offset
  273. and it should be relocated for changes in its own address
  274. as well as for changes in the symbol or section specified. */
  275. unsigned int r_pcrel:1;
  276. /* Length (as exponent of 2) of the field to be relocated.
  277. Thus, a value of 2 indicates 1<<2 bytes. */
  278. unsigned int r_length:2;
  279. /* 1 => relocate with value of symbol.
  280. r_symbolnum is the index of the symbol
  281. in file's the symbol table.
  282. 0 => relocate with the address of a segment.
  283. r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
  284. (the N_EXT bit may be set also, but signifies nothing). */
  285. unsigned int r_extern:1;
  286. /* Four bits that aren't used, but when writing an object file
  287. it is desirable to clear them. */
  288. unsigned int r_pad:4;
  289. };
  290. #endif /* no N_RELOCATION_INFO_DECLARED. */
  291. #ifdef __cplusplus
  292. }
  293. #endif
  294. #endif /* __A_OUT_GNU_H__ */