rs6000.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* IBM RS/6000 "XCOFF" file definitions for BFD.
  3. Copyright (C) 1990, 1991 Free Software Foundation, Inc.
  4. FIXME: Can someone provide a transliteration of this name into ASCII?
  5. Using the following chars caused a compiler warning on HIUX (so I replaced
  6. them with octal escapes), and isn't useful without an understanding of what
  7. character set it is.
  8. Written by Mimi Ph\373\364ng-Th\345o V\365 of IBM
  9. and John Gilmore of Cygnus Support. */
  10. /********************** FILE HEADER **********************/
  11. struct external_filehdr {
  12. char f_magic[2]; /* magic number */
  13. char f_nscns[2]; /* number of sections */
  14. char f_timdat[4]; /* time & date stamp */
  15. char f_symptr[4]; /* file pointer to symtab */
  16. char f_nsyms[4]; /* number of symtab entries */
  17. char f_opthdr[2]; /* sizeof(optional hdr) */
  18. char f_flags[2]; /* flags */
  19. };
  20. /* IBM RS/6000 */
  21. #define U802WRMAGIC 0730 /* writeable text segments **chh** */
  22. #define U802ROMAGIC 0735 /* readonly sharable text segments */
  23. #define U802TOCMAGIC 0737 /* readonly text segments and TOC */
  24. #define BADMAG(x) \
  25. ((x).f_magic != U802ROMAGIC && (x).f_magic != U802WRMAGIC && \
  26. (x).f_magic != U802TOCMAGIC)
  27. #define FILHDR struct external_filehdr
  28. #define FILHSZ 20
  29. /********************** AOUT "OPTIONAL HEADER" **********************/
  30. typedef struct
  31. {
  32. unsigned char magic[2]; /* type of file */
  33. unsigned char vstamp[2]; /* version stamp */
  34. unsigned char tsize[4]; /* text size in bytes, padded to FW bdry */
  35. unsigned char dsize[4]; /* initialized data " " */
  36. unsigned char bsize[4]; /* uninitialized data " " */
  37. unsigned char entry[4]; /* entry pt. */
  38. unsigned char text_start[4]; /* base of text used for this file */
  39. unsigned char data_start[4]; /* base of data used for this file */
  40. unsigned char o_toc[4]; /* address of TOC */
  41. unsigned char o_snentry[2]; /* section number of entry point */
  42. unsigned char o_sntext[2]; /* section number of .text section */
  43. unsigned char o_sndata[2]; /* section number of .data section */
  44. unsigned char o_sntoc[2]; /* section number of TOC */
  45. unsigned char o_snloader[2]; /* section number of .loader section */
  46. unsigned char o_snbss[2]; /* section number of .bss section */
  47. unsigned char o_algntext[2]; /* .text alignment */
  48. unsigned char o_algndata[2]; /* .data alignment */
  49. unsigned char o_modtype[2]; /* module type (??) */
  50. unsigned char o_cputype[2]; /* cpu type */
  51. unsigned char o_maxstack[4]; /* max stack size (??) */
  52. unsigned char o_maxdata[4]; /* max data size (??) */
  53. unsigned char o_resv2[12]; /* reserved */
  54. }
  55. AOUTHDR;
  56. #define AOUTSZ 72
  57. #define SMALL_AOUTSZ (28)
  58. #define AOUTHDRSZ 72
  59. #define RS6K_AOUTHDR_OMAGIC 0x0107 /* old: text & data writeable */
  60. #define RS6K_AOUTHDR_NMAGIC 0x0108 /* new: text r/o, data r/w */
  61. #define RS6K_AOUTHDR_ZMAGIC 0x010B /* paged: text r/o, both page-aligned */
  62. /********************** SECTION HEADER **********************/
  63. struct external_scnhdr {
  64. char s_name[8]; /* section name */
  65. char s_paddr[4]; /* physical address, aliased s_nlib */
  66. char s_vaddr[4]; /* virtual address */
  67. char s_size[4]; /* section size */
  68. char s_scnptr[4]; /* file ptr to raw data for section */
  69. char s_relptr[4]; /* file ptr to relocation */
  70. char s_lnnoptr[4]; /* file ptr to line numbers */
  71. char s_nreloc[2]; /* number of relocation entries */
  72. char s_nlnno[2]; /* number of line number entries*/
  73. char s_flags[4]; /* flags */
  74. };
  75. /*
  76. * names of "special" sections
  77. */
  78. #define _TEXT ".text"
  79. #define _DATA ".data"
  80. #define _BSS ".bss"
  81. #define _PAD ".pad"
  82. #define _LOADER ".loader"
  83. #define SCNHDR struct external_scnhdr
  84. #define SCNHSZ 40
  85. /* XCOFF uses a special .loader section with type STYP_LOADER. */
  86. #define STYP_LOADER 0x1000
  87. /* XCOFF uses a special .debug section with type STYP_DEBUG. */
  88. #define STYP_DEBUG 0x2000
  89. /* XCOFF handles line number or relocation overflow by creating
  90. another section header with STYP_OVRFLO set. */
  91. #define STYP_OVRFLO 0x8000
  92. /********************** LINE NUMBERS **********************/
  93. /* 1 line number entry for every "breakpointable" source line in a section.
  94. * Line numbers are grouped on a per function basis; first entry in a function
  95. * grouping will have l_lnno = 0 and in place of physical address will be the
  96. * symbol table index of the function name.
  97. */
  98. struct external_lineno {
  99. union {
  100. char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
  101. char l_paddr[4]; /* (physical) address of line number */
  102. } l_addr;
  103. char l_lnno[2]; /* line number */
  104. };
  105. #define LINENO struct external_lineno
  106. #define LINESZ 6
  107. /********************** SYMBOLS **********************/
  108. #define E_SYMNMLEN 8 /* # characters in a symbol name */
  109. #define E_FILNMLEN 14 /* # characters in a file name */
  110. #define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
  111. struct external_syment
  112. {
  113. union {
  114. char e_name[E_SYMNMLEN];
  115. struct {
  116. char e_zeroes[4];
  117. char e_offset[4];
  118. } e;
  119. } e;
  120. char e_value[4];
  121. char e_scnum[2];
  122. char e_type[2];
  123. char e_sclass[1];
  124. char e_numaux[1];
  125. };
  126. #define N_BTMASK (017)
  127. #define N_TMASK (060)
  128. #define N_BTSHFT (4)
  129. #define N_TSHIFT (2)
  130. union external_auxent {
  131. struct {
  132. char x_tagndx[4]; /* str, un, or enum tag indx */
  133. union {
  134. struct {
  135. char x_lnno[2]; /* declaration line number */
  136. char x_size[2]; /* str/union/array size */
  137. } x_lnsz;
  138. char x_fsize[4]; /* size of function */
  139. } x_misc;
  140. union {
  141. struct { /* if ISFCN, tag, or .bb */
  142. char x_lnnoptr[4]; /* ptr to fcn line # */
  143. char x_endndx[4]; /* entry ndx past block end */
  144. } x_fcn;
  145. struct { /* if ISARY, up to 4 dimen. */
  146. char x_dimen[E_DIMNUM][2];
  147. } x_ary;
  148. } x_fcnary;
  149. char x_tvndx[2]; /* tv index */
  150. } x_sym;
  151. union {
  152. char x_fname[E_FILNMLEN];
  153. struct {
  154. char x_zeroes[4];
  155. char x_offset[4];
  156. } x_n;
  157. } x_file;
  158. struct {
  159. char x_scnlen[4]; /* section length */
  160. char x_nreloc[2]; /* # relocation entries */
  161. char x_nlinno[2]; /* # line numbers */
  162. } x_scn;
  163. struct {
  164. char x_tvfill[4]; /* tv fill value */
  165. char x_tvlen[2]; /* length of .tv */
  166. char x_tvran[2][2]; /* tv range */
  167. } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
  168. struct {
  169. unsigned char x_scnlen[4];
  170. unsigned char x_parmhash[4];
  171. unsigned char x_snhash[2];
  172. unsigned char x_smtyp[1];
  173. unsigned char x_smclas[1];
  174. unsigned char x_stab[4];
  175. unsigned char x_snstab[2];
  176. } x_csect;
  177. };
  178. #define SYMENT struct external_syment
  179. #define SYMESZ 18
  180. #define AUXENT union external_auxent
  181. #define AUXESZ 18
  182. #define DBXMASK 0x80 /* for dbx storage mask */
  183. #define SYMNAME_IN_DEBUG(symptr) ((symptr)->n_sclass & DBXMASK)
  184. /********************** RELOCATION DIRECTIVES **********************/
  185. struct external_reloc {
  186. char r_vaddr[4];
  187. char r_symndx[4];
  188. char r_size[1];
  189. char r_type[1];
  190. };
  191. #define RELOC struct external_reloc
  192. #define RELSZ 10
  193. #define DEFAULT_DATA_SECTION_ALIGNMENT 4
  194. #define DEFAULT_BSS_SECTION_ALIGNMENT 4
  195. #define DEFAULT_TEXT_SECTION_ALIGNMENT 4
  196. /* For new sections we haven't heard of before */
  197. #define DEFAULT_SECTION_ALIGNMENT 4