diff options
author | Russ Cox <rsc@golang.org> | 2014-09-16 17:39:55 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-09-16 17:39:55 -0400 |
commit | 49f4c39e491fe81c849d206d91e47b8a757b232a (patch) | |
tree | bb226f52c46ce72ead725a9d047755cd3d0fe095 /src/liblink | |
parent | b8bda7526a56e959b2aade18c392fb6e4d39e7b5 (diff) | |
download | go-49f4c39e491fe81c849d206d91e47b8a757b232a.tar.gz |
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
Diffstat (limited to 'src/liblink')
-rw-r--r-- | src/liblink/objfile.c | 23 |
1 files changed, 22 insertions, 1 deletions
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) { |