llcppsymg:remove one leading underscore only in mac

This commit is contained in:
luoliwoshang
2024-10-26 18:43:14 +08:00
parent e6bfe1fc88
commit 7747082ae8
7 changed files with 56 additions and 39 deletions

View File

@@ -158,7 +158,10 @@ func getPath(file string) []string {
func GetCommonSymbols(dylibSymbols []*nm.Symbol, headerSymbols map[string]*parse.SymbolInfo) []*types.SymbolInfo {
var commonSymbols []*types.SymbolInfo
for _, dylibSym := range dylibSymbols {
symName := strings.TrimLeft(dylibSym.Name, "_")
symName := dylibSym.Name
if runtime.GOOS == "darwin" {
symName = strings.TrimPrefix(symName, "_")
}
if symInfo, ok := headerSymbols[symName]; ok {
symbolInfo := &types.SymbolInfo{
Mangle: symName,
@@ -266,3 +269,15 @@ func GenerateAndUpdateSymbolTable(symbols []*nm.Symbol, headerInfos map[string]*
return symbolData, nil
}
// For mutiple os test,the nm output's symbol name is different.
func AddSymbolPrefixUnder(name string, isCpp bool) string {
prefix := ""
if runtime.GOOS == "darwin" {
prefix = prefix + "_"
}
if isCpp {
prefix = prefix + "_"
}
return prefix + name
}