// FuncToPC converts a function name to a PC. It does a "fuzzy" search so if
// the given name is a substring of a real function name, and the substring
// uniquely identifies it, that function is used. If there are multiple matches
// it returns a multiple match error describing all the matches.
FuncToPC converts a function name to a PC. It does a "fuzzy" search so if
the given name is a substring of a real function name, and the substring
uniquely identifies it, that function is used. If there are multiple matches
it returns a multiple match error describing all the matches.
// FuncToPC converts a function name to a PC . It does a " fuzzy " search so if // the given name is a substring of a real function name and the substring // uniquely identifies it that function is used . If there are multiple matches // it returns a multiple match error describing all the matches .
func (b *BinFile) FuncToPC(name string) (uint64, error) {
	if b.funcs == nil {
		return 0, errors.New("no elf symbol table")
	}
	if addr, ok := b.funcs[name]; ok {
		return addr, nil
	}
	matches := make([]string, 0)
	for fn := range b.funcs {
		if strings.Contains(fn, name) {
			matches = append(matches, fn)
		}
	}
	if len(matches) == 1 {
		return b.funcs[matches[0]], nil
	}
	return 0, &ErrMultipleMatches{
		Matches: matches,
	}
}
func ( b * BinFile ) FuncToPC ( name string ) ( uint64 , error ) { if b . funcs == nil { return 0 , errors . New ( " " ) } if addr , ok := b . funcs [ name ] ; ok { return addr , nil } matches := make ( [ ] string , 0 ) for fn := range b . funcs { if strings . Contains ( fn , name ) { matches = append ( matches , fn ) } } if len ( matches ) == 1 { return b . funcs [ matches [ 0 ] ] , nil } return 0 , & ErrMultipleMatches { Matches : matches , } }
FuncToPC converts a function name to a PC.
FuncToPC converts a function name to a PC .