rs6000.h 7.0 KB

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