rs6000.h 6.8 KB

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