aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-05-20 00:30:58 -0400
committerRuss Cox <rsc@golang.org>2014-05-20 00:30:58 -0400
commitd9c9665f1dcd09b0e315c9437d192fed795587a5 (patch)
treee4f4db102031ca07b6b43c3e96400e2456d840e4
parent6aee29648fce3af20507787035ae22d06d75d39b (diff)
downloadgo-d9c9665f1dcd09b0e315c9437d192fed795587a5.tar.gz
go-d9c9665f1dcd09b0e315c9437d192fed795587a5.zip
liblink: fix field tracking
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
-rw-r--r--include/link.h1
-rw-r--r--src/liblink/asm6.c9
-rw-r--r--src/liblink/asm8.c11
3 files changed, 21 insertions, 0 deletions
diff --git a/include/link.h b/include/link.h
index 044849254f..248497888e 100644
--- a/include/link.h
+++ b/include/link.h
@@ -243,6 +243,7 @@ enum
R_PLT0,
R_PLT1,
R_PLT2,
+ R_USEFIELD,
};
// Auto.type
diff --git a/src/liblink/asm6.c b/src/liblink/asm6.c
index 2c719a7758..66afc7a12a 100644
--- a/src/liblink/asm6.c
+++ b/src/liblink/asm6.c
@@ -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++;
diff --git a/src/liblink/asm8.c b/src/liblink/asm8.c
index 39bd5bae10..3ab527ce89 100644
--- a/src/liblink/asm8.c
+++ b/src/liblink/asm8.c
@@ -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) {