symg

package
v0.7.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DbgSymbol  dbgFlags = 1 << iota
	DbgFlagAll          = DbgSymbol
)

Variables

This section is empty.

Functions

func Do

func Do(conf *Config) (symbolTable []*llcppg.SymbolInfo, err error)

func FetchSymbols added in v0.7.0

func FetchSymbols(lib string, mode LibMode) ([]*nm.Symbol, error)

fetchSymbols parses symbols from dynamic libraries specified in the lib string. It handles multiple libraries (e.g., -L/opt/homebrew/lib -llua -lm) and returns symbols if at least one library is successfully parsed. Errors from inaccessible libraries (like standard libs) are logged as warnings.

Returns symbols and nil error if any symbols are found, or nil and error if none found.

func GetCommonSymbols

func GetCommonSymbols(syms []*nm.Symbol, headerSymbols HeaderSymbols) []*llcppg.SymbolInfo

todo(zzy):only public for test,when llgo test support private package test,this function should be private GetCommonSymbols finds the intersection of symbols from the library symbol table and the symbols parsed from header files. It returns a list of symbols that can be externally linked.

func SetDebug

func SetDebug(flags dbgFlags)

Types

type Config

type Config struct {
	Libs         string
	CFlags       string
	Includes     []string
	Mix          bool
	TrimPrefixes []string
	SymMap       map[string]string
	IsCpp        bool
	HeaderOnly   bool
	LibMode      LibMode
}

type HeaderSymbols added in v0.7.1

type HeaderSymbols map[string]*SymbolInfo

func ParseHeaderFile

func ParseHeaderFile(combileFile string, curPkgFiles []string, prefixes []string, cflags []string, symMap map[string]string, isCpp bool) (HeaderSymbols, error)

func (HeaderSymbols) ToSymbolTable added in v0.7.1

func (h HeaderSymbols) ToSymbolTable() (table []*llcppg.SymbolInfo)

type LibMode added in v0.6.0

type LibMode = symbol.Mode

type Libs added in v0.6.0

type Libs struct {
	Paths []string
	Names []string
}

func ParseLibs added in v0.6.0

func ParseLibs(libs string) *Libs

func (*Libs) Files added in v0.6.0

func (l *Libs) Files(findPaths []string, mode LibMode) ([]string, []string, error)

searches for each library name in the provided paths and default paths, appending the appropriate file extension (.dylib for macOS, .so for Linux at dylib mode, .a for static mode).

Example: For "-L/opt/homebrew/lib -llua -lm" and at dylib mode: - It will search for liblua.dylib (on macOS) or liblua.so (on Linux) - System libs like -lm are ignored and included in notFound

So error is returned if no libraries found at all.

type SymbolInfo

type SymbolInfo struct {
	GoName    string
	ProtoName string
}

type SymbolProcessor

type SymbolProcessor struct {
	// contains filtered or unexported fields
}

func NewSymbolProcessor

func NewSymbolProcessor(curPkgFiles []string, prefixes []string, symMap map[string]string) *SymbolProcessor

func (*SymbolProcessor) AddSuffix

func (p *SymbolProcessor) AddSuffix(name string) string

func (*SymbolProcessor) GenMethodName

func (p *SymbolProcessor) GenMethodName(class, name string, isDestructor bool, isPointer bool) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL