diff options
author | Shenghou Ma <minux.ma@gmail.com> | 2014-05-19 22:39:42 -0400 |
---|---|---|
committer | Shenghou Ma <minux.ma@gmail.com> | 2014-05-19 22:39:42 -0400 |
commit | bfa519202cfb9e307dab42155e5b5e9d2a9a15b4 (patch) | |
tree | 526aaf775a8b2a52d2a2faedfe95f6c2ffd70c03 /src/cmd | |
parent | 126b9b3ba0b3ba7eab6e15cbcc8860762c3917fd (diff) | |
download | go-bfa519202cfb9e307dab42155e5b5e9d2a9a15b4.tar.gz |
cmd/ld: abort if (32-bit) address relocation is negative on amd64.
Update issue 7980
This CL make the linker abort for the example program. For Go 1.4,
we need to find a general way to handle large memory model programs.
LGTM=dave, josharian, iant
R=iant, dave, josharian
CC=golang-codereviews
https://codereview.appspot.com/91500046
Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/ld/data.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/cmd/ld/data.c b/src/cmd/ld/data.c index 24969db55..55d020710 100644 --- a/src/cmd/ld/data.c +++ b/src/cmd/ld/data.c @@ -243,6 +243,16 @@ relocsym(LSym *s) break; } o = symaddr(r->sym) + r->add; + + // On amd64, 4-byte offsets will be sign-extended, so it is impossible to + // access more than 2GB of static data; fail at link time is better than + // fail at runtime. See http://golang.org/issue/7980. + // Instead of special casing only amd64, we treat this as an error on all + // 64-bit architectures so as to be future-proof. + if((int32)o < 0 && PtrSize > 4 && siz == 4) { + diag("non-pc-relative relocation address is too big: %#llux", o); + errorexit(); + } break; case R_CALL: case R_PCREL: |