func()

in elf.go [94:134]


func (f *elfFile) goSymbols(stdlib bool) ([]string, error) {
	syms, err := f.objFile.Symbols()
	if err != nil {
		if err == elf.ErrNoSymbols {
			err = nil
		}
		return nil, err
	}
	if len(syms) == 0 {
		return nil, nil
	}
	tab, err := f.pclnTable()
	if err != nil {
		return nil, err
	}
	imports := make([]string, 0, len(syms))
	for _, sym := range syms {
		switch sym.Section {
		case elf.SHN_UNDEF, elf.SHN_COMMON:
			continue
		}
		if strings.HasPrefix(sym.Name, "type..") {
			continue
		}
		if !stdlib && isStdlib(sym.Name, sym.Value, tab) {
			continue
		}
		i := int(sym.Section)
		if i < 0 || i >= len(f.objFile.Sections) {
			continue
		}
		sect := f.objFile.Sections[i]
		if sect.Flags&(elf.SHF_ALLOC|elf.SHF_EXECINSTR) == elf.SHF_ALLOC|elf.SHF_EXECINSTR {
			imports = append(imports, sym.Name)
		}
	}
	if len(imports) == 0 {
		return nil, nil
	}
	return imports, nil
}