rs6000.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:7k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

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