Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

allowing undefined symbols #29

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions arguments.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ func parseCompanionFile(goCompanion, protoName string) ([]string, []string) {
return args, rets
}
}

panic(fmt.Sprintf("Failed to find function prototype for %s", protoName))
return nil, nil
}

var regexpFuncAndArgs = regexp.MustCompile(`^\s*func\s+([^\(]*)\(([^\)]*)\)(.*)`)
Expand Down
8 changes: 8 additions & 0 deletions c2goasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (

var (
assembleFlag = flag.Bool("a", false, "Immediately invoke asm2plan9s")
allowUndef = flag.Bool("u", false, "allow undefined symbols")
stripFlag = flag.Bool("s", false, "Strip comments")
compactFlag = flag.Bool("c", false, "Compact byte codes")
formatFlag = flag.Bool("f", false, "Format using asmfmt")
Expand Down Expand Up @@ -85,6 +86,13 @@ func process(assembly []string, goCompanionFile string) ([]string, error) {
for isubroutine, sub := range subroutines {

golangArgs, golangReturns := parseCompanionFile(goCompanionFile, sub.name)
if golangArgs == nil && golangReturns == nil {
if *allowUndef {
log.Printf("Failed to find function prototype for %s", sub.name)
continue
}
panic(fmt.Sprintf("Failed to find function prototype for %s\n", sub.name))
}
stackArgs := argumentsOnStack(sub.body)
if len(golangArgs) > 6 && len(golangArgs)-6 < stackArgs.Number {
panic(fmt.Sprintf("Found too few arguments on stack (%d) but needed %d", len(golangArgs)-6, stackArgs.Number))
Expand Down