Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version
)?
latest
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env
)?
ppc64le
What did you do?
Tried to run binaries built as PIE.
What did you expect to see?
Correct execution
What did you see instead?
Error messages like this:
./main.exe: error while loading shared libraries: R_PPC64_ADDR16_HA re10f2f8fa4 for symbol `' out of range
2018/09/05 09:53:14 Failed: exit status 127
on newer distros.
The problem is related to issues #27510 and #21954 and can still be reproduced on many distros by passing -pie as a linker option.
The solution to the above issues was to use -buildmode=pie but that doesn't correct all problems. When linking a program with -pie on ppc64le then all code should be built as PIC. When some code is not PIC there could be relocations created like R_PPC64_ADDR16_HA which will fail with the above error if the relocated addresses are too big. On some distros/kernels we get lucky and no failures occur if the addresses stay small enough but on newer distros the runtime relocation errors can occur.
When using -buildmode=pie the -shared option is set to force the compiles to be built as PIC but it still links in stdlib which was not built as PIC. Likewise any library linked in should be PIC. When all the code is has been built as PIC then this relocation would not be generated and the PIE should work.
One further question is whether all code should be PIC if the gcc being used for the link passes -pie by default and stop setting -no-pie.
Activity