From 700a126c64948f91822dcc0380f32438dad6fc71 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Tue, 30 Apr 2013 09:10:10 -0700 Subject: [PATCH] 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 --- src/cmd/ld/data.c | 3 +-- src/cmd/ld/ldpe.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cmd/ld/data.c b/src/cmd/ld/data.c index c57c0c69b61..263dd25828c 100644 --- a/src/cmd/ld/data.c +++ b/src/cmd/ld/data.c @@ -259,8 +259,7 @@ relocsym(Sym *s) cursym = s; diag("bad reloc size %#ux for %s", siz, r->sym->name); case 4: - // TODO: Test is causing breakages on ARM and Windows. Disable for now. - if(0 && o != (int32)o) { + if((r->type == D_PCREL && o != (int32)o) || (r->type != D_PCREL && o != (uint32)o)) { cursym = S; diag("relocation address is too big: %#llx", o); } diff --git a/src/cmd/ld/ldpe.c b/src/cmd/ld/ldpe.c index 7a5bc0c6083..033e522f277 100644 --- a/src/cmd/ld/ldpe.c +++ b/src/cmd/ld/ldpe.c @@ -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_ADDR32NB: rp->type = D_PCREL; - rp->add = le32(rsect->base+rp->off); + rp->add = (int32)le32(rsect->base+rp->off); break; case IMAGE_REL_I386_DIR32NB: case IMAGE_REL_I386_DIR32: