diff options
| author | Russ Cox <rsc@golang.org> | 2014-04-14 15:54:20 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2014-04-14 15:54:20 -0400 |
| commit | 8d39e55c6516be5ee3267b8ce101b324a4f09986 (patch) | |
| tree | acc342d354cf6456d4cf9b60afea3fc0a0547979 /src/cmd/8l | |
| parent | b53bb2cae512ce4abbc1587a903171a9da6201cf (diff) | |
| download | go-8d39e55c6516be5ee3267b8ce101b324a4f09986.tar.xz | |
liblink: remove arch-specific constants from file format
The relocation and automatic variable types were using
arch-specific numbers. Introduce portable enumerations
instead.
To the best of my knowledge, these are the only arch-specific
bits left in the new object file format.
Remove now, before Go 1.3, because file formats are forever.
LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/87670044
Diffstat (limited to 'src/cmd/8l')
| -rw-r--r-- | src/cmd/8l/8.out.h | 5 | ||||
| -rw-r--r-- | src/cmd/8l/asm.c | 44 |
2 files changed, 22 insertions, 27 deletions
diff --git a/src/cmd/8l/8.out.h b/src/cmd/8l/8.out.h index 3d3c40c755..0dcd74a61d 100644 --- a/src/cmd/8l/8.out.h +++ b/src/cmd/8l/8.out.h @@ -655,11 +655,6 @@ enum D_INDIR, /* additive */ D_CONST2 = D_INDIR+D_INDIR, - D_SIZE, /* 8l internal */ - D_PCREL, - D_GOTOFF, - D_GOTREL, - D_TLS, T_TYPE = 1<<0, T_INDEX = 1<<1, diff --git a/src/cmd/8l/asm.c b/src/cmd/8l/asm.c index cc4ec564bd..6bd2c1fdb7 100644 --- a/src/cmd/8l/asm.c +++ b/src/cmd/8l/asm.c @@ -100,12 +100,12 @@ adddynrel(LSym *s, Reloc *r) diag("unexpected R_386_PC32 relocation for dynamic symbol %s", targ->name); if(targ->type == 0 || targ->type == SXREF) diag("unknown symbol %s in pcrel", targ->name); - r->type = D_PCREL; + r->type = R_PCREL; r->add += 4; return; case 256 + R_386_PLT32: - r->type = D_PCREL; + r->type = R_PCREL; r->add += 4; if(targ->type == SDYNIMPORT) { addpltsym(ctxt, targ); @@ -123,21 +123,21 @@ adddynrel(LSym *s, Reloc *r) return; } s->p[r->off-2] = 0x8d; - r->type = D_GOTOFF; + r->type = R_GOTOFF; return; } addgotsym(ctxt, targ); - r->type = D_CONST; // write r->add during relocsym + r->type = R_CONST; // write r->add during relocsym r->sym = S; r->add += targ->got; return; case 256 + R_386_GOTOFF: - r->type = D_GOTOFF; + r->type = R_GOTOFF; return; case 256 + R_386_GOTPC: - r->type = D_PCREL; + r->type = R_PCREL; r->sym = linklookup(ctxt, ".got", 0); r->add += 4; return; @@ -145,11 +145,11 @@ adddynrel(LSym *s, Reloc *r) case 256 + R_386_32: if(targ->type == SDYNIMPORT) diag("unexpected R_386_32 relocation for dynamic symbol %s", targ->name); - r->type = D_ADDR; + r->type = R_ADDR; return; case 512 + MACHO_GENERIC_RELOC_VANILLA*2 + 0: - r->type = D_ADDR; + r->type = R_ADDR; if(targ->type == SDYNIMPORT) diag("unexpected reloc for dynamic symbol %s", targ->name); return; @@ -159,10 +159,10 @@ adddynrel(LSym *s, Reloc *r) addpltsym(ctxt, targ); r->sym = linklookup(ctxt, ".plt", 0); r->add = targ->plt; - r->type = D_PCREL; + r->type = R_PCREL; return; } - r->type = D_PCREL; + r->type = R_PCREL; return; case 512 + MACHO_FAKE_GOTPCREL: @@ -174,13 +174,13 @@ adddynrel(LSym *s, Reloc *r) return; } s->p[r->off-2] = 0x8d; - r->type = D_PCREL; + r->type = R_PCREL; return; } addgotsym(ctxt, targ); r->sym = linklookup(ctxt, ".got", 0); r->add += targ->got; - r->type = D_PCREL; + r->type = R_PCREL; return; } @@ -189,13 +189,13 @@ adddynrel(LSym *s, Reloc *r) return; switch(r->type) { - case D_PCREL: + case R_PCREL: addpltsym(ctxt, targ); r->sym = linklookup(ctxt, ".plt", 0); r->add = targ->plt; return; - case D_ADDR: + case R_ADDR: if(s->type != SDATA) break; if(iself) { @@ -203,7 +203,7 @@ adddynrel(LSym *s, Reloc *r) rel = linklookup(ctxt, ".rel", 0); addaddrplus(ctxt, rel, s, r->off); adduint32(ctxt, rel, ELF32_R_INFO(targ->dynid, R_386_32)); - r->type = D_CONST; // write r->add during relocsym + r->type = R_CONST; // write r->add during relocsym r->sym = S; return; } @@ -249,21 +249,21 @@ elfreloc1(Reloc *r, vlong sectoff) default: return -1; - case D_ADDR: + case R_ADDR: if(r->siz == 4) LPUT(R_386_32 | elfsym<<8); else return -1; break; - case D_PCREL: + case R_PCREL: if(r->siz == 4) LPUT(R_386_PC32 | elfsym<<8); else return -1; break; - case D_TLS: + case R_TLS: if(r->siz == 4) LPUT(R_386_TLS_LE | elfsym<<8); else @@ -299,10 +299,10 @@ machoreloc1(Reloc *r, vlong sectoff) switch(r->type) { default: return -1; - case D_ADDR: + case R_ADDR: v |= MACHO_GENERIC_RELOC_VANILLA<<28; break; - case D_PCREL: + case R_PCREL: v |= 1<<24; // pc-relative bit v |= MACHO_GENERIC_RELOC_VANILLA<<28; break; @@ -337,10 +337,10 @@ archreloc(Reloc *r, LSym *s, vlong *val) if(linkmode == LinkExternal) return -1; switch(r->type) { - case D_CONST: + case R_CONST: *val = r->add; return 0; - case D_GOTOFF: + case R_GOTOFF: *val = symaddr(r->sym) + r->add - symaddr(linklookup(ctxt, ".got", 0)); return 0; } |
