cmd/link: wrong program header offset when cross-compile to riscv64 when setting -T text alignment #57983
Labels
arch-riscv
Issues solely affecting the riscv64 architecture.
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
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
OutputWhat did you do?
I try to cross-compile an empty main function to RISC-V binary with the following command, trying to put text segment to 0x80200000:
GOOS=linux GOARCH=riscv64 go build -o kernel.elf -ldflags '-T 0x80200000' ./kmain
kmain is a directory containing a main.go with only an empty main func and nothing imports.
After executing, I tried to
readelf -a kernel.elf
, it says 'readelf: Error: the PHDR segment is not covered by a LOAD segment'. And the output program headers like:The offset of the third section is pretty big and cannot be loaded.
When I change GOARCH to 'amd64' or delete -T, nothing above happens: none error and offset is also fine.
What did you expect to see?
none error and offsets of program headers is fine.
What did you see instead?
error and strangely big offset
The text was updated successfully, but these errors were encountered: