From 49f4c39e491fe81c849d206d91e47b8a757b232a Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 16 Sep 2014 17:39:55 -0400 Subject: liblink: make GO_ARGS the default for functions beginning with ? If there is a leading ?, assume there is a Go prototype and attach the Go prototype information to the function. If the function is not called from Go and does not need a Go prototype, it can be made file-local instead (using name<>(SB)). This fixes the current BSD build failures, by giving functions like sync/atomic.StoreUint32 argument stack map information. Fixes issue 8753. LGTM=khr, iant R=golang-codereviews, iant, khr, bradfitz CC=golang-codereviews, r, rlh https://codereview.appspot.com/142150043 --- src/liblink/objfile.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/liblink') diff --git a/src/liblink/objfile.c b/src/liblink/objfile.c index 02cfae495..7d4b28c9a 100644 --- a/src/liblink/objfile.c +++ b/src/liblink/objfile.c @@ -125,7 +125,7 @@ static LSym *rdsym(Link*, Biobuf*, char*); void writeobj(Link *ctxt, Biobuf *b) { - int flag; + int flag, found; Hist *h; LSym *s, *text, *etext, *curtext, *data, *edata; Plist *pl; @@ -251,6 +251,27 @@ writeobj(Link *ctxt, Biobuf *b) s->etext = p; } } + + // Add reference to Go arguments for C or assembly functions without them. + for(s = text; s != nil; s = s->next) { + if(strncmp(s->name, "\"\".", 3) != 0) + continue; + found = 0; + for(p = s->text; p != nil; p = p->link) { + if(p->as == ctxt->arch->AFUNCDATA && p->from.type == ctxt->arch->D_CONST && p->from.offset == FUNCDATA_ArgsPointerMaps) { + found = 1; + break; + } + } + if(!found) { + p = appendp(ctxt, s->text); + p->as = ctxt->arch->AFUNCDATA; + p->from.type = ctxt->arch->D_CONST; + p->from.offset = FUNCDATA_ArgsPointerMaps; + p->to.type = ctxt->arch->D_EXTERN; + p->to.sym = linklookup(ctxt, smprint("%s.args_stackmap", s->name), s->version); + } + } // Turn functions into machine code images. for(s = text; s != nil; s = s->next) { -- cgit v1.2.1