-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/asm: index out of range (4) #12657
Comments
Reproduced with 46c5856 More generally, any of pseudo registers will cause runtime panic Should If we are going for error, should this check be x86-specific, Another note: empty scaling will result in // Included p.String() output (note that pseudo registers are not recognized).
TEXT asmfunc(SB), $0
CALL (AX)(PC*1) // CALL (AX)(R???-4*1) | runtime error: index out of range
CALL (AX)(SB*1) // CALL (AX)(R???-2*1) | runtime error: index out of range
CALL (AX)(FP*1) // CALL (AX)(R???-1*1) | runtime error: index out of range
RET |
If patch like this is applied: diff --git a/src/cmd/asm/internal/asm/parse.go b/src/cmd/asm/internal/asm/parse.go
index 1d5d073..a278de0 100644
--- a/src/cmd/asm/internal/asm/parse.go
+++ b/src/cmd/asm/internal/asm/parse.go
@@ -790,6 +790,10 @@ func (p *Parser) registerIndirect(a *obj.Addr, prefix rune) {
if r2 != 0 {
p.errorf("unimplemented two-register form")
}
+ if p.arch.InFamily(sys.I386, sys.AMD64) && r1 < 0 {
+ // Reject (R)(Pseudo*scale) forms for x86.
+ p.errorf("illegal addressing mode for pseudo-register")
+ }
a.Index = r1
if scale == 0 && p.arch.Family == sys.ARM64 {
// scale is 1 by default for ARM64 Attempt to compile example above will result in:
|
Change https://golang.org/cl/85419 mentions this issue: |
Change https://golang.org/cl/107835 mentions this issue: |
cmd/asm crashes on the following program:
go version devel +5512ac2 Wed Sep 16 17:56:14 2015 +0000 linux/amd64
The text was updated successfully, but these errors were encountered: