diff options
author | Charlie Haley <[email protected]> | 2023-07-26 18:22:49 +0100 |
---|---|---|
committer | Ayke <[email protected]> | 2023-07-31 14:52:26 +0200 |
commit | 5b581d83b379d77472405ffc1296939b7af409d4 (patch) | |
tree | 60bb56323f8fd365f683e36b271f65ae4b4f36d3 /builder/ar.go | |
parent | d845f1e1b2f04b1c1e778bb7caac005967c1ed7c (diff) | |
download | tinygo-5b581d83b379d77472405ffc1296939b7af409d4.tar.gz tinygo-5b581d83b379d77472405ffc1296939b7af409d4.zip |
compiler: add compiler-rt and wasm symbols to table
Diffstat (limited to 'builder/ar.go')
-rw-r--r-- | builder/ar.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/builder/ar.go b/builder/ar.go index c3aad171e..3f1c8c213 100644 --- a/builder/ar.go +++ b/builder/ar.go @@ -12,6 +12,7 @@ import ( "path/filepath" "time" + wasm "github.com/aykevl/go-wasm" "github.com/blakesmith/ar" ) @@ -74,8 +75,25 @@ func makeArchive(arfile *os.File, objs []string) error { fileIndex int }{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 { - 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 |