compiler: add compiler-rt and wasm symbols to table
Этот коммит содержится в:
родитель
d845f1e1b2
коммит
5b581d83b3
2 изменённых файлов: 20 добавлений и 1 удалений
|
@ -12,6 +12,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
wasm "github.com/aykevl/go-wasm"
|
||||||
"github.com/blakesmith/ar"
|
"github.com/blakesmith/ar"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -74,8 +75,25 @@ func makeArchive(arfile *os.File, objs []string) error {
|
||||||
fileIndex int
|
fileIndex int
|
||||||
}{symbol.Name, i})
|
}{symbol.Name, i})
|
||||||
}
|
}
|
||||||
|
} else if dbg, err := wasm.Parse(objfile); err == nil {
|
||||||
|
for _, s := range dbg.Sections {
|
||||||
|
switch section := s.(type) {
|
||||||
|
case *wasm.SectionImport:
|
||||||
|
for _, ln := range section.Entries {
|
||||||
|
|
||||||
|
if ln.Kind != wasm.ExtKindFunction {
|
||||||
|
// Not a function
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
symbolTable = append(symbolTable, struct {
|
||||||
|
name string
|
||||||
|
fileIndex int
|
||||||
|
}{ln.Field, i})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("failed to open file %s as ELF or PE/COFF: %w", objpath, err)
|
return fmt.Errorf("failed to open file %s as WASM, ELF or PE/COFF: %w", objpath, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close file, to avoid issues with too many open files (especially on
|
// Close file, to avoid issues with too many open files (especially on
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
"goarch": "arm",
|
"goarch": "arm",
|
||||||
"linker": "wasm-ld",
|
"linker": "wasm-ld",
|
||||||
"libc": "wasi-libc",
|
"libc": "wasi-libc",
|
||||||
|
"rtlib": "compiler-rt",
|
||||||
"scheduler": "asyncify",
|
"scheduler": "asyncify",
|
||||||
"default-stack-size": 16384,
|
"default-stack-size": 16384,
|
||||||
"cflags": [
|
"cflags": [
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче