diff options
author | Tianon Gravi <admwiggin@gmail.com> | 2015-01-15 12:50:40 -0700 |
---|---|---|
committer | Tianon Gravi <admwiggin@gmail.com> | 2015-01-15 12:50:40 -0700 |
commit | 2a0db60599fdd75b1bc3e297180fbe1282763759 (patch) | |
tree | 68d43c3e30d9ab961ddf6b7365201ca6b675b253 /src/cmd/8l/asm.c | |
parent | ef33cba3c8de6c431df56503df51fcd3a473c89e (diff) | |
parent | f154da9e12608589e8d5f0508f908a0c3e88a1bb (diff) | |
download | golang-2a0db60599fdd75b1bc3e297180fbe1282763759.tar.gz |
Merge tag 'upstream/1.4' into debian-experimental
* tag 'upstream/1.4':
Imported Upstream version 1.4
Diffstat (limited to 'src/cmd/8l/asm.c')
-rw-r--r-- | src/cmd/8l/asm.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/cmd/8l/asm.c b/src/cmd/8l/asm.c index c135dce70..98c042403 100644 --- a/src/cmd/8l/asm.c +++ b/src/cmd/8l/asm.c @@ -117,13 +117,21 @@ adddynrel(LSym *s, Reloc *r) case 256 + R_386_GOT32: if(targ->type != SDYNIMPORT) { // have symbol - // turn MOVL of GOT entry into LEAL of symbol itself - if(r->off < 2 || s->p[r->off-2] != 0x8b) { - diag("unexpected GOT reloc for non-dynamic symbol %s", targ->name); + if(r->off >= 2 && s->p[r->off-2] == 0x8b) { + // turn MOVL of GOT entry into LEAL of symbol address, relative to GOT. + s->p[r->off-2] = 0x8d; + r->type = R_GOTOFF; return; } - s->p[r->off-2] = 0x8d; - r->type = R_GOTOFF; + if(r->off >= 2 && s->p[r->off-2] == 0xff && s->p[r->off-1] == 0xb3) { + // turn PUSHL of GOT entry into PUSHL of symbol itself. + // use unnecessary SS prefix to keep instruction same length. + s->p[r->off-2] = 0x36; + s->p[r->off-1] = 0x68; + r->type = R_ADDR; + return; + } + diag("unexpected GOT reloc for non-dynamic symbol %s", targ->name); return; } addgotsym(ctxt, targ); |