github.com/pkujhd/goloader@v0.0.0-20240411034752-1a28096bd7bd/objabi/reloctype/reloctype.1.21.go (about) 1 //go:build go1.21 && !go1.23 2 // +build go1.21,!go1.23 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 60 // R_ADDRCUOFF resolves to a pointer-sized offset from the start of the 61 // symbol's DWARF compile unit. 62 R_ADDRCUOFF = (int)(objabi.R_ADDRCUOFF) 63 64 R_GOTPCREL = (int)(objabi.R_GOTPCREL) 65 66 R_ARM64_GOTPCREL = (int)(objabi.R_ARM64_GOTPCREL) 67 68 // R_ARM64_PCREL_LDST8 resolves a PC-relative addresses instruction sequence, usually an 69 // adrp followed by a LD8 or ST8 instruction. 70 R_ARM64_PCREL_LDST8 = (int)(objabi.R_ARM64_PCREL_LDST8) 71 72 // R_ARM64_PCREL_LDST16 resolves a PC-relative addresses instruction sequence, usually an 73 // adrp followed by a LD16 or ST16 instruction. 74 R_ARM64_PCREL_LDST16 = (int)(objabi.R_ARM64_PCREL_LDST16) 75 76 // R_ARM64_PCREL_LDST32 resolves a PC-relative addresses instruction sequence, usually an 77 // adrp followed by a LD32 or ST32 instruction. 78 R_ARM64_PCREL_LDST32 = (int)(objabi.R_ARM64_PCREL_LDST32) 79 80 // R_ARM64_PCREL_LDST64 resolves a PC-relative addresses instruction sequence, usually an 81 // adrp followed by a LD64 or ST64 instruction. 82 R_ARM64_PCREL_LDST64 = (int)(objabi.R_ARM64_PCREL_LDST64) 83 84 // R_INITORDER specifies an ordering edge between two inittask records. 85 // (From one p..inittask record to another one.) 86 // This relocation does not apply any changes to the actual data, it is 87 // just used in the linker to order the inittask records appropriately. 88 R_INITORDER = (int)(objabi.R_INITORDER) 89 R_WEAK = 0x8000 90 91 R_WEAKADDR = R_WEAK | R_ADDR 92 R_WEAKADDROFF = R_WEAK | R_ADDROFF 93 ) 94 95 func RelocTypeString(relocType int) string { 96 return (objabi.RelocType)(relocType).String() 97 }