aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/asm
diff options
context:
space:
mode:
authorquasilyte <quasilyte@gmail.com>2018-04-15 15:20:33 +0300
committerIlya Tocar <ilya.tocar@intel.com>2018-04-17 14:39:08 +0000
commit58b18cfda5fa96330df00c529c36f207eae08cbc (patch)
treed890827a9b82497c2ba9f4c983ced86cdb5c7e72 /src/cmd/asm
parent7457767876645b543af84eeb091779610a715348 (diff)
downloadgo-58b18cfda5fa96330df00c529c36f207eae08cbc.tar.xz
cmd/internal/obj/x86: better error msg for offset overflow on AMD64
Say "offset too large" instead of "invalid instruction" when assembling for AMD64. GOARCH=386 already reports error correctly. Fixed #24871 Change-Id: Iab029307b5c5edbb45f9df4b64c60ecb5f101349 Reviewed-on: https://go-review.googlesource.com/107116 Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/asm')
-rw-r--r--src/cmd/asm/internal/asm/testdata/386enc.s6
-rw-r--r--src/cmd/asm/internal/asm/testdata/amd64enc_extra.s3
-rw-r--r--src/cmd/asm/internal/asm/testdata/amd64error.s11
3 files changed, 20 insertions, 0 deletions
diff --git a/src/cmd/asm/internal/asm/testdata/386enc.s b/src/cmd/asm/internal/asm/testdata/386enc.s
index 94a06de69c..8fe20511d1 100644
--- a/src/cmd/asm/internal/asm/testdata/386enc.s
+++ b/src/cmd/asm/internal/asm/testdata/386enc.s
@@ -12,5 +12,11 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
MOVQ 8(SP), M0 // 0f6f442408
MOVQ M0, (AX) // 0f7f00
MOVQ M0, (BX) // 0f7f03
+ // On non-64bit arch, Go asm allowed uint32 offsets instead of int32.
+ // These tests check that property for backwards-compatibility.
+ MOVL 2147483648(AX), AX // 8b8000000080
+ MOVL -2147483648(AX), AX // 8b8000000080
+ ADDL 2147483648(AX), AX // 038000000080
+ ADDL -2147483648(AX), AX // 038000000080
// End of tests.
RET
diff --git a/src/cmd/asm/internal/asm/testdata/amd64enc_extra.s b/src/cmd/asm/internal/asm/testdata/amd64enc_extra.s
index ab2c7efe0b..d5aad5fe28 100644
--- a/src/cmd/asm/internal/asm/testdata/amd64enc_extra.s
+++ b/src/cmd/asm/internal/asm/testdata/amd64enc_extra.s
@@ -296,5 +296,8 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
// Test VPERMQ with both uint8 and int8 immediate args
VPERMQ $-40, Y8, Y8 // c4407800c0d8
VPERMQ $216, Y8, Y8 // c443fd00c0d8
+ // Check that LEAL is permitted to use overflowing offset.
+ LEAL 2400959708(BP)(R10*1), BP // 428dac15dcbc1b8f
+ LEAL 3395469782(AX)(R10*1), AX // 428d8410d6c162ca
// End of tests.
RET
diff --git a/src/cmd/asm/internal/asm/testdata/amd64error.s b/src/cmd/asm/internal/asm/testdata/amd64error.s
index 32512fc229..da325c9d98 100644
--- a/src/cmd/asm/internal/asm/testdata/amd64error.s
+++ b/src/cmd/asm/internal/asm/testdata/amd64error.s
@@ -34,4 +34,15 @@ TEXT errors(SB),$0
VPGATHERDQ X7, 664(X2*8), X2 // ERROR "mask, index, and destination registers should be distinct"
// Non-X0 for Yxr0 should produce an error
BLENDVPD X1, (BX), X2 // ERROR "invalid instruction"
+ // Check offset overflow. Must fit in int32.
+ MOVQ 2147483647+1(AX), AX // ERROR "offset too large"
+ MOVQ 3395469782(R10), R8 // ERROR "offset too large"
+ LEAQ 3395469782(AX), AX // ERROR "offset too large"
+ ADDQ 3395469782(AX), AX // ERROR "offset too large"
+ ADDL 3395469782(AX), AX // ERROR "offset too large"
+ ADDW 3395469782(AX), AX // ERROR "offset too large"
+ LEAQ 433954697820(AX), AX // ERROR "offset too large"
+ ADDQ 433954697820(AX), AX // ERROR "offset too large"
+ ADDL 433954697820(AX), AX // ERROR "offset too large"
+ ADDW 433954697820(AX), AX // ERROR "offset too large"
RET