]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/ld: fix check for address wrap in relocation
authorRob Pike <r@golang.org>
Tue, 30 Apr 2013 16:10:10 +0000 (09:10 -0700)
committerRob Pike <r@golang.org>
Tue, 30 Apr 2013 16:10:10 +0000 (09:10 -0700)
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
src/cmd/ld/ldpe.c

index c57c0c69b61cd21e27d8d33d191e95bf5545a1ff..263dd25828cd05fa42de9b336c4572c07ea046ec 100644 (file)
@@ -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);
                        }
index 7a5bc0c6083ff4d6274e7636626b93a6193869e1..033e522f277eb9e78262687dd8129849f65167fc 100644 (file)
@@ -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: