diff --git a/constants/pkgpath.1.19.go b/constants/pkgpath.1.19.go index f4681626..0061df3b 100644 --- a/constants/pkgpath.1.19.go +++ b/constants/pkgpath.1.19.go @@ -1,5 +1,5 @@ -//go:build go1.19 && !go1.23 -// +build go1.19,!go1.23 +//go:build go1.19 && !go1.24 +// +build go1.19,!go1.24 package constants diff --git a/constants/type.1.20.go b/constants/type.1.20.go index cc9116ce..ad946ac3 100644 --- a/constants/type.1.20.go +++ b/constants/type.1.20.go @@ -1,5 +1,5 @@ -//go:build go1.20 && !go1.23 -// +build go1.20,!go1.23 +//go:build go1.20 && !go1.24 +// +build go1.20,!go1.24 package constants diff --git a/deferreturn.go b/deferreturn.go index c0ac7ade..d02ec548 100644 --- a/deferreturn.go +++ b/deferreturn.go @@ -1,5 +1,5 @@ -//go:build go1.14 && !go1.23 -// +build go1.14,!go1.23 +//go:build go1.14 && !go1.24 +// +build go1.14,!go1.24 package goloader diff --git a/func.1.20.go b/func.1.20.go index 32255aa2..0e5da75f 100644 --- a/func.1.20.go +++ b/func.1.20.go @@ -1,5 +1,5 @@ -//go:build go1.20 && !go1.23 -// +build go1.20,!go1.23 +//go:build go1.20 && !go1.24 +// +build go1.20,!go1.24 package goloader diff --git a/functab.1.18.go b/functab.1.18.go index 09d99c7d..26ce0c64 100644 --- a/functab.1.18.go +++ b/functab.1.18.go @@ -1,5 +1,5 @@ -//go:build go1.18 && !go1.23 -// +build go1.18,!go1.23 +//go:build go1.18 && !go1.24 +// +build go1.18,!go1.24 package goloader diff --git a/iface.1.10.go b/iface.1.10.go index a2786e17..1f03318f 100644 --- a/iface.1.10.go +++ b/iface.1.10.go @@ -1,5 +1,5 @@ -//go:build go1.10 && !go1.23 -// +build go1.10,!go1.23 +//go:build go1.10 && !go1.24 +// +build go1.10,!go1.24 package goloader diff --git a/init.1.21.go b/init.1.21.go index 00daa034..9b710e50 100644 --- a/init.1.21.go +++ b/init.1.21.go @@ -1,5 +1,5 @@ -//go:build go1.21 && !go1.23 -// +build go1.21,!go1.23 +//go:build go1.21 && !go1.24 +// +build go1.21,!go1.24 package goloader diff --git a/module.1.23.go b/module.1.23.go new file mode 100644 index 00000000..06612d1e --- /dev/null +++ b/module.1.23.go @@ -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 +} diff --git a/obj/funcinfo.1.20.go b/obj/funcinfo.1.20.go index cfed470e..c9e5d84f 100644 --- a/obj/funcinfo.1.20.go +++ b/obj/funcinfo.1.20.go @@ -1,5 +1,5 @@ -//go:build go1.20 && !go1.23 -// +build go1.20,!go1.23 +//go:build go1.20 && !go1.24 +// +build go1.20,!go1.24 package obj diff --git a/obj/inlinedcall.1.20.go b/obj/inlinedcall.1.20.go index c7667ab1..1a23e4c7 100644 --- a/obj/inlinedcall.1.20.go +++ b/obj/inlinedcall.1.20.go @@ -1,5 +1,5 @@ -//go:build go1.20 && !go1.23 -// +build go1.20,!go1.23 +//go:build go1.20 && !go1.24 +// +build go1.20,!go1.24 package obj diff --git a/obj/pathtoprefix.1.9.go b/obj/pathtoprefix.1.9.go index 012b3d7b..139d2a50 100644 --- a/obj/pathtoprefix.1.9.go +++ b/obj/pathtoprefix.1.9.go @@ -1,5 +1,5 @@ -//go:build go1.9 && !go1.23 -// +build go1.9,!go1.23 +//go:build go1.9 && !go1.24 +// +build go1.9,!go1.24 package obj diff --git a/obj/readobj.1.16.go b/obj/readobj.1.16.go index e32f6cc1..6fa1cffe 100644 --- a/obj/readobj.1.16.go +++ b/obj/readobj.1.16.go @@ -1,5 +1,5 @@ -//go:build go1.16 && !go1.23 -// +build go1.16,!go1.23 +//go:build go1.16 && !go1.24 +// +build go1.16,!go1.24 package obj diff --git a/objabi/dataindex/dataindex.1.20.go b/objabi/dataindex/dataindex.1.20.go index 021d8176..14e729ed 100644 --- a/objabi/dataindex/dataindex.1.20.go +++ b/objabi/dataindex/dataindex.1.20.go @@ -1,5 +1,5 @@ -//go:build go1.20 && !go1.23 -// +build go1.20,!go1.23 +//go:build go1.20 && !go1.24 +// +build go1.20,!go1.24 package dataindex diff --git a/objabi/funcalign/funcalign.1.16.go b/objabi/funcalign/funcalign.1.16.go index 48960bd8..d52a4d85 100644 --- a/objabi/funcalign/funcalign.1.16.go +++ b/objabi/funcalign/funcalign.1.16.go @@ -1,5 +1,5 @@ -//go:build go1.16 && !go1.23 -// +build go1.16,!go1.23 +//go:build go1.16 && !go1.24 +// +build go1.16,!go1.24 package funcalign diff --git a/objabi/reloctype/reloctype.1.21.go b/objabi/reloctype/reloctype.1.21.go index 51e3f54b..2f03d249 100644 --- a/objabi/reloctype/reloctype.1.21.go +++ b/objabi/reloctype/reloctype.1.21.go @@ -1,5 +1,5 @@ -//go:build go1.21 && !go1.23 -// +build go1.21,!go1.23 +//go:build go1.21 && !go1.24 +// +build go1.21,!go1.24 package reloctype diff --git a/objabi/symkind/symkind.1.9.go b/objabi/symkind/symkind.1.9.go index 8ceb09e2..f23791e1 100644 --- a/objabi/symkind/symkind.1.9.go +++ b/objabi/symkind/symkind.1.9.go @@ -1,5 +1,5 @@ -//go:build go1.9 && !go1.23 -// +build go1.9,!go1.23 +//go:build go1.9 && !go1.24 +// +build go1.9,!go1.24 package symkind diff --git a/objabi/tls/headtype.1.9.go b/objabi/tls/headtype.1.9.go index 555ec986..7b023830 100644 --- a/objabi/tls/headtype.1.9.go +++ b/objabi/tls/headtype.1.9.go @@ -1,5 +1,5 @@ -//go:build go1.9 && !go1.23 -// +build go1.9,!go1.23 +//go:build go1.9 && !go1.24 +// +build go1.9,!go1.24 package tls diff --git a/objabi/tls/tls.1.13.go b/objabi/tls/tls.1.13.go index 98270482..3bff27a7 100644 --- a/objabi/tls/tls.1.13.go +++ b/objabi/tls/tls.1.13.go @@ -1,5 +1,5 @@ -//go:build go1.13 && !go1.23 -// +build go1.13,!go1.23 +//go:build go1.13 && !go1.24 +// +build go1.13,!go1.24 package tls diff --git a/stackobject/stackobject.1.18.go b/stackobject/stackobject.1.18.go index c50ba71b..a59a7329 100644 --- a/stackobject/stackobject.1.18.go +++ b/stackobject/stackobject.1.18.go @@ -1,5 +1,5 @@ -//go:build go1.18 && !go1.23 -// +build go1.18,!go1.23 +//go:build go1.18 && !go1.24 +// +build go1.18,!go1.24 package stackobject diff --git a/stackobject/stackobject.go b/stackobject/stackobject.go index fd581ddb..f156543e 100644 --- a/stackobject/stackobject.go +++ b/stackobject/stackobject.go @@ -1,5 +1,5 @@ -//go:build go1.12 && !go1.23 -// +build go1.12,!go1.23 +//go:build go1.12 && !go1.24 +// +build go1.12,!go1.24 package stackobject diff --git a/type.1.14.go b/type.1.14.go index e1f045b9..e1550961 100644 --- a/type.1.14.go +++ b/type.1.14.go @@ -1,5 +1,5 @@ -//go:build go1.14 && !go1.23 -// +build go1.14,!go1.23 +//go:build go1.14 && !go1.24 +// +build go1.14,!go1.24 package goloader