github.com/guyezi/gofrontend@v0.0.0-20200228202240-7a62a49e62c0/libgo/go/debug/xcoff/xcoff.go (about)

     1  // Copyright 2017 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package xcoff
     6  
     7  // File Header.
     8  type FileHeader32 struct {
     9  	Fmagic   uint16 // Target machine
    10  	Fnscns   uint16 // Number of sections
    11  	Ftimedat int32  // Time and date of file creation
    12  	Fsymptr  uint32 // Byte offset to symbol table start
    13  	Fnsyms   int32  // Number of entries in symbol table
    14  	Fopthdr  uint16 // Number of bytes in optional header
    15  	Fflags   uint16 // Flags
    16  }
    17  
    18  type FileHeader64 struct {
    19  	Fmagic   uint16 // Target machine
    20  	Fnscns   uint16 // Number of sections
    21  	Ftimedat int32  // Time and date of file creation
    22  	Fsymptr  uint64 // Byte offset to symbol table start
    23  	Fopthdr  uint16 // Number of bytes in optional header
    24  	Fflags   uint16 // Flags
    25  	Fnsyms   int32  // Number of entries in symbol table
    26  }
    27  
    28  const (
    29  	FILHSZ_32 = 20
    30  	FILHSZ_64 = 24
    31  )
    32  const (
    33  	U802TOCMAGIC = 0737 // AIX 32-bit XCOFF
    34  	U64_TOCMAGIC = 0767 // AIX 64-bit XCOFF
    35  )
    36  
    37  // Flags that describe the type of the object file.
    38  const (
    39  	F_RELFLG    = 0x0001
    40  	F_EXEC      = 0x0002
    41  	F_LNNO      = 0x0004
    42  	F_FDPR_PROF = 0x0010
    43  	F_FDPR_OPTI = 0x0020
    44  	F_DSA       = 0x0040
    45  	F_VARPG     = 0x0100
    46  	F_DYNLOAD   = 0x1000
    47  	F_SHROBJ    = 0x2000
    48  	F_LOADONLY  = 0x4000
    49  )
    50  
    51  // Section Header.
    52  type SectionHeader32 struct {
    53  	Sname    [8]byte // Section name
    54  	Spaddr   uint32  // Physical address
    55  	Svaddr   uint32  // Virtual address
    56  	Ssize    uint32  // Section size
    57  	Sscnptr  uint32  // Offset in file to raw data for section
    58  	Srelptr  uint32  // Offset in file to relocation entries for section
    59  	Slnnoptr uint32  // Offset in file to line number entries for section
    60  	Snreloc  uint16  // Number of relocation entries
    61  	Snlnno   uint16  // Number of line number entries
    62  	Sflags   uint32  // Flags to define the section type
    63  }
    64  
    65  type SectionHeader64 struct {
    66  	Sname    [8]byte // Section name
    67  	Spaddr   uint64  // Physical address
    68  	Svaddr   uint64  // Virtual address
    69  	Ssize    uint64  // Section size
    70  	Sscnptr  uint64  // Offset in file to raw data for section
    71  	Srelptr  uint64  // Offset in file to relocation entries for section
    72  	Slnnoptr uint64  // Offset in file to line number entries for section
    73  	Snreloc  uint32  // Number of relocation entries
    74  	Snlnno   uint32  // Number of line number entries
    75  	Sflags   uint32  // Flags to define the section type
    76  	Spad     uint32  // Needs to be 72 bytes long
    77  }
    78  
    79  // Flags defining the section type.
    80  const (
    81  	STYP_DWARF  = 0x0010
    82  	STYP_TEXT   = 0x0020
    83  	STYP_DATA   = 0x0040
    84  	STYP_BSS    = 0x0080
    85  	STYP_EXCEPT = 0x0100
    86  	STYP_INFO   = 0x0200
    87  	STYP_TDATA  = 0x0400
    88  	STYP_TBSS   = 0x0800
    89  	STYP_LOADER = 0x1000
    90  	STYP_DEBUG  = 0x2000
    91  	STYP_TYPCHK = 0x4000
    92  	STYP_OVRFLO = 0x8000
    93  )
    94  const (
    95  	SSUBTYP_DWINFO  = 0x10000 // DWARF info section
    96  	SSUBTYP_DWLINE  = 0x20000 // DWARF line-number section
    97  	SSUBTYP_DWPBNMS = 0x30000 // DWARF public names section
    98  	SSUBTYP_DWPBTYP = 0x40000 // DWARF public types section
    99  	SSUBTYP_DWARNGE = 0x50000 // DWARF aranges section
   100  	SSUBTYP_DWABREV = 0x60000 // DWARF abbreviation section
   101  	SSUBTYP_DWSTR   = 0x70000 // DWARF strings section
   102  	SSUBTYP_DWRNGES = 0x80000 // DWARF ranges section
   103  	SSUBTYP_DWLOC   = 0x90000 // DWARF location lists section
   104  	SSUBTYP_DWFRAME = 0xA0000 // DWARF frames section
   105  	SSUBTYP_DWMAC   = 0xB0000 // DWARF macros section
   106  )
   107  
   108  // Symbol Table Entry.
   109  type SymEnt32 struct {
   110  	Nname   [8]byte // Symbol name
   111  	Nvalue  uint32  // Symbol value
   112  	Nscnum  int16   // Section number of symbol
   113  	Ntype   uint16  // Basic and derived type specification
   114  	Nsclass int8    // Storage class of symbol
   115  	Nnumaux int8    // Number of auxiliary entries
   116  }
   117  
   118  type SymEnt64 struct {
   119  	Nvalue  uint64 // Symbol value
   120  	Noffset uint32 // Offset of the name in string table or .debug section
   121  	Nscnum  int16  // Section number of symbol
   122  	Ntype   uint16 // Basic and derived type specification
   123  	Nsclass int8   // Storage class of symbol
   124  	Nnumaux int8   // Number of auxiliary entries
   125  }
   126  
   127  const SYMESZ = 18
   128  
   129  // Storage Class.
   130  const (
   131  	C_NULL    = 0   // Symbol table entry marked for deletion
   132  	C_EXT     = 2   // External symbol
   133  	C_STAT    = 3   // Static symbol
   134  	C_BLOCK   = 100 // Beginning or end of inner block
   135  	C_FCN     = 101 // Beginning or end of function
   136  	C_FILE    = 103 // Source file name and compiler information
   137  	C_HIDEXT  = 107 // Unnamed external symbol
   138  	C_BINCL   = 108 // Beginning of include file
   139  	C_EINCL   = 109 // End of include file
   140  	C_WEAKEXT = 111 // Weak external symbol
   141  	C_DWARF   = 112 // DWARF symbol
   142  	C_GSYM    = 128 // Global variable
   143  	C_LSYM    = 129 // Automatic variable allocated on stack
   144  	C_PSYM    = 130 // Argument to subroutine allocated on stack
   145  	C_RSYM    = 131 // Register variable
   146  	C_RPSYM   = 132 // Argument to function or procedure stored in register
   147  	C_STSYM   = 133 // Statically allocated symbol
   148  	C_BCOMM   = 135 // Beginning of common block
   149  	C_ECOML   = 136 // Local member of common block
   150  	C_ECOMM   = 137 // End of common block
   151  	C_DECL    = 140 // Declaration of object
   152  	C_ENTRY   = 141 // Alternate entry
   153  	C_FUN     = 142 // Function or procedure
   154  	C_BSTAT   = 143 // Beginning of static block
   155  	C_ESTAT   = 144 // End of static block
   156  	C_GTLS    = 145 // Global thread-local variable
   157  	C_STTLS   = 146 // Static thread-local variable
   158  )
   159  
   160  // csect Auxiliary Entry.
   161  type AuxCSect32 struct {
   162  	Xscnlen   int32  // Length or symbol table index
   163  	Xparmhash uint32 // Offset of parameter type-check string
   164  	Xsnhash   uint16 // .typchk section number
   165  	Xsmtyp    uint8  // Symbol alignment and type
   166  	Xsmclas   uint8  // Storage-mapping class
   167  	Xstab     uint32 // Reserved
   168  	Xsnstab   uint16 // Reserved
   169  }
   170  
   171  type AuxCSect64 struct {
   172  	Xscnlenlo uint32 // Lower 4 bytes of length or symbol table index
   173  	Xparmhash uint32 // Offset of parameter type-check string
   174  	Xsnhash   uint16 // .typchk section number
   175  	Xsmtyp    uint8  // Symbol alignment and type
   176  	Xsmclas   uint8  // Storage-mapping class
   177  	Xscnlenhi int32  // Upper 4 bytes of length or symbol table index
   178  	Xpad      uint8  // Unused
   179  	Xauxtype  uint8  // Type of auxiliary entry
   180  }
   181  
   182  // Symbol type field.
   183  const (
   184  	XTY_ER = 0 // External reference
   185  	XTY_SD = 1 // Section definition
   186  	XTY_LD = 2 // Label definition
   187  	XTY_CM = 3 // Common csect definition
   188  )
   189  
   190  // Storage-mapping class.
   191  const (
   192  	XMC_PR     = 0  // Program code
   193  	XMC_RO     = 1  // Read-only constant
   194  	XMC_DB     = 2  // Debug dictionary table
   195  	XMC_TC     = 3  // TOC entry
   196  	XMC_UA     = 4  // Unclassified
   197  	XMC_RW     = 5  // Read/Write data
   198  	XMC_GL     = 6  // Global linkage
   199  	XMC_XO     = 7  // Extended operation
   200  	XMC_SV     = 8  // 32-bit supervisor call descriptor
   201  	XMC_BS     = 9  // BSS class
   202  	XMC_DS     = 10 // Function descriptor
   203  	XMC_UC     = 11 // Unnamed FORTRAN common
   204  	XMC_TC0    = 15 // TOC anchor
   205  	XMC_TD     = 16 // Scalar data entry in the TOC
   206  	XMC_SV64   = 17 // 64-bit supervisor call descriptor
   207  	XMC_SV3264 = 18 // Supervisor call descriptor for both 32-bit and 64-bit
   208  	XMC_TL     = 20 // Read/Write thread-local data
   209  	XMC_UL     = 21 // Read/Write thread-local data (.tbss)
   210  	XMC_TE     = 22 // TOC entry
   211  )
   212  
   213  // Loader Header.
   214  type LoaderHeader32 struct {
   215  	Lversion int32  // Loader section version number
   216  	Lnsyms   int32  // Number of symbol table entries
   217  	Lnreloc  int32  // Number of relocation table entries
   218  	Listlen  uint32 // Length of import file ID string table
   219  	Lnimpid  int32  // Number of import file IDs
   220  	Limpoff  uint32 // Offset to start of import file IDs
   221  	Lstlen   uint32 // Length of string table
   222  	Lstoff   uint32 // Offset to start of string table
   223  }
   224  
   225  type LoaderHeader64 struct {
   226  	Lversion int32  // Loader section version number
   227  	Lnsyms   int32  // Number of symbol table entries
   228  	Lnreloc  int32  // Number of relocation table entries
   229  	Listlen  uint32 // Length of import file ID string table
   230  	Lnimpid  int32  // Number of import file IDs
   231  	Lstlen   uint32 // Length of string table
   232  	Limpoff  uint64 // Offset to start of import file IDs
   233  	Lstoff   uint64 // Offset to start of string table
   234  	Lsymoff  uint64 // Offset to start of symbol table
   235  	Lrldoff  uint64 // Offset to start of relocation entries
   236  }
   237  
   238  const (
   239  	LDHDRSZ_32 = 32
   240  	LDHDRSZ_64 = 56
   241  )
   242  
   243  // Loader Symbol.
   244  type LoaderSymbol32 struct {
   245  	Lname   [8]byte // Symbol name or byte offset into string table
   246  	Lvalue  uint32  // Address field
   247  	Lscnum  int16   // Section number containing symbol
   248  	Lsmtype int8    // Symbol type, export, import flags
   249  	Lsmclas int8    // Symbol storage class
   250  	Lifile  int32   // Import file ID; ordinal of import file IDs
   251  	Lparm   uint32  // Parameter type-check field
   252  }
   253  
   254  type LoaderSymbol64 struct {
   255  	Lvalue  uint64 // Address field
   256  	Loffset uint32 // Byte offset into string table of symbol name
   257  	Lscnum  int16  // Section number containing symbol
   258  	Lsmtype int8   // Symbol type, export, import flags
   259  	Lsmclas int8   // Symbol storage class
   260  	Lifile  int32  // Import file ID; ordinal of import file IDs
   261  	Lparm   uint32 // Parameter type-check field
   262  }