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

     1  //go:build go1.20 && !go1.21
     2  // +build go1.20,!go1.21
     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_CALL      = (int)(objabi.R_CALL)
    18  	R_CALLARM   = (int)(objabi.R_CALLARM)
    19  	R_CALLARM64 = (int)(objabi.R_CALLARM64)
    20  	R_CALLIND   = (int)(objabi.R_CALLIND)
    21  	R_PCREL     = (int)(objabi.R_PCREL)
    22  	// R_TLS_LE, used on 386, amd64, and ARM, resolves to the offset of the
    23  	// thread-local symbol from the thread local base and is used to implement the
    24  	// "local exec" model for tls access (r.Sym is not set on intel platforms but is
    25  	// set to a TLS symbol -- runtime.tlsg -- in the linker when externally linking).
    26  	R_TLS_LE = (int)(objabi.R_TLS_LE)
    27  	// R_TLS_IE, used 386, amd64, and ARM resolves to the PC-relative offset to a GOT
    28  	// slot containing the offset from the thread-local symbol from the thread local
    29  	// base and is used to implemented the "initial exec" model for tls access (r.Sym
    30  	// is not set on intel platforms but is set to a TLS symbol -- runtime.tlsg -- in
    31  	// the linker when externally linking).
    32  	R_TLS_IE   = (int)(objabi.R_TLS_IE)
    33  	R_USEFIELD = (int)(objabi.R_USEFIELD)
    34  	// R_USETYPE resolves to an *rtype, but no relocation is created. The
    35  	// linker uses this as a signal that the pointed-to type information
    36  	// should be linked into the final binary, even if there are no other
    37  	// direct references. (This is used for types reachable by reflection.)
    38  	R_USETYPE = (int)(objabi.R_USETYPE)
    39  	// R_USEIFACE marks a type is converted to an interface in the function this
    40  	// relocation is applied to. The target is a type descriptor.
    41  	// This is a marker relocation (0-sized), for the linker's reachabililty
    42  	// analysis.
    43  	R_USEIFACE = (int)(objabi.R_USEIFACE)
    44  	// R_USEIFACEMETHOD marks an interface method that is used in the function
    45  	// this relocation is applied to. The target is an interface type descriptor.
    46  	// The addend is the offset of the method in the type descriptor.
    47  	// This is a marker relocation (0-sized), for the linker's reachabililty
    48  	// analysis.
    49  	R_USEIFACEMETHOD = (int)(objabi.R_USEIFACEMETHOD)
    50  	// R_METHODOFF resolves to a 32-bit offset from the beginning of the section
    51  	// holding the data being relocated to the referenced symbol.
    52  	// It is a variant of R_ADDROFF used when linking from the uncommonType of a
    53  	// *rtype, and may be set to zero by the linker if it determines the method
    54  	// text is unreachable by the linked program.
    55  	R_METHODOFF = (int)(objabi.R_METHODOFF)
    56  	// R_KEEP tells the linker to keep the referred-to symbol in the final binary
    57  	// if the symbol containing the R_KEEP relocation is in the final binary.
    58  	R_KEEP = (int)(objabi.R_KEEP)
    59  	// R_ADDRCUOFF resolves to a pointer-sized offset from the start of the
    60  	// symbol's DWARF compile unit.
    61  	R_ADDRCUOFF = (int)(objabi.R_ADDRCUOFF)
    62  
    63  	R_GOTPCREL = (int)(objabi.R_GOTPCREL)
    64  
    65  	R_ARM64_GOTPCREL = (int)(objabi.R_ARM64_GOTPCREL)
    66  
    67  	// R_ARM64_PCREL_LDST8 resolves a PC-relative addresses instruction sequence, usually an
    68  	// adrp followed by a LD8 or ST8 instruction.
    69  	R_ARM64_PCREL_LDST8 = (int)(objabi.R_ARM64_PCREL_LDST8)
    70  
    71  	// R_ARM64_PCREL_LDST16 resolves a PC-relative addresses instruction sequence, usually an
    72  	// adrp followed by a LD16 or ST16 instruction.
    73  	R_ARM64_PCREL_LDST16 = (int)(objabi.R_ARM64_PCREL_LDST16)
    74  
    75  	// R_ARM64_PCREL_LDST32 resolves a PC-relative addresses instruction sequence, usually an
    76  	// adrp followed by a LD32 or ST32 instruction.
    77  	R_ARM64_PCREL_LDST32 = (int)(objabi.R_ARM64_PCREL_LDST32)
    78  
    79  	// R_ARM64_PCREL_LDST64 resolves a PC-relative addresses instruction sequence, usually an
    80  	// adrp followed by a LD64 or ST64 instruction.
    81  	R_ARM64_PCREL_LDST64 = (int)(objabi.R_ARM64_PCREL_LDST64)
    82  	R_WEAK               = 0x8000
    83  
    84  	R_WEAKADDR    = R_WEAK | R_ADDR
    85  	R_WEAKADDROFF = R_WEAK | R_ADDROFF
    86  )
    87  
    88  const (
    89  	//not used, only adapter golang higher version
    90  	R_INITORDER = 0x10000000 - 9
    91  )
    92  
    93  func RelocTypeString(relocType int) string {
    94  	return (objabi.RelocType)(relocType).String()
    95  }