cgo working on linux/386

R=r
DELTA=70  (47 added, 4 deleted, 19 changed)
OCL=35167
CL=35171
This commit is contained in:
Russ Cox 2009-09-30 13:47:15 -07:00
parent 0632bb4ae5
commit e67a5084b8
10 changed files with 66 additions and 23 deletions

View file

@ -22,20 +22,34 @@ func usage() {
flag.PrintDefaults();
}
const ptrSize = 8 // TODO
var ptrSizeMap = map[string]int64 {
"386": 4,
"amd64": 8,
"arm": 4
}
func main() {
flag.Usage = usage;
flag.Parse();
arch := os.Getenv("GOARCH");
if arch == "" {
fatal("$GOARCH is not set");
}
ptrSize, ok := ptrSizeMap[arch];
if !ok {
fatal("unknown architecture %s", arch);
}
args := flag.Args();
if len(args) != 1 {
usage();
os.Exit(2);
}
p := openProg(args[0]);
p.PtrSize = ptrSize;
p.Preamble = p.Preamble + "\n" + builtinProlog;
p.loadDebugInfo(ptrSize);
p.loadDebugInfo();
p.Vardef = make(map[string]*Type);
p.Funcdef = make(map[string]*FuncType);