]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.cc] liblink: invoke go tool objwriter during writeobj
authorRuss Cox <rsc@golang.org>
Mon, 19 Jan 2015 16:38:53 +0000 (11:38 -0500)
committerRuss Cox <rsc@golang.org>
Wed, 21 Jan 2015 00:45:07 +0000 (00:45 +0000)
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 <iant@golang.org>
src/liblink/objfile.c

index aa701f459ed014c576ff2a6efadc4b703635f438..26a7e3ad544f97d3d29c3f31b1cc3cbd687e4690 100644 (file)
@@ -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;