From 3a5410187cdd5d9ed93891cbdccda051246b7988 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 18 Aug 2014 21:06:56 -0400 Subject: liblink: use pc-relative addressing for all memory references in amd64 code LGTM=rminnich, iant R=golang-codereviews, rminnich, iant CC=golang-codereviews, r https://codereview.appspot.com/125140043 --- src/liblink/asm6.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) (limited to 'src/liblink/asm6.c') diff --git a/src/liblink/asm6.c b/src/liblink/asm6.c index fa329777d..e25c85053 100644 --- a/src/liblink/asm6.c +++ b/src/liblink/asm6.c @@ -1932,10 +1932,7 @@ oclass(Link *ctxt, Addr *a) switch(a->index) { case D_EXTERN: case D_STATIC: - if(ctxt->flag_shared || ctxt->headtype == Hnacl) - return Yiauto; - else - return Yi32; /* TO DO: Yi64 */ + return Yiauto; // use pc-relative addressing case D_AUTO: case D_PARAM: return Yiauto; @@ -2290,15 +2287,12 @@ vaddr(Link *ctxt, Addr *a, Reloc *r) r->sym = s; r->add = v; v = 0; - if(ctxt->flag_shared || ctxt->headtype == Hnacl) { - if(s->type == STLSBSS) { - r->xadd = r->add - r->siz; - r->type = R_TLS; - r->xsym = s; - } else - r->type = R_PCREL; - } else - r->type = R_ADDR; + r->type = R_PCREL; + if(s->type == STLSBSS) { + r->xadd = r->add - r->siz; + r->type = R_TLS; + r->xsym = s; + } break; case D_INDIR+D_TLS: @@ -2333,13 +2327,6 @@ asmandsz(Link *ctxt, Addr *a, int r, int rex, int m64) switch(t) { default: goto bad; - case D_STATIC: - case D_EXTERN: - if(ctxt->flag_shared || ctxt->headtype == Hnacl) - goto bad; - t = D_NONE; - v = vaddr(ctxt, a, &rel); - break; case D_AUTO: case D_PARAM: t = D_SP; @@ -2399,7 +2386,7 @@ asmandsz(Link *ctxt, Addr *a, int r, int rex, int m64) ctxt->rexflag |= (regrex[t] & Rxb) | rex; if(t == D_NONE || (D_CS <= t && t <= D_GS) || t == D_TLS) { - if((ctxt->flag_shared || ctxt->headtype == Hnacl) && t == D_NONE && (a->type == D_STATIC || a->type == D_EXTERN) || ctxt->asmode != 64) { + if(t == D_NONE && (a->type == D_STATIC || a->type == D_EXTERN) || ctxt->asmode != 64) { *ctxt->andptr++ = (0 << 6) | (5 << 0) | (r << 3); goto putrelv; } -- cgit v1.2.1