alpha.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. /* ECOFF support on Alpha machines.
  2. coff/ecoff.h must be included before this file.
  3. Copyright (C) 2001-2015 Free Software Foundation, Inc.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  15. MA 02110-1301, USA. */
  16. /********************** FILE HEADER **********************/
  17. struct external_filehdr
  18. {
  19. unsigned char f_magic[2]; /* magic number */
  20. unsigned char f_nscns[2]; /* number of sections */
  21. unsigned char f_timdat[4]; /* time & date stamp */
  22. unsigned char f_symptr[8]; /* file pointer to symtab */
  23. unsigned char f_nsyms[4]; /* number of symtab entries */
  24. unsigned char f_opthdr[2]; /* sizeof(optional hdr) */
  25. unsigned char f_flags[2]; /* flags */
  26. };
  27. /* Magic numbers are defined in coff/ecoff.h. */
  28. #define ALPHA_ECOFF_BADMAG(x) \
  29. ((x).f_magic != ALPHA_MAGIC && (x).f_magic != ALPHA_MAGIC_BSD)
  30. #define ALPHA_ECOFF_COMPRESSEDMAG(x) \
  31. ((x).f_magic == ALPHA_MAGIC_COMPRESSED)
  32. /* The object type is encoded in the f_flags. */
  33. #define F_ALPHA_OBJECT_TYPE_MASK 0x3000
  34. #define F_ALPHA_NO_SHARED 0x1000
  35. #define F_ALPHA_SHARABLE 0x2000
  36. #define F_ALPHA_CALL_SHARED 0x3000
  37. #define FILHDR struct external_filehdr
  38. #define FILHSZ 24
  39. /********************** AOUT "OPTIONAL HEADER" **********************/
  40. typedef struct external_aouthdr
  41. {
  42. unsigned char magic[2]; /* type of file */
  43. unsigned char vstamp[2]; /* version stamp */
  44. unsigned char bldrev[2]; /* ?? */
  45. unsigned char padding[2]; /* pad to quadword boundary */
  46. unsigned char tsize[8]; /* text size in bytes */
  47. unsigned char dsize[8]; /* initialized data " " */
  48. unsigned char bsize[8]; /* uninitialized data " " */
  49. unsigned char entry[8]; /* entry pt. */
  50. unsigned char text_start[8]; /* base of text used for this file */
  51. unsigned char data_start[8]; /* base of data used for this file */
  52. unsigned char bss_start[8]; /* base of bss used for this file */
  53. unsigned char gprmask[4]; /* bitmask of general registers used */
  54. unsigned char fprmask[4]; /* bitmask of floating point registers used */
  55. unsigned char gp_value[8]; /* value for gp register */
  56. } AOUTHDR;
  57. /* compute size of a header */
  58. #define AOUTSZ 80
  59. #define AOUTHDRSZ 80
  60. /********************** SECTION HEADER **********************/
  61. struct external_scnhdr
  62. {
  63. unsigned char s_name[8]; /* section name */
  64. unsigned char s_paddr[8]; /* physical address, aliased s_nlib */
  65. unsigned char s_vaddr[8]; /* virtual address */
  66. unsigned char s_size[8]; /* section size */
  67. unsigned char s_scnptr[8]; /* file ptr to raw data for section */
  68. unsigned char s_relptr[8]; /* file ptr to relocation */
  69. unsigned char s_lnnoptr[8]; /* file ptr to line numbers */
  70. unsigned char s_nreloc[2]; /* number of relocation entries */
  71. unsigned char s_nlnno[2]; /* number of line number entries*/
  72. unsigned char s_flags[4]; /* flags */
  73. };
  74. #define SCNHDR struct external_scnhdr
  75. #define SCNHSZ 64
  76. /********************** RELOCATION DIRECTIVES **********************/
  77. struct external_reloc
  78. {
  79. unsigned char r_vaddr[8];
  80. unsigned char r_symndx[4];
  81. unsigned char r_bits[4];
  82. };
  83. #define RELOC struct external_reloc
  84. #define RELSZ 16
  85. /* Constants to unpack the r_bits field. The Alpha seems to always be
  86. little endian, so I haven't bothered to define big endian variants
  87. of these. */
  88. #define RELOC_BITS0_TYPE_LITTLE 0xff
  89. #define RELOC_BITS0_TYPE_SH_LITTLE 0
  90. #define RELOC_BITS1_EXTERN_LITTLE 0x01
  91. #define RELOC_BITS1_OFFSET_LITTLE 0x7e
  92. #define RELOC_BITS1_OFFSET_SH_LITTLE 1
  93. #define RELOC_BITS1_RESERVED_LITTLE 0x80
  94. #define RELOC_BITS1_RESERVED_SH_LITTLE 7
  95. #define RELOC_BITS2_RESERVED_LITTLE 0xff
  96. #define RELOC_BITS2_RESERVED_SH_LEFT_LITTLE 1
  97. #define RELOC_BITS3_RESERVED_LITTLE 0x03
  98. #define RELOC_BITS3_RESERVED_SH_LEFT_LITTLE 9
  99. #define RELOC_BITS3_SIZE_LITTLE 0xfc
  100. #define RELOC_BITS3_SIZE_SH_LITTLE 2
  101. /* The r_type field in a reloc is one of the following values. */
  102. #define ALPHA_R_IGNORE 0
  103. #define ALPHA_R_REFLONG 1
  104. #define ALPHA_R_REFQUAD 2
  105. #define ALPHA_R_GPREL32 3
  106. #define ALPHA_R_LITERAL 4
  107. #define ALPHA_R_LITUSE 5
  108. #define ALPHA_R_GPDISP 6
  109. #define ALPHA_R_BRADDR 7
  110. #define ALPHA_R_HINT 8
  111. #define ALPHA_R_SREL16 9
  112. #define ALPHA_R_SREL32 10
  113. #define ALPHA_R_SREL64 11
  114. #define ALPHA_R_OP_PUSH 12
  115. #define ALPHA_R_OP_STORE 13
  116. #define ALPHA_R_OP_PSUB 14
  117. #define ALPHA_R_OP_PRSHIFT 15
  118. #define ALPHA_R_GPVALUE 16
  119. #define ALPHA_R_GPRELHIGH 17
  120. #define ALPHA_R_GPRELLOW 18
  121. #define ALPHA_R_IMMED 19
  122. /* Overloaded reloc value used by Net- and OpenBSD. */
  123. #define ALPHA_R_LITERALSLEAZY 17
  124. /* With ALPHA_R_LITUSE, the r_size field is one of the following values. */
  125. #define ALPHA_R_LU_BASE 1
  126. #define ALPHA_R_LU_BYTOFF 2
  127. #define ALPHA_R_LU_JSR 3
  128. /* With ALPHA_R_IMMED, the r_size field is one of the following values. */
  129. #define ALPHA_R_IMMED_GP_16 1
  130. #define ALPHA_R_IMMED_GP_HI32 2
  131. #define ALPHA_R_IMMED_SCN_HI32 3
  132. #define ALPHA_R_IMMED_BR_HI32 4
  133. #define ALPHA_R_IMMED_LO32 5
  134. /********************** SYMBOLIC INFORMATION **********************/
  135. /* Written by John Gilmore. */
  136. /* ECOFF uses COFF-like section structures, but its own symbol format.
  137. This file defines the symbol format in fields whose size and alignment
  138. will not vary on different host systems. */
  139. /* File header as a set of bytes */
  140. struct hdr_ext
  141. {
  142. unsigned char h_magic[2];
  143. unsigned char h_vstamp[2];
  144. unsigned char h_ilineMax[4];
  145. unsigned char h_idnMax[4];
  146. unsigned char h_ipdMax[4];
  147. unsigned char h_isymMax[4];
  148. unsigned char h_ioptMax[4];
  149. unsigned char h_iauxMax[4];
  150. unsigned char h_issMax[4];
  151. unsigned char h_issExtMax[4];
  152. unsigned char h_ifdMax[4];
  153. unsigned char h_crfd[4];
  154. unsigned char h_iextMax[4];
  155. unsigned char h_cbLine[8];
  156. unsigned char h_cbLineOffset[8];
  157. unsigned char h_cbDnOffset[8];
  158. unsigned char h_cbPdOffset[8];
  159. unsigned char h_cbSymOffset[8];
  160. unsigned char h_cbOptOffset[8];
  161. unsigned char h_cbAuxOffset[8];
  162. unsigned char h_cbSsOffset[8];
  163. unsigned char h_cbSsExtOffset[8];
  164. unsigned char h_cbFdOffset[8];
  165. unsigned char h_cbRfdOffset[8];
  166. unsigned char h_cbExtOffset[8];
  167. };
  168. /* File descriptor external record */
  169. struct fdr_ext
  170. {
  171. unsigned char f_adr[8];
  172. unsigned char f_cbLineOffset[8];
  173. unsigned char f_cbLine[8];
  174. unsigned char f_cbSs[8];
  175. unsigned char f_rss[4];
  176. unsigned char f_issBase[4];
  177. unsigned char f_isymBase[4];
  178. unsigned char f_csym[4];
  179. unsigned char f_ilineBase[4];
  180. unsigned char f_cline[4];
  181. unsigned char f_ioptBase[4];
  182. unsigned char f_copt[4];
  183. unsigned char f_ipdFirst[4];
  184. unsigned char f_cpd[4];
  185. unsigned char f_iauxBase[4];
  186. unsigned char f_caux[4];
  187. unsigned char f_rfdBase[4];
  188. unsigned char f_crfd[4];
  189. unsigned char f_bits1[1];
  190. unsigned char f_bits2[3];
  191. unsigned char f_padding[4];
  192. };
  193. #define FDR_BITS1_LANG_BIG 0xF8
  194. #define FDR_BITS1_LANG_SH_BIG 3
  195. #define FDR_BITS1_LANG_LITTLE 0x1F
  196. #define FDR_BITS1_LANG_SH_LITTLE 0
  197. #define FDR_BITS1_FMERGE_BIG 0x04
  198. #define FDR_BITS1_FMERGE_LITTLE 0x20
  199. #define FDR_BITS1_FREADIN_BIG 0x02
  200. #define FDR_BITS1_FREADIN_LITTLE 0x40
  201. #define FDR_BITS1_FBIGENDIAN_BIG 0x01
  202. #define FDR_BITS1_FBIGENDIAN_LITTLE 0x80
  203. #define FDR_BITS2_GLEVEL_BIG 0xC0
  204. #define FDR_BITS2_GLEVEL_SH_BIG 6
  205. #define FDR_BITS2_GLEVEL_LITTLE 0x03
  206. #define FDR_BITS2_GLEVEL_SH_LITTLE 0
  207. /* We ignore the `reserved' field in bits2. */
  208. /* Procedure descriptor external record */
  209. struct pdr_ext {
  210. unsigned char p_adr[8];
  211. unsigned char p_cbLineOffset[8];
  212. unsigned char p_isym[4];
  213. unsigned char p_iline[4];
  214. unsigned char p_regmask[4];
  215. unsigned char p_regoffset[4];
  216. unsigned char p_iopt[4];
  217. unsigned char p_fregmask[4];
  218. unsigned char p_fregoffset[4];
  219. unsigned char p_frameoffset[4];
  220. unsigned char p_lnLow[4];
  221. unsigned char p_lnHigh[4];
  222. unsigned char p_gp_prologue[1];
  223. unsigned char p_bits1[1];
  224. unsigned char p_bits2[1];
  225. unsigned char p_localoff[1];
  226. unsigned char p_framereg[2];
  227. unsigned char p_pcreg[2];
  228. };
  229. #define PDR_BITS1_GP_USED_BIG 0x80
  230. #define PDR_BITS1_REG_FRAME_BIG 0x40
  231. #define PDR_BITS1_PROF_BIG 0x20
  232. #define PDR_BITS1_RESERVED_BIG 0x1f
  233. #define PDR_BITS1_RESERVED_SH_LEFT_BIG 8
  234. #define PDR_BITS2_RESERVED_BIG 0xff
  235. #define PDR_BITS2_RESERVED_SH_BIG 0
  236. #define PDR_BITS1_GP_USED_LITTLE 0x01
  237. #define PDR_BITS1_REG_FRAME_LITTLE 0x02
  238. #define PDR_BITS1_PROF_LITTLE 0x04
  239. #define PDR_BITS1_RESERVED_LITTLE 0xf8
  240. #define PDR_BITS1_RESERVED_SH_LITTLE 3
  241. #define PDR_BITS2_RESERVED_LITTLE 0xff
  242. #define PDR_BITS2_RESERVED_SH_LEFT_LITTLE 5
  243. /* Line numbers */
  244. struct line_ext {
  245. unsigned char l_line[4];
  246. };
  247. /* Symbol external record */
  248. struct sym_ext {
  249. unsigned char s_value[8];
  250. unsigned char s_iss[4];
  251. unsigned char s_bits1[1];
  252. unsigned char s_bits2[1];
  253. unsigned char s_bits3[1];
  254. unsigned char s_bits4[1];
  255. };
  256. #define SYM_BITS1_ST_BIG 0xFC
  257. #define SYM_BITS1_ST_SH_BIG 2
  258. #define SYM_BITS1_ST_LITTLE 0x3F
  259. #define SYM_BITS1_ST_SH_LITTLE 0
  260. #define SYM_BITS1_SC_BIG 0x03
  261. #define SYM_BITS1_SC_SH_LEFT_BIG 3
  262. #define SYM_BITS1_SC_LITTLE 0xC0
  263. #define SYM_BITS1_SC_SH_LITTLE 6
  264. #define SYM_BITS2_SC_BIG 0xE0
  265. #define SYM_BITS2_SC_SH_BIG 5
  266. #define SYM_BITS2_SC_LITTLE 0x07
  267. #define SYM_BITS2_SC_SH_LEFT_LITTLE 2
  268. #define SYM_BITS2_RESERVED_BIG 0x10
  269. #define SYM_BITS2_RESERVED_LITTLE 0x08
  270. #define SYM_BITS2_INDEX_BIG 0x0F
  271. #define SYM_BITS2_INDEX_SH_LEFT_BIG 16
  272. #define SYM_BITS2_INDEX_LITTLE 0xF0
  273. #define SYM_BITS2_INDEX_SH_LITTLE 4
  274. #define SYM_BITS3_INDEX_SH_LEFT_BIG 8
  275. #define SYM_BITS3_INDEX_SH_LEFT_LITTLE 4
  276. #define SYM_BITS4_INDEX_SH_LEFT_BIG 0
  277. #define SYM_BITS4_INDEX_SH_LEFT_LITTLE 12
  278. /* External symbol external record */
  279. struct ext_ext {
  280. struct sym_ext es_asym;
  281. unsigned char es_bits1[1];
  282. unsigned char es_bits2[3];
  283. unsigned char es_ifd[4];
  284. };
  285. #define EXT_BITS1_JMPTBL_BIG 0x80
  286. #define EXT_BITS1_JMPTBL_LITTLE 0x01
  287. #define EXT_BITS1_COBOL_MAIN_BIG 0x40
  288. #define EXT_BITS1_COBOL_MAIN_LITTLE 0x02
  289. #define EXT_BITS1_WEAKEXT_BIG 0x20
  290. #define EXT_BITS1_WEAKEXT_LITTLE 0x04
  291. /* Dense numbers external record */
  292. struct dnr_ext {
  293. unsigned char d_rfd[4];
  294. unsigned char d_index[4];
  295. };
  296. /* Relative file descriptor */
  297. struct rfd_ext {
  298. unsigned char rfd[4];
  299. };
  300. /* Optimizer symbol external record */
  301. struct opt_ext {
  302. unsigned char o_bits1[1];
  303. unsigned char o_bits2[1];
  304. unsigned char o_bits3[1];
  305. unsigned char o_bits4[1];
  306. struct rndx_ext o_rndx;
  307. unsigned char o_offset[4];
  308. };
  309. #define OPT_BITS2_VALUE_SH_LEFT_BIG 16
  310. #define OPT_BITS2_VALUE_SH_LEFT_LITTLE 0
  311. #define OPT_BITS3_VALUE_SH_LEFT_BIG 8
  312. #define OPT_BITS3_VALUE_SH_LEFT_LITTLE 8
  313. #define OPT_BITS4_VALUE_SH_LEFT_BIG 0
  314. #define OPT_BITS4_VALUE_SH_LEFT_LITTLE 16