summaryrefslogtreecommitdiff
path: root/src/liblink
diff options
context:
space:
mode:
Diffstat (limited to 'src/liblink')
-rw-r--r--src/liblink/asm5.c12
-rw-r--r--src/liblink/asm6.c12
-rw-r--r--src/liblink/asm8.c10
-rw-r--r--src/liblink/data.c16
-rw-r--r--src/liblink/obj5.c4
-rw-r--r--src/liblink/obj6.c8
-rw-r--r--src/liblink/obj8.c4
-rw-r--r--src/liblink/objfile.c12
8 files changed, 39 insertions, 39 deletions
diff --git a/src/liblink/asm5.c b/src/liblink/asm5.c
index 39aded033..c11287c8b 100644
--- a/src/liblink/asm5.c
+++ b/src/liblink/asm5.c
@@ -1302,7 +1302,7 @@ if(0 /*debug['G']*/) print("%ux: %s: arm %d\n", (uint32)(p->pc), p->from.sym->na
rel->siz = 4;
rel->sym = p->to.sym;
rel->add = o1 | ((v >> 2) & 0xffffff);
- rel->type = D_CALL;
+ rel->type = R_CALL;
break;
}
if(p->pcond != nil)
@@ -1372,16 +1372,16 @@ if(0 /*debug['G']*/) print("%ux: %s: arm %d\n", (uint32)(p->pc), p->from.sym->na
// to the thread-local g and m pointers.
// Emit a TLS relocation instead of a standard one.
if(rel->sym == ctxt->gmsym) {
- rel->type = D_TLS;
+ rel->type = R_TLS;
if(ctxt->flag_shared)
rel->add += ctxt->pc - p->pcrel->pc - 8 - rel->siz;
rel->xadd = rel->add;
rel->xsym = rel->sym;
} else if(ctxt->flag_shared) {
- rel->type = D_PCREL;
+ rel->type = R_PCREL;
rel->add += ctxt->pc - p->pcrel->pc - 8;
} else
- rel->type = D_ADDR;
+ rel->type = R_ADDR;
o1 = 0;
}
break;
@@ -1720,10 +1720,10 @@ if(0 /*debug['G']*/) print("%ux: %s: arm %d\n", (uint32)(p->pc), p->from.sym->na
rel->add = p->pcond->pc;
}
if(o->flag & LPCREL) {
- rel->type = D_PCREL;
+ rel->type = R_PCREL;
rel->add += ctxt->pc - p->pcrel->pc - 16 + rel->siz;
} else
- rel->type = D_ADDR;
+ rel->type = R_ADDR;
o1 = 0;
}
break;
diff --git a/src/liblink/asm6.c b/src/liblink/asm6.c
index 07ca35eda..213b1b55d 100644
--- a/src/liblink/asm6.c
+++ b/src/liblink/asm6.c
@@ -2272,12 +2272,12 @@ vaddr(Link *ctxt, Addr *a, Reloc *r)
if(ctxt->flag_shared || ctxt->headtype == Hnacl) {
if(s->type == STLSBSS) {
r->xadd = r->add - r->siz;
- r->type = D_TLS;
+ r->type = R_TLS;
r->xsym = s;
} else
- r->type = D_PCREL;
+ r->type = R_PCREL;
} else
- r->type = D_ADDR;
+ r->type = R_ADDR;
}
return v;
}
@@ -3024,7 +3024,7 @@ found:
r->off = p->pc + ctxt->andptr - ctxt->and;
r->sym = p->to.sym;
r->add = p->to.offset;
- r->type = D_PCREL;
+ r->type = R_PCREL;
r->siz = 4;
put4(ctxt, 0);
break;
@@ -3042,7 +3042,7 @@ found:
r = addrel(ctxt->cursym);
r->off = p->pc + ctxt->andptr - ctxt->and;
r->sym = p->to.sym;
- r->type = D_PCREL;
+ r->type = R_PCREL;
r->siz = 4;
put4(ctxt, 0);
break;
@@ -3461,7 +3461,7 @@ asmins(Link *ctxt, Prog *p)
break;
if(ctxt->rexflag)
r->off++;
- if(r->type == D_PCREL)
+ if(r->type == R_PCREL)
r->add -= p->pc + n - (r->off + r->siz);
}
diff --git a/src/liblink/asm8.c b/src/liblink/asm8.c
index 4d209cbdf..2bf6707e1 100644
--- a/src/liblink/asm8.c
+++ b/src/liblink/asm8.c
@@ -1717,7 +1717,7 @@ vaddr(Link *ctxt, Addr *a, Reloc *r)
ctxt->diag("need reloc for %D", a);
sysfatal("bad code");
}
- r->type = D_ADDR;
+ r->type = R_ADDR;
r->siz = 4;
r->off = -1;
r->sym = s;
@@ -2360,7 +2360,7 @@ found:
*ctxt->andptr++ = op;
r = addrel(ctxt->cursym);
r->off = p->pc + ctxt->andptr - ctxt->and;
- r->type = D_PCREL;
+ r->type = R_PCREL;
r->siz = 4;
r->sym = p->to.sym;
r->add = p->to.offset;
@@ -2379,7 +2379,7 @@ found:
r = addrel(ctxt->cursym);
r->off = p->pc + ctxt->andptr - ctxt->and;
r->sym = p->to.sym;
- r->type = D_PCREL;
+ r->type = R_PCREL;
r->siz = 4;
put4(ctxt, 0);
break;
@@ -2445,7 +2445,7 @@ found:
*ctxt->andptr++ = o->op[z+1];
r = addrel(ctxt->cursym);
r->off = p->pc + ctxt->andptr - ctxt->and;
- r->type = D_PCREL;
+ r->type = R_PCREL;
r->siz = 4;
r->add = p->to.offset;
put4(ctxt, 0);
@@ -2456,7 +2456,7 @@ found:
*ctxt->andptr++ = o->op[z+1];
r = addrel(ctxt->cursym);
r->off = p->pc + ctxt->andptr - ctxt->and;
- r->type = D_ADDR;
+ r->type = R_ADDR;
r->siz = 4;
r->add = p->to.offset;
r->sym = p->to.sym;
diff --git a/src/liblink/data.c b/src/liblink/data.c
index 58d6d6b5e..4504f4171 100644
--- a/src/liblink/data.c
+++ b/src/liblink/data.c
@@ -130,15 +130,13 @@ savedata(Link *ctxt, LSym *s, Prog *p, char *pn)
s->p[off+i] = cast[inuxi8[i]];
break;
}
- } else if(p->to.type == ctxt->arch->D_ADDR || p->to.type == ctxt->arch->D_SIZE) {
+ } else if(p->to.type == ctxt->arch->D_ADDR) {
addr:
r = addrel(s);
r->off = off;
r->siz = siz;
r->sym = p->to.sym;
- r->type = p->to.type;
- if(r->type != ctxt->arch->D_SIZE)
- r->type = ctxt->arch->D_ADDR;
+ r->type = R_ADDR;
r->add = p->to.offset;
} else {
ctxt->diag("bad data: %P", p);
@@ -271,7 +269,7 @@ addaddrplus(Link *ctxt, LSym *s, LSym *t, vlong add)
r->sym = t;
r->off = i;
r->siz = ctxt->arch->ptrsize;
- r->type = ctxt->arch->D_ADDR;
+ r->type = R_ADDR;
r->add = add;
return i + r->siz;
}
@@ -292,7 +290,7 @@ addpcrelplus(Link *ctxt, LSym *s, LSym *t, vlong add)
r->sym = t;
r->off = i;
r->add = add;
- r->type = ctxt->arch->D_PCREL;
+ r->type = R_PCREL;
r->siz = 4;
return i + r->siz;
}
@@ -319,7 +317,7 @@ setaddrplus(Link *ctxt, LSym *s, vlong off, LSym *t, vlong add)
r->sym = t;
r->off = off;
r->siz = ctxt->arch->ptrsize;
- r->type = ctxt->arch->D_ADDR;
+ r->type = R_ADDR;
r->add = add;
return off + r->siz;
}
@@ -346,7 +344,7 @@ addsize(Link *ctxt, LSym *s, LSym *t)
r->sym = t;
r->off = i;
r->siz = ctxt->arch->ptrsize;
- r->type = ctxt->arch->D_SIZE;
+ r->type = R_SIZE;
return i + r->siz;
}
@@ -366,7 +364,7 @@ addaddrplus4(Link *ctxt, LSym *s, LSym *t, vlong add)
r->sym = t;
r->off = i;
r->siz = 4;
- r->type = ctxt->arch->D_ADDR;
+ r->type = R_ADDR;
r->add = add;
return i + r->siz;
}
diff --git a/src/liblink/obj5.c b/src/liblink/obj5.c
index 96d7aa052..1b1c7df5f 100644
--- a/src/liblink/obj5.c
+++ b/src/liblink/obj5.c
@@ -1039,14 +1039,14 @@ LinkArch linkarm = {
.regsize = 4,
.D_ADDR = D_ADDR,
+ .D_AUTO = D_AUTO,
.D_BRANCH = D_BRANCH,
.D_CONST = D_CONST,
.D_EXTERN = D_EXTERN,
.D_FCONST = D_FCONST,
.D_NONE = D_NONE,
- .D_PCREL = D_PCREL,
+ .D_PARAM = D_PARAM,
.D_SCONST = D_SCONST,
- .D_SIZE = D_SIZE,
.D_STATIC = D_STATIC,
.ACALL = ABL,
diff --git a/src/liblink/obj6.c b/src/liblink/obj6.c
index 6cfa67f09..b4329e886 100644
--- a/src/liblink/obj6.c
+++ b/src/liblink/obj6.c
@@ -1121,14 +1121,14 @@ LinkArch linkamd64 = {
.regsize = 8,
.D_ADDR = D_ADDR,
+ .D_AUTO = D_AUTO,
.D_BRANCH = D_BRANCH,
.D_CONST = D_CONST,
.D_EXTERN = D_EXTERN,
.D_FCONST = D_FCONST,
.D_NONE = D_NONE,
- .D_PCREL = D_PCREL,
+ .D_PARAM = D_PARAM,
.D_SCONST = D_SCONST,
- .D_SIZE = D_SIZE,
.D_STATIC = D_STATIC,
.ACALL = ACALL,
@@ -1166,14 +1166,14 @@ LinkArch linkamd64p32 = {
.regsize = 8,
.D_ADDR = D_ADDR,
+ .D_AUTO = D_AUTO,
.D_BRANCH = D_BRANCH,
.D_CONST = D_CONST,
.D_EXTERN = D_EXTERN,
.D_FCONST = D_FCONST,
.D_NONE = D_NONE,
- .D_PCREL = D_PCREL,
+ .D_PARAM = D_PARAM,
.D_SCONST = D_SCONST,
- .D_SIZE = D_SIZE,
.D_STATIC = D_STATIC,
.ACALL = ACALL,
diff --git a/src/liblink/obj8.c b/src/liblink/obj8.c
index 6e40d04a5..d36db8470 100644
--- a/src/liblink/obj8.c
+++ b/src/liblink/obj8.c
@@ -875,14 +875,14 @@ LinkArch link386 = {
.regsize = 4,
.D_ADDR = D_ADDR,
+ .D_AUTO = D_AUTO,
.D_BRANCH = D_BRANCH,
.D_CONST = D_CONST,
.D_EXTERN = D_EXTERN,
.D_FCONST = D_FCONST,
.D_NONE = D_NONE,
- .D_PCREL = D_PCREL,
+ .D_PARAM = D_PARAM,
.D_SCONST = D_SCONST,
- .D_SIZE = D_SIZE,
.D_STATIC = D_STATIC,
.ACALL = ACALL,
diff --git a/src/liblink/objfile.c b/src/liblink/objfile.c
index f0f3f7622..2b11add3b 100644
--- a/src/liblink/objfile.c
+++ b/src/liblink/objfile.c
@@ -83,10 +83,7 @@
// - nfile [int]
// - file [nfile symbol references]
//
-// The file layout is architecture-independent.
-// The meaning is almost architecture-independent:
-// the only field with architecture-dependent meaning is the
-// relocation's type field.
+// The file layout and meaning of type integers are architecture-independent.
//
// TODO(rsc): The file format is good for a first pass but needs work.
// - There are SymID in the object file that should really just be strings.
@@ -346,7 +343,12 @@ writesym(Link *ctxt, Biobuf *b, LSym *s)
for(a = s->autom; a != nil; a = a->link) {
wrsym(b, a->asym);
wrint(b, a->aoffset);
- wrint(b, a->type);
+ if(a->type == ctxt->arch->D_AUTO)
+ wrint(b, A_AUTO);
+ else if(a->type == ctxt->arch->D_PARAM)
+ wrint(b, A_PARAM);
+ else
+ sysfatal("%s: invalid local variable type %d", s->name, a->type);
wrsym(b, a->gotype);
}