Subversion Repositories Kolibri OS

Rev

Rev 5191 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /* IBM RS/6000 "XCOFF64" file definitions for BFD.
  2.    Copyright (C) 2000-2015 Free Software Foundation, Inc.
  3.  
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.
  8.    
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.    
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  17.    MA 02110-1301, USA.  */
  18.  
  19. /********************** FILE HEADER **********************/
  20.  
  21. struct external_filehdr
  22. {
  23.   char f_magic[2];      /* magic number                 */
  24.   char f_nscns[2];      /* number of sections           */
  25.   char f_timdat[4];     /* time & date stamp            */
  26.   char f_symptr[8];     /* file pointer to symtab       */
  27.   char f_opthdr[2];     /* sizeof(optional hdr)         */
  28.   char f_flags[2];      /* flags                        */
  29.   char f_nsyms[4];      /* number of symtab entries     */
  30. };
  31.  
  32. /* IBM RS/6000.  */
  33. #define U803XTOCMAGIC 0757      /* Aix 4.3 64-bit XCOFF */
  34. #define U64_TOCMAGIC  0767      /* AIX 5+ 64-bit XCOFF */
  35. #define BADMAG(x) ((x).f_magic != U803XTOCMAGIC && (x).f_magic != U64_TOCMAGIC)
  36.  
  37. #define FILHDR  struct external_filehdr
  38. #define FILHSZ  24
  39.  
  40. /********************** AOUT "OPTIONAL HEADER" **********************/
  41.  
  42. typedef struct
  43. {
  44.   unsigned char magic[2];               /* type of file                 */
  45.   unsigned char vstamp[2];              /* version stamp                */
  46.   unsigned char o_debugger[4];          /* reserved                     */
  47.   unsigned char text_start[8];          /* base of text used for this file */
  48.   unsigned char data_start[8];          /* base of data used for this file */
  49.   unsigned char o_toc[8];               /* address of TOC */
  50.   unsigned char o_snentry[2];           /* section number of entry point */
  51.   unsigned char o_sntext[2];            /* section number of .text section */
  52.   unsigned char o_sndata[2];            /* section number of .data section */
  53.   unsigned char o_sntoc[2];             /* section number of TOC */
  54.   unsigned char o_snloader[2];          /* section number of .loader section */
  55.   unsigned char o_snbss[2];             /* section number of .bss section */
  56.   unsigned char o_algntext[2];          /* .text alignment */
  57.   unsigned char o_algndata[2];          /* .data alignment */
  58.   unsigned char o_modtype[2];           /* module type (??) */
  59.   unsigned char o_cputype[2];           /* cpu type */
  60.   unsigned char o_resv2[4];             /* reserved                     */
  61.   unsigned char tsize[8];               /* text size bytes, padded to FW bdry */
  62.   unsigned char dsize[8];               /* initialized data "  "        */
  63.   unsigned char bsize[8];               /* uninitialized data "   "     */
  64.   unsigned char entry[8];               /* entry pt.                    */
  65.   unsigned char o_maxstack[8];          /* max stack size (??)          */
  66.   unsigned char o_maxdata[8];           /* max data size (??)           */
  67.   unsigned char o_resv3[16];            /* reserved                     */
  68. }
  69. AOUTHDR;
  70.  
  71. #define AOUTSZ 120
  72. #define SMALL_AOUTSZ (0)
  73. #define AOUTHDRSZ 72
  74.  
  75. /********************** SECTION HEADER **********************/
  76.  
  77. struct external_scnhdr
  78. {
  79.   char  s_name[8];      /* section name                 */
  80.   char  s_paddr[8];     /* physical address, aliased s_nlib */
  81.   char  s_vaddr[8];     /* virtual address              */
  82.   char  s_size[8];      /* section size                 */
  83.   char  s_scnptr[8];    /* file ptr to raw data for section */
  84.   char  s_relptr[8];    /* file ptr to relocation       */
  85.   char  s_lnnoptr[8];   /* file ptr to line numbers     */
  86.   char  s_nreloc[4];    /* number of relocation entries */
  87.   char  s_nlnno[4];     /* number of line number entries*/
  88.   char  s_flags[4];     /* flags                        */
  89.   char  s_pad[4];       /* padding */  
  90. };
  91.  
  92. #define SCNHDR  struct external_scnhdr
  93.  
  94. #define SCNHSZ  72
  95.  
  96. /********************** LINE NUMBERS **********************/
  97.  
  98. /* 1 line number entry for every "breakpointable" source line in a section.
  99.    Line numbers are grouped on a per function basis; first entry in a function
  100.    grouping will have l_lnno = 0 and in place of physical address will be the
  101.    symbol table index of the function name.  */
  102.  
  103. struct external_lineno
  104. {
  105.   union
  106.   {
  107.     char l_symndx[4];   /* function name symbol index, iff l_lnno == 0*/
  108.     char l_paddr[8];    /* (physical) address of line number    */
  109.   } l_addr;
  110.  
  111.   char l_lnno[4];       /* line number          */
  112. };
  113.  
  114. #define LINENO  struct external_lineno
  115.  
  116. #define LINESZ  12
  117.  
  118. /********************** SYMBOLS **********************/
  119.  
  120. #define E_SYMNMLEN      8       /* # characters in a symbol name        */
  121. #define E_FILNMLEN      14      /* # characters in a file name          */
  122. #define E_DIMNUM        4       /* # array dimensions in auxiliary entry */
  123.  
  124. struct external_syment
  125. {
  126.   char e_value[8];
  127.   char e_offset[4];
  128.   char e_scnum[2];
  129.   char e_type[2];
  130.   char e_sclass[1];
  131.   char e_numaux[1];
  132. };
  133.  
  134. #define N_BTMASK        (017)
  135. #define N_TMASK         (060)
  136. #define N_BTSHFT        (4)
  137. #define N_TSHIFT        (2)
  138.  
  139. union external_auxent
  140. {
  141.     struct {
  142.         union {
  143.             struct {
  144.                 char x_lnno[4];         /* declaration line number */
  145.                 char x_size[2];         /* str/union/array size */
  146.             } x_lnsz;
  147.             struct {
  148.                 char x_lnnoptr[8];/* ptr to fcn line */
  149.                 char x_fsize[4];         /* size of function */
  150.                 char x_endndx[4];        /* entry ndx past block end */
  151.             } x_fcn;
  152.         } x_fcnary;
  153.     } x_sym;
  154.          
  155.     struct {
  156.         union {
  157.             char x_fname[E_FILNMLEN];
  158.             struct {
  159.                 char x_zeroes[4];
  160.                 char x_offset[4];
  161.                 char x_pad[6];
  162.             } x_n;
  163.         } x_n;
  164.         unsigned char x_ftype[1];
  165.         unsigned char x_resv[2];
  166.     } x_file;
  167.  
  168.     struct {
  169.         char x_exptr[8];
  170.         char x_fsize[4];
  171.         char x_endndx[4];
  172.         char x_pad[1];
  173.     } x_except;
  174.  
  175.     struct {
  176.             unsigned char x_scnlen_lo[4];
  177.             unsigned char x_parmhash[4];
  178.             unsigned char x_snhash[2];
  179.             unsigned char x_smtyp[1];
  180.             unsigned char x_smclas[1];
  181.             unsigned char x_scnlen_hi[4];
  182.             unsigned char x_pad[1];
  183.     } x_csect; 
  184.  
  185.     struct {
  186.         char x_pad[17];
  187.         char x_auxtype[1];
  188.     } x_auxtype;
  189. };
  190.  
  191. #define SYMENT  struct external_syment
  192. #define SYMESZ  18     
  193. #define AUXENT  union external_auxent
  194. #define AUXESZ  18
  195. #define DBXMASK 0x80            /* for dbx storage mask */
  196. #define SYMNAME_IN_DEBUG(symptr) ((symptr)->n_sclass & DBXMASK)
  197.  
  198. /* Values for auxtype field in XCOFF64, taken from AIX 4.3 sym.h.  */
  199. #define _AUX_EXCEPT     255
  200. #define _AUX_FCN        254
  201. #define _AUX_SYM        253
  202. #define _AUX_FILE       252
  203. #define _AUX_CSECT      251
  204.  
  205. /********************** RELOCATION DIRECTIVES **********************/
  206.  
  207. struct external_reloc
  208. {
  209.   char r_vaddr[8];
  210.   char r_symndx[4];
  211.   char r_size[1];
  212.   char r_type[1];
  213. };
  214.  
  215. #define RELOC struct external_reloc
  216. #define RELSZ 14
  217.  
  218. #define DEFAULT_DATA_SECTION_ALIGNMENT 4
  219. #define DEFAULT_BSS_SECTION_ALIGNMENT 4
  220. #define DEFAULT_TEXT_SECTION_ALIGNMENT 4
  221. /* For new sections we havn't heard of before */
  222. #define DEFAULT_SECTION_ALIGNMENT 4
  223.  
  224. /* The ldhdr structure.  This appears at the start of the .loader
  225.    section.  */
  226.  
  227. struct external_ldhdr
  228. {
  229.   bfd_byte l_version[4];
  230.   bfd_byte l_nsyms[4];
  231.   bfd_byte l_nreloc[4];
  232.   bfd_byte l_istlen[4];
  233.   bfd_byte l_nimpid[4];
  234.   bfd_byte l_stlen[4];
  235.   bfd_byte l_impoff[8];
  236.   bfd_byte l_stoff[8];
  237.   bfd_byte l_symoff[8];
  238.   bfd_byte l_rldoff[8];
  239. };
  240. #define LDHDRSZ (56)
  241.  
  242. struct external_ldsym
  243. {
  244.   bfd_byte l_value[8];
  245.   bfd_byte l_offset[4];
  246.   bfd_byte l_scnum[2];
  247.   bfd_byte l_smtype[1];
  248.   bfd_byte l_smclas[1];
  249.   bfd_byte l_ifile[4];
  250.   bfd_byte l_parm[4];
  251. };
  252.  
  253. #define LDSYMSZ (24)
  254.  
  255. struct external_ldrel
  256. {
  257.   bfd_byte l_vaddr[8];
  258.   bfd_byte l_rtype[2];
  259.   bfd_byte l_rsecnm[2];
  260.   bfd_byte l_symndx[4];
  261. };
  262.  
  263. #define LDRELSZ (16)
  264.  
  265. struct external_exceptab
  266. {
  267.   union {
  268.     bfd_byte e_symndx[4];
  269.     bfd_byte e_paddr[8];
  270.   } e_addr;
  271.   bfd_byte e_lang[1];
  272.   bfd_byte e_reason[1];
  273. };
  274.  
  275. #define EXCEPTSZ (10)
  276.