Skip to content

Commit

Permalink
iterator itab table, remove all interface inter or type in load module
Browse files Browse the repository at this point in the history
  • Loading branch information
pkujhd committed Jul 13, 2020
1 parent be33f75 commit b3853c8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions iface.1.10.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// +build go1.10
// +build !go1.15
// +build !go1.16

package goloader

Expand Down Expand Up @@ -65,9 +65,11 @@ func removeitabs(module *moduledata) bool {
p := (**itab)(add(unsafe.Pointer(&itabTable.entries), i*PtrSize))
m := (*itab)(loadp(unsafe.Pointer(p)))
if m != nil {
uintptrm := uintptr(unsafe.Pointer(m))
inter := uintptr(unsafe.Pointer(m.inter))
_type := uintptr(unsafe.Pointer(m._type))
if (inter >= module.types && inter <= module.etypes) || (_type >= module.types && _type <= module.etypes) {
if (inter >= module.types && inter <= module.etypes) || (_type >= module.types && _type <= module.etypes) ||
(uintptrm >= module.types && uintptrm <= module.etypes) {
atomicstorep(unsafe.Pointer(p), unsafe.Pointer(nil))
itabTable.count = itabTable.count - 1
}
Expand Down
4 changes: 3 additions & 1 deletion iface.1.8.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ func removeitabs(module *moduledata) bool {
for index, h := range &hash {
last := h
for m := h; m != nil; m = m.link {
uintptrm := uintptr(unsafe.Pointer(m))
inter := uintptr(unsafe.Pointer(m.inter))
_type := uintptr(unsafe.Pointer(m._type))
if (inter >= module.types && inter <= module.etypes) || (_type >= module.types && _type <= module.etypes) {
if (inter >= module.types && inter <= module.etypes) || (_type >= module.types && _type <= module.etypes) ||
(uintptrm >= module.types && uintptrm <= module.etypes) {
if m == h {
hash[index] = m.link
} else {
Expand Down

0 comments on commit b3853c8

Please sign in to comment.