-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: failure of 'internal linking of -buildmode=pie' test on (some) Linuxes #17068
Comments
Hm it passed for me earlier today:
https://launchpadlibrarian.net/283851576/buildlog_ubuntu-xenial-amd64.golang-tip_201609112338.4ba2a49~ppa1~ubuntu16.04.1_BUILDING.txt.gz
The test was added in the commit you mention, so unfortunately that's not
very interesting information.
|
However it does fail locally for me. Maybe it's a dependence on kernel version. It seems that runtime.firstmoduledata lacks any relocations. In fact it seems that the linker lacks any facility to emit relative relocations at all, so I don't understand how this could possibly work – how can an executable with static data be PIE without relative relocations? |
Something has gone very wrong. Somewhere in my patch series I must have broken something, and my old Ubuntu 14.04 isn't showing it. Looking into it. |
(I think this is some fallout from my backing off adding BuildmodePIE to the DynlinkingGo function in cmd/link.) |
Ah yes, I see the problem: it's me. When I was using DynlinkingGo, I was tripping the other condition for host linking without realizing, so all of my original poking around the output for the right relocations was done on a host linked binary. Then I changed it so I don't host link, but by that point I was just testing all my binaries worked, and my linux system is far too forgiving. So I have a bunch more code to write to generate all the appropriate relocations. I'll send a CL disabling internal PIE for now, as this may take a few days. |
There's more work to do. Updates #17068 Change-Id: I4e16c0e8e9ac739e1fe266224c3769f6c5b2e070 Reviewed-on: https://go-review.googlesource.com/29076 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Even after pulling the above commit I still see the same test failure:
|
@siebenmann could I impose on you to try undoing the second part of 1a42d8f and see if that fixes it? That is, turn cmd/link/internal/ld/lib.go:639 from
into
I don't know why that would matter, but as the comment above it says, it's a very unusual state for a binary as far as glibc is concerned. |
Making this change still leaves the test failing with a segmentation fault. |
Oh, the comment on the code I just changed is a little misleading. It doesn't force external linking, it just sets it to external if no link mode was set. For now I'll disable the test in cmd/dist. |
CL https://golang.org/cl/29079 mentions this issue. |
With the change from this CL applied by hand, an all.bash build on my machine succeeds. |
Updates #17068 Change-Id: I61b75ec07ca8705a678677d262e11b16848cddf3 Reviewed-on: https://go-review.googlesource.com/29079 Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
CL 29079 was a wild red herring chase. Starting from the beginning: On Ubuntu 14.04 I can successfully build and run a hello world program with
On Ubuntu 16.04 it crashes. It also crashed on 14.04 if it is run under gdb. It gives a nice clear error when it does so:
That combined with Ian's explanation on CL 29079 makes everything clear, because gdb loads PIE at a fixed and unusual address. A relocation that needs to be statically resolved as PC-relative is instead being statically resolved as something else, probably absolute to the beginning of the program. |
I don't see anything from Ian on CL 29079? I think the problem is that not nearly enough relocations are being emitted:
I got confused a bit by the lack of relative relocations but of course R_X86_64_64 should work fine, even if it's a bit inefficient. But there aren't enough of them. There's this in adddynrel:
which looks a bit suspicious but the naive thing of adding "&& Buildmode != BuildmodePIE" on the end makes the linker consume unbounded amounts of RAM... |
Ah you mean CL 29090. And I think that is a red herring: this isn't about code->data references, it's about data->data references. |
CL https://golang.org/cl/29119 mentions this issue. |
CL https://golang.org/cl/29118 mentions this issue. |
For #17068 Change-Id: I4e3ab166f08100292b779b651a9acfbfb44a55cd Reviewed-on: https://go-review.googlesource.com/29119 Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version devel +4ba2a49 Sun Sep 11 23:38:44 2016 +0000 linux/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOOS="linux"
What did you do?
On 64-bit Fedora 24 and Ubuntu 16.04 (at least) go from source using the git tip fails currently with the error:
According to git bisect, this problem first appears in commit 1a42d8f. This problem doesn't happen on Ubuntu 14.04 amd64, where the test passes:
The text was updated successfully, but these errors were encountered: