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: 386 assembler silently drops indices when indexing symbols #41286

Open
clausecker opened this issue Sep 9, 2020 · 1 comment
Open
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@clausecker
Copy link

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

$ go version
go version go1.15 linux/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
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build142714031=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Create an assembly file with the following content, assemble it for 386:

DATA bar<>(SB)/4, $0x0
GLOBL bar<>(SB), 0, $4

TEXT foo<>(SB), 4, $0
	MOVL bar<>(SB)(AX), AX

Then, dump the resulting object file.

What did you expect to see?

Something like

TEXT foo<1>(SB) gofile../.../bug.s
  bug.s:5		0x142			8b0500000000		MOVL 0(AX), AX		[2:6]R_ADDR:bar		

What did you see instead?

TEXT foo<1>(SB) gofile../.../bug.s
  bug.s:5		0x142			8b0500000000		MOVL 0, AX		[2:6]R_ADDR:bar		

It appears that the index register has been dropped silently. Please either fail this kind of code during assembly or add support for indexing into global symbols.

@cherrymui
Copy link
Member

Index into a global symbol is not a supported addressing mode. We should emit an error.

@andybons andybons added the NeedsFix The path to resolution is known, but the work has not been done. label Sep 10, 2020
@andybons andybons added this to the Unplanned milestone Sep 10, 2020
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants