diff --git a/iface.1.10.go b/iface.1.10.go index 1f03318..b9dbe79 100644 --- a/iface.1.10.go +++ b/iface.1.10.go @@ -28,32 +28,26 @@ type itabTableType struct { entries [itabInitSize]*itab // really [size] large } -//go:linkname __itabTable runtime.itabTable -var __itabTable unsafe.Pointer // pointer to current table +//go:linkname itabTable runtime.itabTable +var itabTable *itabTableType // pointer to current table -// Avoids "go.info.runtime.itabTable: relocation target go.info.*github.com/pkujhd/goloader.itabTableType not defined" -var itabTable = *(**itabTableType)(unsafe.Pointer(&__itabTable)) - -//go:linkname __itabLock runtime.itabLock -var __itabLock uintptr - -// Avoids "go.info.runtime.itabLock: relocation target go.info.github.com/pkujhd/goloader.mutex not defined" -var itabLock = (*mutex)(unsafe.Pointer(&__itabLock)) +//go:linkname itabLock runtime.itabLock +var itabLock mutex //go:linkname itabAdd runtime.itabAdd func itabAdd(m *itab) func additabs(module *moduledata) { - lock(itabLock) + lock(&itabLock) for _, itab := range module.itablinks { itabAdd(itab) } - unlock(itabLock) + unlock(&itabLock) } func removeitabs(module *moduledata) bool { - lock(itabLock) - defer unlock(itabLock) + lock(&itabLock) + defer unlock(&itabLock) for i := uintptr(0); i < itabTable.size; i++ { p := (**itab)(add(unsafe.Pointer(&itabTable.entries), i*PtrSize)) diff --git a/iface.1.8.go b/iface.1.8.go index 5aaa844..25e63bb 100644 --- a/iface.1.8.go +++ b/iface.1.8.go @@ -23,32 +23,28 @@ type itab struct { // See: src/runtime/iface.go const hashSize = 1009 -//go:linkname __hash runtime.hash -var __hash uintptr +//go:linkname hash runtime.hash +var hash [hashSize]*itab -var hash = (*[hashSize]*itab)(unsafe.Pointer(&__hash)) - -//go:linkname __ifaceLock runtime.ifaceLock -var __ifaceLock uintptr - -var ifaceLock = (*mutex)(unsafe.Pointer(&__ifaceLock)) +//go:linkname ifaceLock runtime.ifaceLock +var ifaceLock mutex //go:linkname additab runtime.additab func additab(m *itab, locked, canfail bool) func additabs(module *moduledata) { - lock(ifaceLock) + lock(&ifaceLock) for _, itab := range module.itablinks { if itab.inhash == 0 { additab(itab, true, false) } } - unlock(ifaceLock) + unlock(&ifaceLock) } func removeitabs(module *moduledata) bool { - lock(ifaceLock) - defer unlock(ifaceLock) + lock(&ifaceLock) + defer unlock(&ifaceLock) //the itab alloc by runtime.persistentalloc, can't free for index, h := range hash {