File tree 2 files changed +16
-26
lines changed
2 files changed +16
-26
lines changed Original file line number Diff line number Diff line change @@ -28,32 +28,26 @@ type itabTableType struct {
28
28
entries [itabInitSize ]* itab // really [size] large
29
29
}
30
30
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
33
33
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
42
36
43
37
//go:linkname itabAdd runtime.itabAdd
44
38
func itabAdd (m * itab )
45
39
46
40
func additabs (module * moduledata ) {
47
- lock (itabLock )
41
+ lock (& itabLock )
48
42
for _ , itab := range module .itablinks {
49
43
itabAdd (itab )
50
44
}
51
- unlock (itabLock )
45
+ unlock (& itabLock )
52
46
}
53
47
54
48
func removeitabs (module * moduledata ) bool {
55
- lock (itabLock )
56
- defer unlock (itabLock )
49
+ lock (& itabLock )
50
+ defer unlock (& itabLock )
57
51
58
52
for i := uintptr (0 ); i < itabTable .size ; i ++ {
59
53
p := (* * itab )(add (unsafe .Pointer (& itabTable .entries ), i * PtrSize ))
Original file line number Diff line number Diff line change @@ -23,32 +23,28 @@ type itab struct {
23
23
// See: src/runtime/iface.go
24
24
const hashSize = 1009
25
25
26
- //go:linkname __hash runtime.hash
27
- var __hash uintptr
26
+ //go:linkname hash runtime.hash
27
+ var hash [ hashSize ] * itab
28
28
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
35
31
36
32
//go:linkname additab runtime.additab
37
33
func additab (m * itab , locked , canfail bool )
38
34
39
35
func additabs (module * moduledata ) {
40
- lock (ifaceLock )
36
+ lock (& ifaceLock )
41
37
for _ , itab := range module .itablinks {
42
38
if itab .inhash == 0 {
43
39
additab (itab , true , false )
44
40
}
45
41
}
46
- unlock (ifaceLock )
42
+ unlock (& ifaceLock )
47
43
}
48
44
49
45
func removeitabs (module * moduledata ) bool {
50
- lock (ifaceLock )
51
- defer unlock (ifaceLock )
46
+ lock (& ifaceLock )
47
+ defer unlock (& ifaceLock )
52
48
53
49
//the itab alloc by runtime.persistentalloc, can't free
54
50
for index , h := range hash {
You can’t perform that action at this time.
0 commit comments