Skip to content

Commit

Permalink
trim ABI suffix for function name on find stkobj name
Browse files Browse the repository at this point in the history
  • Loading branch information
pkujhd committed Jul 27, 2024
1 parent 45232d7 commit 2e27998
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions stackobject/stackobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package stackobject

import (
"fmt"
"strings"
"unsafe"

"github.com/pkujhd/goloader/obj"
Expand Down Expand Up @@ -39,17 +40,16 @@ func AddStackObject(funcname string, symMap map[string]*obj.Sym, symbolMap map[s
if Func != nil && len(Func.FuncData) > dataindex.FUNCDATA_StackObjects &&
Func.FuncData[dataindex.FUNCDATA_StackObjects] != 0 {
objects := addr2stackObjectRecords(adduintptr(Func.FuncData[dataindex.FUNCDATA_StackObjects], int(noptrdata)))
stkobjName := strings.TrimSuffix(strings.TrimSuffix(funcname, obj.ABIINTERNAL_SUFFIX), obj.ABI0_SUFFIX) + StkobjSuffix
for i := range *objects {
name := EmptyString
stkobjName := funcname + StkobjSuffix
if symbol := symMap[stkobjName]; symbol != nil {
name = symbol.Reloc[i].SymName
}
if ptr, ok := symbolMap[name]; ok {
setStackObjectPtr(&((*objects)[i]), adduintptr(ptr, 0), noptrdata)
} else {
return fmt.Errorf("unresolve external Var! Function name:%s index:%d, name:%s", funcname, i, name)

return fmt.Errorf("unresolved external Var! Function name:%s index:%d, name:%s", funcname, i, name)
}
}
}
Expand Down

0 comments on commit 2e27998

Please sign in to comment.