github.com/primecitizens/pcz/std@v0.2.1/encoding/binfmt/pe/symbol.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright 2023 The Prime Citizens
     3  //
     4  // Copyright 2009 The Go Authors. All rights reserved.
     5  // Use of this source code is governed by a BSD-style
     6  // license that can be found in the LICENSE file.
     7  
     8  package pe
     9  
    10  const COFFSymbolSize = 18
    11  
    12  // COFFSymbol represents single COFF symbol table record.
    13  type COFFSymbol struct {
    14  	Name               [8]uint8
    15  	Value              uint32
    16  	SectionNumber      int16
    17  	Type               uint16
    18  	StorageClass       uint8
    19  	NumberOfAuxSymbols uint8
    20  }
    21  
    22  // COFFSymbolAuxFormat5 describes the expected form of an aux symbol
    23  // attached to a section definition symbol. The PE format defines a
    24  // number of different aux symbol formats: format 1 for function
    25  // definitions, format 2 for .be and .ef symbols, and so on. Format 5
    26  // holds extra info associated with a section definition, including
    27  // number of relocations + line numbers, as well as COMDAT info. See
    28  // https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#auxiliary-format-5-section-definitions
    29  // for more on what's going on here.
    30  type COFFSymbolAuxFormat5 struct {
    31  	Size           uint32
    32  	NumRelocs      uint16
    33  	NumLineNumbers uint16
    34  	Checksum       uint32
    35  	SecNum         uint16
    36  	Selection      uint8
    37  	_              [3]uint8 // padding
    38  }
    39  
    40  // These constants make up the possible values for the 'Selection'
    41  // field in an AuxFormat5.
    42  const (
    43  	IMAGE_COMDAT_SELECT_NODUPLICATES = 1
    44  	IMAGE_COMDAT_SELECT_ANY          = 2
    45  	IMAGE_COMDAT_SELECT_SAME_SIZE    = 3
    46  	IMAGE_COMDAT_SELECT_EXACT_MATCH  = 4
    47  	IMAGE_COMDAT_SELECT_ASSOCIATIVE  = 5
    48  	IMAGE_COMDAT_SELECT_LARGEST      = 6
    49  )
    50  
    51  // See https://docs.microsoft.com/en-us/windows/win32/debug/pe-format.
    52  const (
    53  	// TODO: the Microsoft doco says IMAGE_SYM_DTYPE_ARRAY is 3 and IMAGE_SYM_DTYPE_FUNCTION is 2
    54  	IMAGE_SYM_TYPE_NULL      = 0
    55  	IMAGE_SYM_TYPE_STRUCT    = 8
    56  	IMAGE_SYM_DTYPE_FUNCTION = 0x20
    57  	IMAGE_SYM_DTYPE_ARRAY    = 0x30
    58  	IMAGE_SYM_CLASS_EXTERNAL = 2
    59  	IMAGE_SYM_CLASS_STATIC   = 3
    60  )