From: Russ Cox Date: Mon, 19 Jan 2015 16:38:53 +0000 (-0500) Subject: [dev.cc] liblink: invoke go tool objwriter during writeobj X-Git-Tag: go1.5beta1~1915^2~114 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=725e3a7afbb5b07e9345dd9ef6878af0cd959776;p=gostls13.git [dev.cc] liblink: invoke go tool objwriter during writeobj This doesn't actually use objwriter for any real work. It's just to check that objwriter is available. The real work will be moved once the bootstrapping mechanisms are working. Change-Id: I5f41c8910c4b11b9d80cb0b0847ff9cb582fc2be Reviewed-on: https://go-review.googlesource.com/3045 Reviewed-by: Ian Lance Taylor --- diff --git a/src/liblink/objfile.c b/src/liblink/objfile.c index aa701f459e..26a7e3ad54 100644 --- a/src/liblink/objfile.c +++ b/src/liblink/objfile.c @@ -119,11 +119,36 @@ static char *rdstring(Biobuf*); static void rddata(Biobuf*, uchar**, int*); static LSym *rdsym(Link*, Biobuf*, char*); +void writeobjdirect(Link*, Biobuf*); + +void +writeobj(Link *ctxt, Biobuf *b) +{ + char *cmd[2]; + + // TODO(rsc): Use 'go tool objwriter' to write object file, + // allowing the bulk of liblink to be moved into Go. + // As a first step, we check that we can invoke objwriter at all + // (it is an empty program for now). + // This tests the cmd/dist bootstrap process, making sure + // that objwriter is available when it needs to be. + // Once the support mechanisms are there, we can put the + // real code in. + + cmd[0] = smprint("%s/pkg/tool/%s_%s/objwriter", getgoroot(), getgohostos(), getgohostarch()); + cmd[1] = "ping"; + cmd[2] = nil; + if(runcmd(cmd) < 0) + sysfatal("cannot run objwriter: %r"); + + writeobjdirect(ctxt, b); +} + // The Go and C compilers, and the assembler, call writeobj to write // out a Go object file. The linker does not call this; the linker // does not write out object files. void -writeobj(Link *ctxt, Biobuf *b) +writeobjdirect(Link *ctxt, Biobuf *b) { int flag, found; Hist *h;