From 737d6de29569572e16839f9cf6d91cc1db75b622 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 16 Dec 2013 12:51:38 -0500 Subject: cmd/cc, cmd/gc: update compilers, assemblers for liblink changes - add buffered stdout to all tools and provide to link ctxt. - avoid extra \n before ! in .6 files written by assemblers (makes them match the C compilers). - use linkwriteobj instead of linkouthist+linkwritefuncs. - in assemblers and C compilers, record pc explicitly in Prog, for use by liblink. - in C compilers, preserve jump target links. - in Go compilers (gsubr.c) attach gotype directly to corresponding LSym* instead of rederiving from instruction stream. - in Go compilers, emit just one definition for runtime.zerovalue from each compilation. This CL consists entirely of small adjustments. The heavy lifting is in CL 39680043. Each depends on the other. R=golang-dev, dave, iant CC=golang-dev https://codereview.appspot.com/37030045 --- src/cmd/6a/a.h | 1 + src/cmd/6a/lex.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src/cmd/6a') diff --git a/src/cmd/6a/a.h b/src/cmd/6a/a.h index db72accd7..da12b3298 100644 --- a/src/cmd/6a/a.h +++ b/src/cmd/6a/a.h @@ -137,6 +137,7 @@ EXTERN char* thestring; EXTERN int32 thunk; EXTERN Biobuf obuf; EXTERN Link* ctxt; +EXTERN Biobuf bstdout; void* alloc(int32); void* allocn(void*, int32, int32); diff --git a/src/cmd/6a/lex.c b/src/cmd/6a/lex.c index 97c78d161..e69069e41 100644 --- a/src/cmd/6a/lex.c +++ b/src/cmd/6a/lex.c @@ -65,8 +65,12 @@ main(int argc, char *argv[]) thechar = '6'; thestring = "amd64"; + ctxt = linknew(&linkamd64); ctxt->diag = yyerror; + ctxt->bso = &bstdout; + Binit(&bstdout, 1, OWRITE); + listinit6(); ensuresymb(NSYMB); memset(debug, 0, sizeof(debug)); @@ -103,6 +107,7 @@ main(int argc, char *argv[]) ctxt->debugasm++; break; } ARGEND + if(*argv == 0) { print("usage: %ca [-options] file.s\n", thechar); errorexit(); @@ -113,6 +118,7 @@ main(int argc, char *argv[]) } if(assemble(argv[0])) errorexit(); + Bflush(&bstdout); exits(0); } @@ -152,7 +158,7 @@ assemble(char *file) } Binit(&obuf, of, OWRITE); Bprint(&obuf, "go object %s %s %s\n", getgoos(), thestring, getgoversion()); - Bprint(&obuf, "\n!\n"); + Bprint(&obuf, "!\n"); for(pass = 1; pass <= 2; pass++) { pinit(file); @@ -164,8 +170,7 @@ assemble(char *file) return nerrors; } - linkouthist(ctxt, &obuf); - linkwritefuncs(ctxt, &obuf); + linkwriteobj(ctxt, &obuf); Bflush(&obuf); return 0; } @@ -1098,6 +1103,7 @@ outcode(int a, Addr2 *g2) p->lineno = stmtline; p->from = g2->from; p->to = g2->to; + p->pc = pc; if(lastpc == nil) { pl = linknewplist(ctxt); -- cgit v1.2.1