Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* IBM RS/6000 "XCOFF" file definitions for BFD.
0003    Copyright (C) 1990, 1991 Free Software Foundation, Inc.
0004    FIXME: Can someone provide a transliteration of this name into ASCII?
0005    Using the following chars caused a compiler warning on HIUX (so I replaced
0006    them with octal escapes), and isn't useful without an understanding of what
0007    character set it is.
0008    Written by Mimi Ph\373\364ng-Th\345o V\365 of IBM
0009    and John Gilmore of Cygnus Support.  */
0010 
0011 /********************** FILE HEADER **********************/
0012 
0013 struct external_filehdr {
0014     char f_magic[2];    /* magic number         */
0015     char f_nscns[2];    /* number of sections       */
0016     char f_timdat[4];   /* time & date stamp        */
0017     char f_symptr[4];   /* file pointer to symtab   */
0018     char f_nsyms[4];    /* number of symtab entries */
0019     char f_opthdr[2];   /* sizeof(optional hdr)     */
0020     char f_flags[2];    /* flags            */
0021 };
0022 
0023         /* IBM RS/6000 */
0024 #define U802WRMAGIC     0730    /* writeable text segments **chh**      */
0025 #define U802ROMAGIC     0735    /* readonly sharable text segments      */
0026 #define U802TOCMAGIC    0737    /* readonly text segments and TOC       */
0027 
0028 #define BADMAG(x)   \
0029     ((x).f_magic != U802ROMAGIC && (x).f_magic != U802WRMAGIC && \
0030      (x).f_magic != U802TOCMAGIC)
0031 
0032 #define FILHDR  struct external_filehdr
0033 #define FILHSZ  20
0034 
0035 
0036 /********************** AOUT "OPTIONAL HEADER" **********************/
0037 
0038 
0039 typedef struct
0040 {
0041   unsigned char magic[2];   /* type of file         */
0042   unsigned char vstamp[2];  /* version stamp        */
0043   unsigned char tsize[4];   /* text size in bytes, padded to FW bdry */
0044   unsigned char dsize[4];   /* initialized data "  "    */
0045   unsigned char bsize[4];   /* uninitialized data "   " */
0046   unsigned char entry[4];   /* entry pt.            */
0047   unsigned char text_start[4];  /* base of text used for this file */
0048   unsigned char data_start[4];  /* base of data used for this file */
0049   unsigned char o_toc[4];   /* address of TOC */
0050   unsigned char o_snentry[2];   /* section number of entry point */
0051   unsigned char o_sntext[2];    /* section number of .text section */
0052   unsigned char o_sndata[2];    /* section number of .data section */
0053   unsigned char o_sntoc[2]; /* section number of TOC */
0054   unsigned char o_snloader[2];  /* section number of .loader section */
0055   unsigned char o_snbss[2]; /* section number of .bss section */
0056   unsigned char o_algntext[2];  /* .text alignment */
0057   unsigned char o_algndata[2];  /* .data alignment */
0058   unsigned char o_modtype[2];   /* module type (??) */
0059   unsigned char o_cputype[2];   /* cpu type */
0060   unsigned char o_maxstack[4];  /* max stack size (??) */
0061   unsigned char o_maxdata[4];   /* max data size (??) */
0062   unsigned char o_resv2[12];    /* reserved */
0063 }
0064 AOUTHDR;
0065 
0066 #define AOUTSZ 72
0067 #define SMALL_AOUTSZ (28)
0068 #define AOUTHDRSZ 72
0069 
0070 #define RS6K_AOUTHDR_OMAGIC 0x0107  /* old: text & data writeable */
0071 #define RS6K_AOUTHDR_NMAGIC 0x0108  /* new: text r/o, data r/w */
0072 #define RS6K_AOUTHDR_ZMAGIC 0x010B  /* paged: text r/o, both page-aligned */
0073 
0074 
0075 /********************** SECTION HEADER **********************/
0076 
0077 
0078 struct external_scnhdr {
0079     char        s_name[8];  /* section name         */
0080     char        s_paddr[4]; /* physical address, aliased s_nlib */
0081     char        s_vaddr[4]; /* virtual address      */
0082     char        s_size[4];  /* section size         */
0083     char        s_scnptr[4];    /* file ptr to raw data for section */
0084     char        s_relptr[4];    /* file ptr to relocation   */
0085     char        s_lnnoptr[4];   /* file ptr to line numbers */
0086     char        s_nreloc[2];    /* number of relocation entries */
0087     char        s_nlnno[2]; /* number of line number entries*/
0088     char        s_flags[4]; /* flags            */
0089 };
0090 
0091 /*
0092  * names of "special" sections
0093  */
0094 #define _TEXT   ".text"
0095 #define _DATA   ".data"
0096 #define _BSS    ".bss"
0097 #define _PAD    ".pad"
0098 #define _LOADER ".loader"
0099 
0100 #define SCNHDR  struct external_scnhdr
0101 #define SCNHSZ  40
0102 
0103 /* XCOFF uses a special .loader section with type STYP_LOADER.  */
0104 #define STYP_LOADER 0x1000
0105 
0106 /* XCOFF uses a special .debug section with type STYP_DEBUG.  */
0107 #define STYP_DEBUG 0x2000
0108 
0109 /* XCOFF handles line number or relocation overflow by creating
0110    another section header with STYP_OVRFLO set.  */
0111 #define STYP_OVRFLO 0x8000
0112 
0113 /********************** LINE NUMBERS **********************/
0114 
0115 /* 1 line number entry for every "breakpointable" source line in a section.
0116  * Line numbers are grouped on a per function basis; first entry in a function
0117  * grouping will have l_lnno = 0 and in place of physical address will be the
0118  * symbol table index of the function name.
0119  */
0120 struct external_lineno {
0121     union {
0122         char l_symndx[4];   /* function name symbol index, iff l_lnno == 0*/
0123         char l_paddr[4];    /* (physical) address of line number    */
0124     } l_addr;
0125     char l_lnno[2]; /* line number      */
0126 };
0127 
0128 
0129 #define LINENO  struct external_lineno
0130 #define LINESZ  6
0131 
0132 
0133 /********************** SYMBOLS **********************/
0134 
0135 #define E_SYMNMLEN  8   /* # characters in a symbol name    */
0136 #define E_FILNMLEN  14  /* # characters in a file name      */
0137 #define E_DIMNUM    4   /* # array dimensions in auxiliary entry */
0138 
0139 struct external_syment
0140 {
0141   union {
0142     char e_name[E_SYMNMLEN];
0143     struct {
0144       char e_zeroes[4];
0145       char e_offset[4];
0146     } e;
0147   } e;
0148   char e_value[4];
0149   char e_scnum[2];
0150   char e_type[2];
0151   char e_sclass[1];
0152   char e_numaux[1];
0153 };
0154 
0155 
0156 
0157 #define N_BTMASK    (017)
0158 #define N_TMASK     (060)
0159 #define N_BTSHFT    (4)
0160 #define N_TSHIFT    (2)
0161 
0162 
0163 union external_auxent {
0164     struct {
0165         char x_tagndx[4];   /* str, un, or enum tag indx */
0166         union {
0167             struct {
0168                 char  x_lnno[2]; /* declaration line number */
0169                 char  x_size[2]; /* str/union/array size */
0170             } x_lnsz;
0171             char x_fsize[4];    /* size of function */
0172         } x_misc;
0173         union {
0174             struct {        /* if ISFCN, tag, or .bb */
0175                 char x_lnnoptr[4];  /* ptr to fcn line # */
0176                 char x_endndx[4];   /* entry ndx past block end */
0177             } x_fcn;
0178             struct {        /* if ISARY, up to 4 dimen. */
0179                 char x_dimen[E_DIMNUM][2];
0180             } x_ary;
0181         } x_fcnary;
0182         char x_tvndx[2];        /* tv index */
0183     } x_sym;
0184 
0185     union {
0186         char x_fname[E_FILNMLEN];
0187         struct {
0188             char x_zeroes[4];
0189             char x_offset[4];
0190         } x_n;
0191     } x_file;
0192 
0193     struct {
0194         char x_scnlen[4];           /* section length */
0195         char x_nreloc[2];   /* # relocation entries */
0196         char x_nlinno[2];   /* # line numbers */
0197     } x_scn;
0198 
0199         struct {
0200         char x_tvfill[4];   /* tv fill value */
0201         char x_tvlen[2];    /* length of .tv */
0202         char x_tvran[2][2]; /* tv range */
0203     } x_tv;     /* info about .tv section (in auxent of symbol .tv)) */
0204 
0205     struct {
0206         unsigned char x_scnlen[4];
0207         unsigned char x_parmhash[4];
0208         unsigned char x_snhash[2];
0209         unsigned char x_smtyp[1];
0210         unsigned char x_smclas[1];
0211         unsigned char x_stab[4];
0212         unsigned char x_snstab[2];
0213     } x_csect;
0214 
0215 };
0216 
0217 #define SYMENT  struct external_syment
0218 #define SYMESZ  18
0219 #define AUXENT  union external_auxent
0220 #define AUXESZ  18
0221 #define DBXMASK 0x80        /* for dbx storage mask */
0222 #define SYMNAME_IN_DEBUG(symptr) ((symptr)->n_sclass & DBXMASK)
0223 
0224 
0225 
0226 /********************** RELOCATION DIRECTIVES **********************/
0227 
0228 
0229 struct external_reloc {
0230   char r_vaddr[4];
0231   char r_symndx[4];
0232   char r_size[1];
0233   char r_type[1];
0234 };
0235 
0236 
0237 #define RELOC struct external_reloc
0238 #define RELSZ 10
0239 
0240 #define DEFAULT_DATA_SECTION_ALIGNMENT 4
0241 #define DEFAULT_BSS_SECTION_ALIGNMENT 4
0242 #define DEFAULT_TEXT_SECTION_ALIGNMENT 4
0243 /* For new sections we haven't heard of before */
0244 #define DEFAULT_SECTION_ALIGNMENT 4