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/link: Setting rounding quantum to a value higher than 2M or smaller than 4K breaks. #62660
Comments
@cherrymui With fix patch #527822, trying different values of the Output of compiling the program with -R 0x300000 on arm64 machine:
From the log, we can notice that the first program header offset is less than |
I came up with another solution that may solve this problem, that is, if the
|
I don't think we really care about alignment less than 4K, which is the the minimal possible physical page size on many systems. If one sets -R less than 4K, it is asking for problems. I'll look into the issue with alignment larger than 2M. In the end we don't know or want to list exactly what memory layouts are supported on each system. We ensure the default works well. We do best effort support for some reasonable non-default values. Other than that, one is on their own. |
0x300000 doesn't work not because it is larger than 2M, but because it is not a power of 2. 0x400000 does work. I think it is fine to reject -R value that is not a power of 2 or less than 4K. I don't think we need to go farther than that. I'll send a CL. |
cc @golang/compiler |
Change https://go.dev/cl/528715 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputGO111MODULE='auto'
GOARCH='arm64'
GOBIN=''
GOCACHE='/home/fanzha02/.cache/go-build'
GOENV='/home/fanzha02/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/fanzha02/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/fanzha02/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/fanzha02/work/go_project/govscode/gomain'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/fanzha02/work/go_project/govscode/gomain/pkg/tool/linux_arm64'
GOVCS=''
GOVERSION='devel go1.22-856cf23a8a Thu Sep 14 05:14:44 2023 +0000'
GCCGO='gccgo'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/fanzha02/work/go_project/govscode/gomain/src/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3689557035=/tmp/go-build -gno-record-gcc-switches'
What did you do?
Build a hello.go with:
$ go build -ldflags "-R 0x300000" -o hello_3M hello.go
Run with:
$ ./hello_3M
What did you expect to see?
Hello world!
What did you see instead?
Segment fault
The text was updated successfully, but these errors were encountered: