-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
go build with CGO on MIPS little endian 64 produces binary with invalid exec format #68965
Comments
For this example What is the output of |
`go build -x -o hello hello.go` output
|
Thanks. Unfortunately I now realize the we need to see something different. What is the output of |
Sure, no problem. Output of `go build -ldflags=-v`
|
Thanks. What is the output of |
If you build a pure-Go binary (without cgo), does it run? What is the output of |
|
Yes, a pure go binary runs
|
output of
|
I don't see anything obvious here. Does gcc work by itself? Can you run |
It does
|
I'm running out of ideas. Either way we are invoking GCC to create an executable. I don't see any relevant command line flags. I don't know why the kernel is unhappy with the executable generated by GCC. I guess show the output of |
I couldn't find anything obvious either. I suspect it has to do with either Go itself or the fact that I'm attempting to run the binary in an emulated environment (docker, which underneath has QEMU). I couldn't get my hands on any hardware with mips64el to rule out a fault in Go. Maybe some of you have such access and could run a test on it? |
readelf -hln hello-c output (the GCC compiled C binary)
readelf -hln hello output (the Go & GCC compiled CGO binary)
|
We routinely run Go builds and tests on mips64 and mips64el hardware running Linux, and those tests are passing. |
Thanks. The obvious difference is that GCC is generating a PIE whereas Go is generating an executable. I don't know why that would be and I don't know why it would matter. Try building with |
|
Argh. OK, please try |
It does, but it's runnable
|
OK, I'm really out of ideas now. Sorry. Maybe someone else will think of something. |
Timed out in state WaitingForInfo. Closing. (I am just a bot, though. Please speak up if this is a mistake or you have the requested information.) |
Go version
go version go1.22.5 linux/mips64le
Output of
go env
in your module/workspace:What did you do?
wget
,gcc
, and Go (included Dockerfile)What did you see happen?
./hello
file hello
hello: ELF 64-bit LSB executable, MIPS, MIPS64 rel2 version 1 (SYSV), dynamically linked, interpreter /lib64/ld.so.1, BuildID[sha1]=a345b82433eab00866dcb465077034aa0b619a72, for GNU/Linux 3.2.0, with debug_info, not stripped
What did you expect to see?
Go build produces a valid executable binary that when run with
./hello
outputsThe text was updated successfully, but these errors were encountered: