github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/internal/xcoff/xcoff.go (about)

     1  // Copyright 2018 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
    10  	Fnscns   uint16
    11  	Ftimedat uint32
    12  	Fsymptr  uint32
    13  	Fnsyms   uint32
    14  	Fopthdr  uint16
    15  	Fflags   uint16
    16  }
    17  
    18  type FileHeader64 struct {
    19  	Fmagic   uint16
    20  	Fnscns   uint16
    21  	Ftimedat uint32
    22  	Fsymptr  uint64
    23  	Fopthdr  uint16
    24  	Fflags   uint16
    25  	Fnsyms   uint32
    26  }
    27  
    28  const (
    29  	FILHSZ_32 = 20
    30  	FILHSZ_64 = 24
    31  )
    32  const (
    33  	U802TOCMAGIC = 0737
    34  	U64_TOCMAGIC = 0767
    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
    54  	Spaddr   uint32
    55  	Svaddr   uint32
    56  	Ssize    uint32
    57  	Sscnptr  uint32
    58  	Srelptr  uint32
    59  	Slnnoptr uint32
    60  	Snreloc  uint16
    61  	Snlnno   uint16
    62  	Sflags   uint32
    63  }
    64  
    65  type SectionHeader64 struct {
    66  	Sname    [8]byte
    67  	Spaddr   uint64
    68  	Svaddr   uint64
    69  	Ssize    uint64
    70  	Sscnptr  uint64
    71  	Srelptr  uint64
    72  	Slnnoptr uint64
    73  	Snreloc  uint32
    74  	Snlnno   uint32
    75  	Sflags   uint32
    76  	Spad     uint32
    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
    96  	SSUBTYP_DWLINE  = 0x20000
    97  	SSUBTYP_DWPBNMS = 0x30000
    98  	SSUBTYP_DWPBTYP = 0x40000
    99  	SSUBTYP_DWARNGE = 0x50000
   100  	SSUBTYP_DWABREV = 0x60000
   101  	SSUBTYP_DWSTR   = 0x70000
   102  	SSUBTYP_DWRNGES = 0x80000
   103  	SSUBTYP_DWLOC   = 0x90000
   104  	SSUBTYP_DWFRAME = 0xA0000
   105  	SSUBTYP_DWMAC   = 0xB0000
   106  )
   107  
   108  // Symbol Table Entry.
   109  type SymEnt32 struct {
   110  	Nname   [8]byte
   111  	Nvalue  uint32
   112  	Nscnum  uint16
   113  	Ntype   uint16
   114  	Nsclass uint8
   115  	Nnumaux uint8
   116  }
   117  
   118  type SymEnt64 struct {
   119  	Nvalue  uint64
   120  	Noffset uint32
   121  	Nscnum  uint16
   122  	Ntype   uint16
   123  	Nsclass uint8
   124  	Nnumaux uint8
   125  }
   126  
   127  const SYMESZ = 18
   128  
   129  const (
   130  	// Nscnum
   131  	N_DEBUG = -2
   132  	N_ABS   = -1
   133  	N_UNDEF = 0
   134  
   135  	//Ntype
   136  	SYM_V_INTERNAL  = 0x1000
   137  	SYM_V_HIDDEN    = 0x2000
   138  	SYM_V_PROTECTED = 0x3000
   139  	SYM_V_EXPORTED  = 0x4000
   140  	SYM_TYPE_FUNC   = 0x0020
   141  )
   142  
   143  // Storage Class.
   144  const (
   145  	C_NULL    = 0
   146  	C_EXT     = 2
   147  	C_STAT    = 3
   148  	C_BLOCK   = 100
   149  	C_FCN     = 101
   150  	C_FILE    = 103
   151  	C_HIDEXT  = 107
   152  	C_BINCL   = 108
   153  	C_EINCL   = 109
   154  	C_WEAKEXT = 111
   155  	C_DWARF   = 112
   156  	C_GSYM    = 128
   157  	C_LSYM    = 129
   158  	C_PSYM    = 130
   159  	C_RSYM    = 131
   160  	C_RPSYM   = 132
   161  	C_STSYM   = 133
   162  	C_BCOMM   = 135
   163  	C_ECOML   = 136
   164  	C_ECOMM   = 137
   165  	C_DECL    = 140
   166  	C_ENTRY   = 141
   167  	C_FUN     = 142
   168  	C_BSTAT   = 143
   169  	C_ESTAT   = 144
   170  	C_GTLS    = 145
   171  	C_STTLS   = 146
   172  )
   173  
   174  // File Auxiliary Entry
   175  type AuxFile64 struct {
   176  	Xfname   [8]byte
   177  	Xftype   uint8
   178  	Xauxtype uint8
   179  }
   180  
   181  // Function Auxiliary Entry
   182  type AuxFcn32 struct {
   183  	Xexptr   uint32
   184  	Xfsize   uint32
   185  	Xlnnoptr uint32
   186  	Xendndx  uint32
   187  	Xpad     uint16
   188  }
   189  type AuxFcn64 struct {
   190  	Xlnnoptr uint64
   191  	Xfsize   uint32
   192  	Xendndx  uint32
   193  	Xpad     uint8
   194  	Xauxtype uint8
   195  }
   196  
   197  type AuxSect64 struct {
   198  	Xscnlen  uint64
   199  	Xnreloc  uint64
   200  	pad      uint8
   201  	Xauxtype uint8
   202  }
   203  
   204  // csect Auxiliary Entry.
   205  type AuxCSect32 struct {
   206  	Xscnlen   uint32
   207  	Xparmhash uint32
   208  	Xsnhash   uint16
   209  	Xsmtyp    uint8
   210  	Xsmclas   uint8
   211  	Xstab     uint32
   212  	Xsnstab   uint16
   213  }
   214  
   215  type AuxCSect64 struct {
   216  	Xscnlenlo uint32
   217  	Xparmhash uint32
   218  	Xsnhash   uint16
   219  	Xsmtyp    uint8
   220  	Xsmclas   uint8
   221  	Xscnlenhi uint32
   222  	Xpad      uint8
   223  	Xauxtype  uint8
   224  }
   225  
   226  // Symbol type field.
   227  const (
   228  	XTY_ER = 0
   229  	XTY_SD = 1
   230  	XTY_LD = 2
   231  	XTY_CM = 3
   232  )
   233  
   234  // Defines for File auxiliary definitions: x_ftype field of x_file
   235  const (
   236  	XFT_FN = 0
   237  	XFT_CT = 1
   238  	XFT_CV = 2
   239  	XFT_CD = 128
   240  )
   241  
   242  // Storage-mapping class.
   243  const (
   244  	XMC_PR     = 0
   245  	XMC_RO     = 1
   246  	XMC_DB     = 2
   247  	XMC_TC     = 3
   248  	XMC_UA     = 4
   249  	XMC_RW     = 5
   250  	XMC_GL     = 6
   251  	XMC_XO     = 7
   252  	XMC_SV     = 8
   253  	XMC_BS     = 9
   254  	XMC_DS     = 10
   255  	XMC_UC     = 11
   256  	XMC_TC0    = 15
   257  	XMC_TD     = 16
   258  	XMC_SV64   = 17
   259  	XMC_SV3264 = 18
   260  	XMC_TL     = 20
   261  	XMC_UL     = 21
   262  	XMC_TE     = 22
   263  )
   264  
   265  // Loader Header.
   266  type LoaderHeader32 struct {
   267  	Lversion uint32
   268  	Lnsyms   uint32
   269  	Lnreloc  uint32
   270  	Listlen  uint32
   271  	Lnimpid  uint32
   272  	Limpoff  uint32
   273  	Lstlen   uint32
   274  	Lstoff   uint32
   275  }
   276  
   277  type LoaderHeader64 struct {
   278  	Lversion uint32
   279  	Lnsyms   uint32
   280  	Lnreloc  uint32
   281  	Listlen  uint32
   282  	Lnimpid  uint32
   283  	Lstlen   uint32
   284  	Limpoff  uint64
   285  	Lstoff   uint64
   286  	Lsymoff  uint64
   287  	Lrldoff  uint64
   288  }
   289  
   290  const (
   291  	LDHDRSZ_32 = 32
   292  	LDHDRSZ_64 = 56
   293  )
   294  
   295  // Loader Symbol.
   296  type LoaderSymbol32 struct {
   297  	Lname   [8]byte
   298  	Lvalue  uint32
   299  	Lscnum  uint16
   300  	Lsmtype uint8
   301  	Lsmclas uint8
   302  	Lifile  uint32
   303  	Lparm   uint32
   304  }
   305  
   306  type LoaderSymbol64 struct {
   307  	Lvalue  uint64
   308  	Loffset uint32
   309  	Lscnum  uint16
   310  	Lsmtype uint8
   311  	Lsmclas uint8
   312  	Lifile  uint32
   313  	Lparm   uint32
   314  }
   315  
   316  type Reloc32 struct {
   317  	Rvaddr  uint32
   318  	Rsymndx uint32
   319  	Rsize   uint8
   320  	Rtype   uint8
   321  }
   322  
   323  type Reloc64 struct {
   324  	Rvaddr  uint64
   325  	Rsymndx uint32
   326  	Rsize   uint8
   327  	Rtype   uint8
   328  }
   329  
   330  const (
   331  	R_POS = 0x00
   332  	R_NEG = 0x01
   333  	R_REL = 0x02
   334  	R_TOC = 0x03
   335  	R_TRL = 0x12
   336  
   337  	R_TRLA = 0x13
   338  	R_GL   = 0x05
   339  	R_TCL  = 0x06
   340  	R_RL   = 0x0C
   341  	R_RLA  = 0x0D
   342  	R_REF  = 0x0F
   343  	R_BA   = 0x08
   344  	R_RBA  = 0x18
   345  	R_BR   = 0x0A
   346  	R_RBR  = 0x1A
   347  
   348  	R_TLS    = 0x20
   349  	R_TLS_IE = 0x21
   350  	R_TLS_LD = 0x22
   351  	R_TLS_LE = 0x23
   352  	R_TLSM   = 0x24
   353  	R_TLSML  = 0x25
   354  
   355  	R_TOCU = 0x30
   356  	R_TOCL = 0x31
   357  )