diff options
| author | Aram Hăvărneanu <aram@mgk.ro> | 2014-07-02 21:04:10 +1000 |
|---|---|---|
| committer | Dave Cheney <dave@cheney.net> | 2014-07-02 21:04:10 +1000 |
| commit | decd810945e22642df5db99a616af3cc5d53bf8d (patch) | |
| tree | 6e00d4d3dd2f395c7ec89bf945481c81206325a2 /src/liblink | |
| parent | d7b678b2ca26928390078c29e3f71868e867a182 (diff) | |
| download | go-decd810945e22642df5db99a616af3cc5d53bf8d.tar.xz | |
liblink, runtime: preliminary support for plan9/amd64
A TLS slot is reserved by _rt0_.*_plan9 as an automatic and
its address (which is static on Plan 9) is saved in the
global _privates symbol. The startup linkage now is exactly
like that from Plan 9 libc, and the way we access g is
exactly as if we'd have used privalloc(2).
Aside from making the code more standard, this change
drastically simplifies it, both for 386 and for amd64, and
makes the Plan 9 code in liblink common for both 386 and
amd64.
The amd64 runtime code was cleared of nxm assumptions, and
now runs on the standard Plan 9 kernel.
Note handling fixes will follow in a separate CL.
LGTM=rsc
R=golang-codereviews, rsc, bradfitz, dave
CC=0intro, ality, golang-codereviews, jas, minux.ma, mischief
https://golang.org/cl/101510049
Diffstat (limited to 'src/liblink')
| -rw-r--r-- | src/liblink/asm6.c | 14 | ||||
| -rw-r--r-- | src/liblink/asm8.c | 6 | ||||
| -rw-r--r-- | src/liblink/obj6.c | 6 | ||||
| -rw-r--r-- | src/liblink/obj8.c | 4 | ||||
| -rw-r--r-- | src/liblink/sym.c | 2 |
5 files changed, 23 insertions, 9 deletions
diff --git a/src/liblink/asm6.c b/src/liblink/asm6.c index 66afc7a12a..751c972154 100644 --- a/src/liblink/asm6.c +++ b/src/liblink/asm6.c @@ -1901,7 +1901,6 @@ prefixof(Link *ctxt, Addr *a) case Hlinux: case Hnetbsd: case Hopenbsd: - case Hplan9: case Hsolaris: return 0x64; // FS case Hdarwin: @@ -3365,6 +3364,19 @@ mfound: default: sysfatal("unknown TLS base location for %s", headstr(ctxt->headtype)); + case Hplan9: + if(ctxt->plan9privates == nil) + ctxt->plan9privates = linklookup(ctxt, "_privates", 0); + memset(&pp.from, 0, sizeof pp.from); + pp.from.type = D_EXTERN; + pp.from.sym = ctxt->plan9privates; + pp.from.offset = 0; + pp.from.index = D_NONE; + ctxt->rexflag |= Pw; + *ctxt->andptr++ = 0x8B; + asmand(ctxt, &pp.from, &p->to); + break; + case Hsolaris: // TODO(rsc): Delete Hsolaris from list. Should not use this code. See progedit in obj6.c. // TLS base is 0(FS). pp.from = p->from; diff --git a/src/liblink/asm8.c b/src/liblink/asm8.c index 3ab527ce89..62ef41e18a 100644 --- a/src/liblink/asm8.c +++ b/src/liblink/asm8.c @@ -2707,11 +2707,11 @@ mfound: break; case Hplan9: - if(ctxt->plan9tos == nil) - ctxt->plan9tos = linklookup(ctxt, "_tos", 0); + if(ctxt->plan9privates == nil) + ctxt->plan9privates = linklookup(ctxt, "_privates", 0); memset(&pp.from, 0, sizeof pp.from); pp.from.type = D_EXTERN; - pp.from.sym = ctxt->plan9tos; + pp.from.sym = ctxt->plan9privates; pp.from.offset = 0; pp.from.index = D_NONE; *ctxt->andptr++ = 0x8B; diff --git a/src/liblink/obj6.c b/src/liblink/obj6.c index d83f847851..a8538c9ecf 100644 --- a/src/liblink/obj6.c +++ b/src/liblink/obj6.c @@ -103,7 +103,7 @@ static int canuselocaltls(Link *ctxt) { switch(ctxt->headtype) { -// case Hlinux: + case Hplan9: case Hwindows: return 0; } @@ -402,6 +402,10 @@ addstacksplit(Link *ctxt, LSym *cursym) for(i=0; i<nelem(morename); i++) ctxt->symmorestack[i] = linklookup(ctxt, morename[i], 0); } + + if(ctxt->headtype == Hplan9 && ctxt->plan9privates == nil) + ctxt->plan9privates = linklookup(ctxt, "_privates", 0); + ctxt->cursym = cursym; if(cursym->text == nil || cursym->text->link == nil) diff --git a/src/liblink/obj8.c b/src/liblink/obj8.c index 72934c1499..6f96ebae95 100644 --- a/src/liblink/obj8.c +++ b/src/liblink/obj8.c @@ -270,8 +270,8 @@ addstacksplit(Link *ctxt, LSym *cursym) ctxt->symmorestack[1] = linklookup(ctxt, "runtime.morestack_noctxt", 0); } - if(ctxt->headtype == Hplan9 && ctxt->plan9tos == nil) - ctxt->plan9tos = linklookup(ctxt, "_tos", 0); + if(ctxt->headtype == Hplan9 && ctxt->plan9privates == nil) + ctxt->plan9privates = linklookup(ctxt, "_privates", 0); ctxt->cursym = cursym; diff --git a/src/liblink/sym.c b/src/liblink/sym.c index 2b029ce4dc..c8da39ded1 100644 --- a/src/liblink/sym.c +++ b/src/liblink/sym.c @@ -128,8 +128,6 @@ linknew(LinkArch *arch) default: sysfatal("unknown thread-local storage offset for %s", headstr(ctxt->headtype)); case Hplan9: - ctxt->tlsoffset = -2*ctxt->arch->ptrsize; - break; case Hwindows: break; case Hlinux: |
