Skip to content

Commit 206fcf7

Browse files
committed
fix #102, revert commit 0b5d8fa
1 parent 3fe2acb commit 206fcf7

File tree

2 files changed

+16
-26
lines changed

2 files changed

+16
-26
lines changed

iface.1.10.go

+8-14
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,26 @@ type itabTableType struct {
2828
entries [itabInitSize]*itab // really [size] large
2929
}
3030

31-
//go:linkname __itabTable runtime.itabTable
32-
var __itabTable unsafe.Pointer // pointer to current table
31+
//go:linkname itabTable runtime.itabTable
32+
var itabTable *itabTableType // pointer to current table
3333

34-
// Avoids "go.info.runtime.itabTable: relocation target go.info.*github.com/pkujhd/goloader.itabTableType not defined"
35-
var itabTable = *(**itabTableType)(unsafe.Pointer(&__itabTable))
36-
37-
//go:linkname __itabLock runtime.itabLock
38-
var __itabLock uintptr
39-
40-
// Avoids "go.info.runtime.itabLock: relocation target go.info.github.com/pkujhd/goloader.mutex not defined"
41-
var itabLock = (*mutex)(unsafe.Pointer(&__itabLock))
34+
//go:linkname itabLock runtime.itabLock
35+
var itabLock mutex
4236

4337
//go:linkname itabAdd runtime.itabAdd
4438
func itabAdd(m *itab)
4539

4640
func additabs(module *moduledata) {
47-
lock(itabLock)
41+
lock(&itabLock)
4842
for _, itab := range module.itablinks {
4943
itabAdd(itab)
5044
}
51-
unlock(itabLock)
45+
unlock(&itabLock)
5246
}
5347

5448
func removeitabs(module *moduledata) bool {
55-
lock(itabLock)
56-
defer unlock(itabLock)
49+
lock(&itabLock)
50+
defer unlock(&itabLock)
5751

5852
for i := uintptr(0); i < itabTable.size; i++ {
5953
p := (**itab)(add(unsafe.Pointer(&itabTable.entries), i*PtrSize))

iface.1.8.go

+8-12
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,28 @@ type itab struct {
2323
// See: src/runtime/iface.go
2424
const hashSize = 1009
2525

26-
//go:linkname __hash runtime.hash
27-
var __hash uintptr
26+
//go:linkname hash runtime.hash
27+
var hash [hashSize]*itab
2828

29-
var hash = (*[hashSize]*itab)(unsafe.Pointer(&__hash))
30-
31-
//go:linkname __ifaceLock runtime.ifaceLock
32-
var __ifaceLock uintptr
33-
34-
var ifaceLock = (*mutex)(unsafe.Pointer(&__ifaceLock))
29+
//go:linkname ifaceLock runtime.ifaceLock
30+
var ifaceLock mutex
3531

3632
//go:linkname additab runtime.additab
3733
func additab(m *itab, locked, canfail bool)
3834

3935
func additabs(module *moduledata) {
40-
lock(ifaceLock)
36+
lock(&ifaceLock)
4137
for _, itab := range module.itablinks {
4238
if itab.inhash == 0 {
4339
additab(itab, true, false)
4440
}
4541
}
46-
unlock(ifaceLock)
42+
unlock(&ifaceLock)
4743
}
4844

4945
func removeitabs(module *moduledata) bool {
50-
lock(ifaceLock)
51-
defer unlock(ifaceLock)
46+
lock(&ifaceLock)
47+
defer unlock(&ifaceLock)
5248

5349
//the itab alloc by runtime.persistentalloc, can't free
5450
for index, h := range hash {

0 commit comments

Comments
 (0)