aboutsummaryrefslogtreecommitdiff
path: root/src/liblink/obj5.c
diff options
context:
space:
mode:
authorDave Cheney <dave@cheney.net>2014-09-30 10:03:10 +1000
committerDave Cheney <dave@cheney.net>2014-09-30 10:03:10 +1000
commit0b36211cfb823f41e3a201dd18ddee7a68b4d4e3 (patch)
tree4c1eb9c227c933f406b9b50634a5d20190bb2d6c /src/liblink/obj5.c
parent5368e63b57f742495fcbbb82bb15772b761004bf (diff)
downloadgo-0b36211cfb823f41e3a201dd18ddee7a68b4d4e3.tar.xz
liblink: generate MRC replacement in liblink, not tls_arm
Fixes #8690. This CL moves the save of LR around BL runtime.read_tls_fallback to liblink as it is not needed when MRC is not replaced. LGTM=rsc, minux R=rsc, khr, minux CC=golang-codereviews https://golang.org/cl/147310043
Diffstat (limited to 'src/liblink/obj5.c')
-rw-r--r--src/liblink/obj5.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/liblink/obj5.c b/src/liblink/obj5.c
index e192b082b5..d7f2714ed8 100644
--- a/src/liblink/obj5.c
+++ b/src/liblink/obj5.c
@@ -119,14 +119,30 @@ progedit(Link *ctxt, Prog *p)
ctxt->diag("%L: TLS MRC instruction must write to R0 as it might get translated into a BL instruction", p->lineno);
if(ctxt->goarm < 7) {
- // Replace it with BL runtime.read_tls_fallback(SB).
+ // Replace it with BL runtime.read_tls_fallback(SB) for ARM CPUs that lack the tls extension.
if(tlsfallback == nil)
tlsfallback = linklookup(ctxt, "runtime.read_tls_fallback", 0);
- // BL runtime.read_tls_fallback(SB)
+ // MOVW LR, R11
+ p->as = AMOVW;
+ p->from.type = D_REG;
+ p->from.reg = REGLINK;
+ p->to.type = D_REG;
+ p->to.reg = REGTMP;
+
+ // BL runtime.read_tls_fallback(SB)
+ p = appendp(ctxt, p);
p->as = ABL;
p->to.type = D_BRANCH;
p->to.sym = tlsfallback;
p->to.offset = 0;
+
+ // MOVW R11, LR
+ p = appendp(ctxt, p);
+ p->as = AMOVW;
+ p->from.type = D_REG;
+ p->from.reg = REGTMP;
+ p->to.type = D_REG;
+ p->to.reg = REGLINK;
break;
}
}