]> Cypherpunks repositories - gostls13.git/commitdiff
liblink: fix field tracking
authorRuss Cox <rsc@golang.org>
Tue, 20 May 2014 04:30:58 +0000 (00:30 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 20 May 2014 04:30:58 +0000 (00:30 -0400)
The USEFIELD instructions no longer make it to the linker,
so we have to do something else to pin the references
they were pinning. Emit a 0-length relocation of type R_USEFIELD.

Fixes #7486.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, r
https://golang.org/cl/95530043

include/link.h
src/liblink/asm6.c
src/liblink/asm8.c

index 044849254fcaf2e0bbd067ed654365e825b81987..248497888e85a0173c55b9baaa23166e7c3c1f72 100644 (file)
@@ -243,6 +243,7 @@ enum
        R_PLT0,
        R_PLT1,
        R_PLT2,
+       R_USEFIELD,
 };
 
 // Auto.type
index 2c719a7758347408aee3861a1d3fa729b89679e6..66afc7a12a89561dff949dc0b75497c96894125f 100644 (file)
@@ -3443,6 +3443,15 @@ asmins(Link *ctxt, Prog *p)
        ctxt->andptr = ctxt->and;
        ctxt->asmode = p->mode;
        
+       if(p->as == AUSEFIELD) {
+               r = addrel(ctxt->cursym);
+               r->off = 0;
+               r->siz = 0;
+               r->sym = p->from.sym;
+               r->type = R_USEFIELD;
+               return;
+       }
+       
        if(ctxt->headtype == Hnacl) {
                if(p->as == AREP) {
                        ctxt->rep++;
index 39bd5bae105c7c2164b733a8b08145388f173afb..3ab527ce89c633b1da5b4142d2ddf0461b6bbd8d 100644 (file)
@@ -2744,7 +2744,18 @@ static uchar naclret[] = {
 static void
 asmins(Link *ctxt, Prog *p)
 {
+       Reloc *r;
+
        ctxt->andptr = ctxt->and;
+       
+       if(p->as == AUSEFIELD) {
+               r = addrel(ctxt->cursym);
+               r->off = 0;
+               r->sym = p->from.sym;
+               r->type = R_USEFIELD;
+               r->siz = 0;
+               return;
+       }
 
        if(ctxt->headtype == Hnacl) {
                switch(p->as) {