Commit 700a126c authored by Rob Pike's avatar Rob Pike

cmd/ld: fix check for address wrap in relocation

PC-relative needs a signed offset; others need unsigned.
Also fix signedness of 32-bit relocation on Windows.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/9039045
parent e2b2e0d8
...@@ -259,8 +259,7 @@ relocsym(Sym *s) ...@@ -259,8 +259,7 @@ relocsym(Sym *s)
cursym = s; cursym = s;
diag("bad reloc size %#ux for %s", siz, r->sym->name); diag("bad reloc size %#ux for %s", siz, r->sym->name);
case 4: case 4:
// TODO: Test is causing breakages on ARM and Windows. Disable for now. if((r->type == D_PCREL && o != (int32)o) || (r->type != D_PCREL && o != (uint32)o)) {
if(0 && o != (int32)o) {
cursym = S; cursym = S;
diag("relocation address is too big: %#llx", o); diag("relocation address is too big: %#llx", o);
} }
......
...@@ -291,7 +291,7 @@ ldpe(Biobuf *f, char *pkg, int64 len, char *pn) ...@@ -291,7 +291,7 @@ ldpe(Biobuf *f, char *pkg, int64 len, char *pn)
case IMAGE_REL_AMD64_ADDR32: // R_X86_64_PC32 case IMAGE_REL_AMD64_ADDR32: // R_X86_64_PC32
case IMAGE_REL_AMD64_ADDR32NB: case IMAGE_REL_AMD64_ADDR32NB:
rp->type = D_PCREL; rp->type = D_PCREL;
rp->add = le32(rsect->base+rp->off); rp->add = (int32)le32(rsect->base+rp->off);
break; break;
case IMAGE_REL_I386_DIR32NB: case IMAGE_REL_I386_DIR32NB:
case IMAGE_REL_I386_DIR32: case IMAGE_REL_I386_DIR32:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment