Skip to content
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: amd64: Invalid instruction emits wrong binary without error #59462

Closed
bupjae opened this issue Apr 6, 2023 · 2 comments
Closed

cmd/asm: amd64: Invalid instruction emits wrong binary without error #59462

bupjae opened this issue Apr 6, 2023 · 2 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge

Comments

@bupjae
Copy link

bupjae commented Apr 6, 2023

What version of Go are you using (go version)?

$ go version
go version go1.20.3 windows/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Bupjae\AppData\Local\go-build
set GOENV=C:\Users\Bupjae\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\Bupjae\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Bupjae\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=D:\BupProg\OldGoTest\go\go1.20.3
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=D:\BupProg\OldGoTest\go\go1.20.3\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.20.3
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\Bupjae\AppData\Local\Temp\go-build1676784847=/tmp/go-build -gno-record-gcc-switches

What did you do?

Created demo.s then go build

#include "textflag.h"

TEXT ·foo(SB), NOSPLIT, $0-0
MOVB AH, R8
RET

What did you expect to see?

Build failed with suitable error message. (i.e. asm: "".foo: invalid instruction).

According to Intel® 64 and IA-32 Architectures Software Developer's Manuals, register AH cannot be used if REX prefix is used. Using register R8 needs REX prefix.

What did you see instead?

Build was successful. Disassembling shows following:

000000000045c8a0 <main.foo.abi0>:
  45c8a0:	41 88 e0             	mov    %spl,%r8b
  45c8a3:	c3                   	retq   
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Apr 6, 2023
@randall77
Copy link
Contributor

Dup of #45511 or #14288 ?

@bupjae
Copy link
Author

bupjae commented Apr 6, 2023

I agree that this issue is dup of #14288. Closing.

@bupjae bupjae closed this as not planned Won't fix, can't repro, duplicate, stale Apr 6, 2023
@golang golang locked and limited conversation to collaborators Apr 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge
Projects
None yet
Development

No branches or pull requests

3 participants