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: ppc64le internal linking does not handle TOC correctly #15409
Comments
CL https://golang.org/cl/22379 mentions this issue. |
CL 22372 changed ppc64le to use normal cgo initialization on ppc64le. Doing this uncovered a cmd/link error using internal linking. Opened issue 15409 for the problem. This CL disables the test. Update #15409. Change-Id: Ia1bb6b874c1b5a4df1a0436c8841c145142c30f7 Reviewed-on: https://go-review.googlesource.com/22379 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
FWIW I think if we fix this we could always generate ELFv2-style PIC for CL https://golang.org/cl/22379 mentions this issue. — |
Actually, according the the ABI it is not invalid to have multiple TOCs in a module:
I think this is what the code is trying to do. It doesn't handle .sdata or .sbss sections at all, but I get the impression they are not present with default compiler options? However:
I guess this is where things are going wrong. I don't entirely get how we end up with calls between functions using different TOC pointer values though. It still seems likely to me that moving to a model with a single TOC would make life easier overall. |
Change https://golang.org/cl/304458 mentions this issue: |
The tests in misc/cgo/test fail with -linkmode=internal on ppc64le. From https://build.golang.org/log/a5a334010e62ae540ec0ec4916a8615cae0472d7:
I believe that the problem is this: the PPC ELF v2 ABI requires that every function start with a small prologue that computes the TOC pointer in r2 from the function address in r12. This computation is two instructions; in normal PPC assembler it looks like this:
The symbol
.TOC.
is not defined in an object file, and is magically defined by the linker. The linker must arrange that every function in the same module (shared library or executable) compute the same value for r2.The problem is that cmd/link is using a different value for
.TOC.
for functions defined in different object files. I haven't sorted it all out, but cmd/link seems to use a different.TOC.
symbol for each object file, and to give them different values. This may be correct for the ELF v1 ABI; I'm not sure. It's not correct for the ELF v2 ABI used on PPC64le.The text was updated successfully, but these errors were encountered: