mirror of
https://github.com/golang/go
synced 2024-11-19 10:44:47 -07:00
liblink: warn about TLS base MRC instruction that does not write into R0.
While we're here, make it lookup the tlsfallback symbol only once. LGTM=crawshaw R=golang-codereviews, crawshaw, dave CC=golang-codereviews https://golang.org/cl/107430044
This commit is contained in:
parent
faa223459a
commit
20a5de9eb6
@ -92,7 +92,7 @@ progedit(Link *ctxt, Prog *p)
|
|||||||
{
|
{
|
||||||
char literal[64];
|
char literal[64];
|
||||||
LSym *s;
|
LSym *s;
|
||||||
LSym *tlsfallback;
|
static LSym *tlsfallback;
|
||||||
|
|
||||||
p->from.class = 0;
|
p->from.class = 0;
|
||||||
p->to.class = 0;
|
p->to.class = 0;
|
||||||
@ -111,19 +111,27 @@ progedit(Link *ctxt, Prog *p)
|
|||||||
// Replace TLS register fetches on older ARM procesors.
|
// Replace TLS register fetches on older ARM procesors.
|
||||||
switch(p->as) {
|
switch(p->as) {
|
||||||
case AMRC:
|
case AMRC:
|
||||||
// If the instruction matches MRC 15, 0, <reg>, C13, C0, 3, replace it.
|
// Treat MRC 15, 0, <reg>, C13, C0, 3 specially.
|
||||||
if(ctxt->goarm < 7 && (p->to.offset & 0xffff0fff) == 0xee1d0f70) {
|
if((p->to.offset & 0xffff0fff) == 0xee1d0f70) {
|
||||||
tlsfallback = linklookup(ctxt, "runtime.read_tls_fallback", 0);
|
// Because the instruction might be rewriten to a BL which returns in R0
|
||||||
|
// the register must be zero.
|
||||||
|
if ((p->to.offset & 0xf000) != 0)
|
||||||
|
ctxt->diag("%L: TLS MRC instruction must write to R0 as it might get translated into a BL instruction", p->lineno);
|
||||||
|
|
||||||
// BL runtime.read_tls_fallback(SB)
|
if(ctxt->goarm < 7) {
|
||||||
p->as = ABL;
|
// Replace it with BL runtime.read_tls_fallback(SB).
|
||||||
p->to.type = D_BRANCH;
|
if(tlsfallback == nil)
|
||||||
p->to.sym = tlsfallback;
|
tlsfallback = linklookup(ctxt, "runtime.read_tls_fallback", 0);
|
||||||
p->to.offset = 0;
|
// BL runtime.read_tls_fallback(SB)
|
||||||
} else {
|
p->as = ABL;
|
||||||
// Otherwise, MRC/MCR instructions need no further treatment.
|
p->to.type = D_BRANCH;
|
||||||
p->as = AWORD;
|
p->to.sym = tlsfallback;
|
||||||
|
p->to.offset = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// Otherwise, MRC/MCR instructions need no further treatment.
|
||||||
|
p->as = AWORD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user