-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
134 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
//go:build go1.23 && !go1.24 | ||
// +build go1.23,!go1.24 | ||
|
||
package goloader | ||
|
||
import ( | ||
"unsafe" | ||
) | ||
|
||
const magic uint32 = 0xFFFFFFF1 | ||
|
||
// pcHeader holds data used by the pclntab lookups. | ||
type pcHeader struct { | ||
magic uint32 // 0xFFFFFFF1 | ||
pad1, pad2 uint8 // 0,0 | ||
minLC uint8 // min instruction size | ||
ptrSize uint8 // size of a ptr in bytes | ||
nfunc int // number of functions in the module | ||
nfiles uint // number of entries in the file tab | ||
textStart uintptr // base for function entry PC offsets in this module, equal to moduledata.text | ||
funcnameOffset uintptr // offset to the funcnametab variable from pcHeader | ||
cuOffset uintptr // offset to the cutab variable from pcHeader | ||
filetabOffset uintptr // offset to the filetab variable from pcHeader | ||
pctabOffset uintptr // offset to the pctab variable from pcHeader | ||
pclnOffset uintptr // offset to the pclntab variable from pcHeader | ||
} | ||
|
||
// moduledata records information about the layout of the executable | ||
// image. It is written by the linker. Any changes here must be | ||
// matched changes to the code in cmd/link/internal/ld/symtab.go:symtab. | ||
// moduledata is stored in statically allocated non-pointer memory; | ||
// none of the pointers here are visible to the garbage collector. | ||
type moduledata struct { | ||
pcHeader *pcHeader | ||
funcnametab []byte | ||
cutab []uint32 | ||
filetab []byte | ||
pctab []byte | ||
pclntable []byte | ||
ftab []functab | ||
findfunctab uintptr | ||
minpc, maxpc uintptr | ||
|
||
text, etext uintptr | ||
noptrdata, enoptrdata uintptr | ||
data, edata uintptr | ||
bss, ebss uintptr | ||
noptrbss, enoptrbss uintptr | ||
covctrs, ecovctrs uintptr | ||
end, gcdata, gcbss uintptr | ||
types, etypes uintptr | ||
rodata uintptr | ||
gofunc uintptr // go.func.* | ||
|
||
textsectmap []textsect | ||
typelinks []int32 // offsets from types | ||
itablinks []*itab | ||
|
||
ptab []ptabEntry | ||
|
||
pluginpath string | ||
pkghashes []modulehash | ||
|
||
// This slice records the initializing tasks that need to be | ||
// done to start up the program. It is built by the linker. | ||
inittasks []*initTask | ||
|
||
modulename string | ||
modulehashes []modulehash | ||
|
||
hasmain uint8 // 1 if module contains the main function, 0 otherwise | ||
bad bool // module failed to load and should be ignored | ||
|
||
gcdatamask, gcbssmask bitvector | ||
|
||
typemap map[typeOff]uintptr // offset to *_rtype in previous module | ||
|
||
next *moduledata | ||
} | ||
|
||
func initmodule(module *moduledata, linker *Linker) { | ||
module.pcHeader = (*pcHeader)(unsafe.Pointer(&(module.pclntable[0]))) | ||
module.pcHeader.textStart = module.text | ||
module.pcHeader.nfunc = len(module.ftab) | ||
module.pcHeader.nfiles = (uint)(len(module.filetab)) | ||
module.funcnametab = module.pclntable | ||
module.pctab = module.pclntable | ||
module.cutab = linker.Filetab | ||
module.filetab = module.pclntable | ||
module.hasmain = 0 | ||
module.bad = false | ||
module.gofunc = module.noptrdata | ||
module.rodata = module.noptrdata | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters