Skip to content

cmd/link, cmd/dist: wrong loader/interpreter used with cross-compiled toolchain for ppc64le #53813

Description

@laboger

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

$ go version
go version devel go1.19-4484c30f78 Wed

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
ppc64le

What did you do?

Built a cross toolchain on x86 host targeting ppc64le. By default CGO_ENABLED=0 for cross builds.
Moved the toolchain to a ppc64le machine. Many tests work fine except those that use -buildmode=pie. In those cases the test fails.

What did you expect to see?

Tests using -buildmode=pie work.

What did you see instead?

$ go build -buildmode=pie hello.go
$ ./hello
bash: ./hello: No such file or directory
$ file hello
hello: ELF 64-bit LSB shared object, 64-bit PowerPC or cisco 7500, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, with debug_info, not stripped

Same result if I set GO_LDSO=/libd64/ld64.so.2 before the go build command above.

If I set GO_LDSO=/lib64/ld64.so.2 when building the cross toolchain then it uses the correct path to the loader.

Also, if I build a cross compiled toolchain with a cross gcc on the build machine and set CGO_ENABLED=1, then the go binary is built dynamic but is unusable for the same reason.. With CGO_ENABLED=0, the go binary is static so doesn't have that problem.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions