diff options
author | Russ Cox <rsc@golang.org> | 2014-01-21 19:46:34 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-01-21 19:46:34 -0500 |
commit | 570d15c4bce42ef290370402df81ea51c3b9dee2 (patch) | |
tree | 6d94836aa663096673e070eff5e2001c3e2af5ab /src/liblink/obj5.c | |
parent | bbf7fc94dcf683fc118d81615bb395743bc3d696 (diff) | |
download | go-570d15c4bce42ef290370402df81ea51c3b9dee2.tar.gz |
liblink: remove use of linkmode on ARM
Now that liblink is compiled into the compilers and assemblers,
it must not refer to the "linkmode", since that is not known until
link time. This CL makes the ARM support no longer use linkmode,
which fixes a bug with cgo binaries that contain their own TLS
variables.
The x86 code must also remove linkmode; that is issue 7164.
Fixes issue 6992.
R=golang-codereviews, iant
CC=golang-codereviews
https://codereview.appspot.com/55160043
Diffstat (limited to 'src/liblink/obj5.c')
-rw-r--r-- | src/liblink/obj5.c | 114 |
1 files changed, 57 insertions, 57 deletions
diff --git a/src/liblink/obj5.c b/src/liblink/obj5.c index 6505459b0..665108cb9 100644 --- a/src/liblink/obj5.c +++ b/src/liblink/obj5.c @@ -37,7 +37,7 @@ static Prog zprg = { .as = AGOK, - .scond = 14, + .scond = C_SCOND_NONE, .reg = NREG, .from = { .name = D_NONE, @@ -207,8 +207,7 @@ addstacksplit(Link *ctxt, LSym *cursym) ctxt->symmorestack[0] = linklookup(ctxt, "runtime.morestack", 0); tlsfallback = linklookup(ctxt, "runtime.read_tls_fallback", 0); - ctxt->gmsym = nil; - if(ctxt->linkmode == LinkExternal) + if(ctxt->gmsym == nil) ctxt->gmsym = linklookup(ctxt, "runtime.tlsgm", 0); q = nil; @@ -355,7 +354,9 @@ addstacksplit(Link *ctxt, LSym *cursym) if((p->to.offset & 0xffff0fff) == 0xee1d0f70) { if(ctxt->headtype == Hopenbsd) { p->as = ARET; - } else if(ctxt->goarm < 7) { + break; + } + if(ctxt->goarm < 7) { // BL runtime.read_tls_fallback(SB) p->as = ABL; p->to.type = D_BRANCH; @@ -363,63 +364,62 @@ addstacksplit(Link *ctxt, LSym *cursym) p->to.offset = 0; cursym->text->mark &= ~LEAF; } - if(ctxt->linkmode == LinkExternal) { - // runtime.tlsgm is relocated with R_ARM_TLS_LE32 - // and $runtime.tlsgm will contain the TLS offset. - // - // MOV $runtime.tlsgm+ctxt->tlsoffset(SB), REGTMP - // ADD REGTMP, <reg> - // - // In shared mode, runtime.tlsgm is relocated with - // R_ARM_TLS_IE32 and runtime.tlsgm(SB) will point - // to the GOT entry containing the TLS offset. - // - // MOV runtime.tlsgm(SB), REGTMP - // ADD REGTMP, <reg> - // SUB -ctxt->tlsoffset, <reg> - // - // The SUB compensates for ctxt->tlsoffset - // used in runtime.save_gm and runtime.load_gm. - q = p; - p = appendp(ctxt, p); - p->as = AMOVW; - p->scond = 14; - p->reg = NREG; - if(ctxt->flag_shared) { - p->from.type = D_OREG; - p->from.offset = 0; - } else { - p->from.type = D_CONST; - p->from.offset = ctxt->tlsoffset; - } - p->from.sym = ctxt->gmsym; - p->from.name = D_EXTERN; - p->to.type = D_REG; - p->to.reg = REGTMP; - p->to.offset = 0; + // runtime.tlsgm is relocated with R_ARM_TLS_LE32 + // and $runtime.tlsgm will contain the TLS offset. + // + // MOV $runtime.tlsgm+ctxt->tlsoffset(SB), REGTMP + // ADD REGTMP, <reg> + // + // In shared mode, runtime.tlsgm is relocated with + // R_ARM_TLS_IE32 and runtime.tlsgm(SB) will point + // to the GOT entry containing the TLS offset. + // + // MOV runtime.tlsgm(SB), REGTMP + // ADD REGTMP, <reg> + // SUB -ctxt->tlsoffset, <reg> + // + // The SUB compensates for ctxt->tlsoffset + // used in runtime.save_gm and runtime.load_gm. + q = p; + p = appendp(ctxt, p); + p->as = AMOVW; + p->scond = C_SCOND_NONE; + p->reg = NREG; + if(ctxt->flag_shared) { + p->from.type = D_OREG; + p->from.offset = 0; + } else { + p->from.type = D_CONST; + p->from.offset = ctxt->tlsoffset; + } + p->from.sym = ctxt->gmsym; + p->from.name = D_EXTERN; + p->to.type = D_REG; + p->to.reg = REGTMP; + p->to.offset = 0; + p = appendp(ctxt, p); + p->as = AADD; + p->scond = C_SCOND_NONE; + p->reg = NREG; + p->from.type = D_REG; + p->from.reg = REGTMP; + p->to.type = D_REG; + p->to.reg = (q->to.offset & 0xf000) >> 12; + p->to.offset = 0; + + if(ctxt->flag_shared) { p = appendp(ctxt, p); - p->as = AADD; - p->scond = 14; + p->as = ASUB; + p->scond = C_SCOND_NONE; p->reg = NREG; - p->from.type = D_REG; - p->from.reg = REGTMP; + p->from.type = D_CONST; + p->from.offset = -ctxt->tlsoffset; p->to.type = D_REG; p->to.reg = (q->to.offset & 0xf000) >> 12; p->to.offset = 0; - - if(ctxt->flag_shared) { - p = appendp(ctxt, p); - p->as = ASUB; - p->scond = 14; - p->reg = NREG; - p->from.type = D_CONST; - p->from.offset = -ctxt->tlsoffset; - p->to.type = D_REG; - p->to.reg = (q->to.offset & 0xf000) >> 12; - p->to.offset = 0; - } } + break; } } q = p; @@ -984,7 +984,7 @@ loop: i--; continue; } - if(a == AB || (a == ARET && q->scond == 14) || a == ARFE || a == AUNDEF) + if(a == AB || (a == ARET && q->scond == C_SCOND_NONE) || a == ARFE || a == AUNDEF) goto copy; if(q->pcond == nil || (q->pcond->mark&FOLL)) continue; @@ -1005,7 +1005,7 @@ loop: } (*last)->link = r; *last = r; - if(a == AB || (a == ARET && q->scond == 14) || a == ARFE || a == AUNDEF) + if(a == AB || (a == ARET && q->scond == C_SCOND_NONE) || a == ARFE || a == AUNDEF) return; r->as = ABNE; if(a == ABNE) @@ -1031,7 +1031,7 @@ loop: p->mark |= FOLL; (*last)->link = p; *last = p; - if(a == AB || (a == ARET && p->scond == 14) || a == ARFE || a == AUNDEF){ + if(a == AB || (a == ARET && p->scond == C_SCOND_NONE) || a == ARFE || a == AUNDEF){ return; } if(p->pcond != nil) |