cmd/link: pass the external linker's own arguments to flag probes

The external linker command may carry arguments of its own, as in
CC="ccache gcc" or the wrapper script used by TestScript/cgo_path_space_quote.
linkerFlagSupported ran only extld()[0], dropping those arguments, so a
wrapper that needs them failed and every probe reported "flag not
supported".

The consequential one is -no-pie: without it, a C toolchain that defaults
to PIE links non-PIC Go text into a PIE. On amd64 that only produces
DT_TEXTREL, but on ppc64le the absolute ADDR16_HA relocations become
dynamic relocations that ld.so cannot fit, and the program dies at startup
with "R_PPC64_ADDR16_HA reloc at 0x... for symbol `' out of range".

Pass the linker as an argv slice and forward linker[1:] to the probe.
Do the same for peHasLoadConfigDirectorySupport, and stop
passLongArgsInResponseFile from moving the linker's own arguments into the
response file, which the program named by argv[0] need not know how to
expand.

cmd/go already handles this correctly in gccSupportsFlag.

Should fix cmd/go TestScript/cgo_path_space_quote on ppc64,
where "$(which cc)" and "$(which cc) gcc" are different.

Fixes #81164.

Change-Id: Idad6ff5a31689b28f617e2985898bd732318cb02
Reviewed-on: https://go-review.googlesource.com/c/go/+/823024
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2 files changed
tree: d0527703f8959cad48621769dadd14af3eecf6fe
  1. .github/
  2. api/
  3. doc/
  4. lib/
  5. misc/
  6. src/
  7. test/
  8. .gitattributes
  9. .gitignore
  10. codereview.cfg
  11. CONTRIBUTING.md
  12. go.env
  13. LICENSE
  14. PATENTS
  15. README.md
  16. SECURITY.md
README.md

The Go Programming Language

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.

Gopher image Gopher image by Renee French, licensed under Creative Commons 4.0 Attribution license.

Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.

Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.

Download and Install

Binary Distributions

Official binary distributions are available at https://go.dev/dl/.

After downloading a binary release, visit https://go.dev/doc/install for installation instructions.

Install From Source

If a binary distribution is not available for your combination of operating system and architecture, visit https://go.dev/doc/install/source for source installation instructions.

Contributing

Go is the work of thousands of contributors. We appreciate your help!

To contribute, please read the contribution guidelines at https://go.dev/doc/contribute.

Note that the Go project uses the issue tracker for bug reports and proposals only. See https://go.dev/wiki/Questions for a list of places to ask questions about the Go language.