github.com/pkujhd/goloader@v0.0.0-20240411034752-1a28096bd7bd/objabi/reloctype/reloctype.1.16.go (about)

     1  //go:build go1.16 && !go1.17
     2  // +build go1.16,!go1.17
     3  
     4  package reloctype
     5  
     6  import "cmd/objfile/objabi"
     7  
     8  // copy from $GOROOT/src/cmd/internal/objabi/reloctype.go
     9  const (
    10  	R_ADDR = (int)(objabi.R_ADDR)
    11  	// R_ADDRARM64 relocates an adrp, add pair to compute the address of the
    12  	// referenced symbol.
    13  	R_ADDRARM64 = (int)(objabi.R_ADDRARM64)
    14  	// R_ADDROFF resolves to a 32-bit offset from the beginning of the section
    15  	// holding the data being relocated to the referenced symbol.
    16  	R_ADDROFF = (int)(objabi.R_ADDROFF)
    17  	// R_WEAKADDROFF resolves just like R_ADDROFF but is a weak relocation.
    18  	// A weak relocation does not make the symbol it refers to reachable,
    19  	// and is only honored by the linker if the symbol is in some other way
    20  	// reachable.
    21  	R_WEAKADDROFF = (int)(objabi.R_WEAKADDROFF)
    22  	R_CALL        = (int)(objabi.R_CALL)
    23  	R_CALLARM     = (int)(objabi.R_CALLARM)
    24  	R_CALLARM64   = (int)(objabi.R_CALLARM64)
    25  	R_CALLIND     = (int)(objabi.R_CALLIND)
    26  	R_PCREL       = (int)(objabi.R_PCREL)
    27  	// R_TLS_LE, used on 386, amd64, and ARM, resolves to the offset of the
    28  	// thread-local symbol from the thread local base and is used to implement the
    29  	// "local exec" model for tls access (r.Sym is not set on intel platforms but is
    30  	// set to a TLS symbol -- runtime.tlsg -- in the linker when externally linking).
    31  	R_TLS_LE = (int)(objabi.R_TLS_LE)
    32  	// R_TLS_IE, used 386, amd64, and ARM resolves to the PC-relative offset to a GOT
    33  	// slot containing the offset from the thread-local symbol from the thread local
    34  	// base and is used to implemented the "initial exec" model for tls access (r.Sym
    35  	// is not set on intel platforms but is set to a TLS symbol -- runtime.tlsg -- in
    36  	// the linker when externally linking).
    37  	R_TLS_IE = (int)(objabi.R_TLS_IE)
    38  	// R_USEIFACE marks a type is converted to an interface in the function this
    39  	// relocation is applied to. The target is a type descriptor.
    40  	// This is a marker relocation (0-sized), for the linker's reachabililty
    41  	// analysis.
    42  	R_USEIFACE = (int)(objabi.R_USEIFACE)
    43  	// R_USEIFACEMETHOD marks an interface method that is used in the function
    44  	// this relocation is applied to. The target is an interface type descriptor.
    45  	// The addend is the offset of the method in the type descriptor.
    46  	// This is a marker relocation (0-sized), for the linker's reachabililty
    47  	// analysis.
    48  	R_USEIFACEMETHOD = (int)(objabi.R_USEIFACEMETHOD)
    49  	// R_METHODOFF resolves to a 32-bit offset from the beginning of the section
    50  	// holding the data being relocated to the referenced symbol.
    51  	// It is a variant of R_ADDROFF used when linking from the uncommonType of a
    52  	// *rtype, and may be set to zero by the linker if it determines the method
    53  	// text is unreachable by the linked program.
    54  	R_METHODOFF = (int)(objabi.R_METHODOFF)
    55  	// R_ADDRCUOFF resolves to a pointer-sized offset from the start of the
    56  	// symbol's DWARF compile unit.
    57  	R_ADDRCUOFF = (int)(objabi.R_ADDRCUOFF)
    58  
    59  	R_GOTPCREL = (int)(objabi.R_GOTPCREL)
    60  
    61  	R_ARM64_GOTPCREL = (int)(objabi.R_ARM64_GOTPCREL)
    62  )
    63  
    64  const (
    65  	//not used, only adapter golang higher version
    66  	R_KEEP               = 0x10000000 - 10
    67  	R_INITORDER          = 0x10000000 - 9
    68  	R_ARM64_PCREL_LDST8  = 0x10000000 - 8
    69  	R_ARM64_PCREL_LDST16 = 0x10000000 - 7
    70  	R_ARM64_PCREL_LDST32 = 0x10000000 - 6
    71  	R_ARM64_PCREL_LDST64 = 0x10000000 - 5
    72  	R_USETYPE            = 0x10000000 - 4
    73  	R_WEAKADDR           = 0x20000000
    74  	R_WEAK               = 0x8000
    75  )
    76  
    77  func RelocTypeString(relocType int) string {
    78  	return (objabi.RelocType)(relocType).String()
    79  }