Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/link: external linking can fail on Solaris 11.2+ #14957
Bootstrapping with Go 1.4.3
Fixes a problem when using the external linker on Solaris. The Solaris external linker still doesn't work due to issue #14957. The problem is, for example, with `go test cmd/objdump`: objdump_test.go:71: go build fmthello.go: exit status 2 # command-line-arguments /var/gcc/iant/go/pkg/tool/solaris_amd64/link: running gcc failed: exit status 1 Undefined first referenced symbol in file x_cgo_callers /tmp/go-link-355600608/go.o ld: fatal: symbol referencing errors collect2: error: ld returned 1 exit status Change-Id: I54917cfd5c288ee77ea25c439489bd2c9124fe73 Reviewed-on: https://go-review.googlesource.com/21392 Run-TryBot: Ian Lance Taylor <email@example.com> Reviewed-by: David Crawshaw <firstname.lastname@example.org>
Unfortunately, Go just happens to be the victim of a bug in the Solaris 11.2 and later linker. This issue is also trivially reproducible using gcc alone without Go:
The reason we are seeing this issue with Go is due to the changes applied for issue #13247 which added this seemingly innocuous logic to src/cmd/link/internal/ld/symtab.go:
This adds a NULL STT_FILE entry to the symtab; this seems to be allowed per the System V ABI, so probably is a valid thing to do. However, this in turn triggers a silent bug that has existed for a few years (since sometime in the Solaris 11.2 release cycle) in the Solaris linker; ld(1)'s local symbol counting is being thrown off in some manner. This in turn trips up logic added during the Solaris 11.2 release cycle to ensure that elf output sections are in the expected order:
In versions of Solaris that have this functionality, this can be worked around by using "-z relax=secadj".
However, the simplest workaround is likely to simply have STT_FILE use a name of some sort:
...which avoids the issue. This issue will be resolved in a future update to Solaris, but a workaround seems appropriate.
I will happily contribute a CL based on whatever the preferred solution is.
@minux I did not choose the path of using "-z relax-secadj" for the following reasons:
@bradfitz I'd like to see it pass on a builder too, but I can't solve that problem at the moment; the best I can do is provide output of test results from a Solaris box and ensure that it hasn't broken any existing builders, as has been the case for all of my contributions thus far. Thanks.