aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMotiejus Jakštys <motiejus@jakstys.lt>2022-06-07 05:55:40 +0000
committerCherry Mui <cherryyz@google.com>2022-06-07 14:45:47 +0000
commit38607c553878da21b5042e63997ecb3b7201e684 (patch)
tree05e9dcc8cbdf204d231073feee44530217db1481
parent95b68e1e02fa713719f02f6c59fb1532bd05e824 (diff)
downloadgo-38607c553878da21b5042e63997ecb3b7201e684.tar.gz
go-38607c553878da21b5042e63997ecb3b7201e684.zip
cmd/link: specify -Wl,-z params as documented
Both GNU and LLVM linkers de facto accept `-zPARAM`, and Go sometimes does it. Inconsistently: there are more uses of `-z PARAM` than `-zPARAM`: $ git grep -E -- '-Wl,-z[^,]' master | wc -l 4 $ git grep -E -- '-Wl,-z,' master | wc -l 7 However, not adding a space between `-z` and the param is not documented: llvm-13: $ man ld.lld-13 | grep -E -A1 -w -- "^ +-z" -z option Linker option extensions. gnu ld: $ man ld | grep -E -A1 -w -- "^ +-z" -z keyword The recognized keywords are: -- -z defs Report unresolved symbol references from regular object files. This is done even if the linker is creating a non-symbolic -- -z muldefs Normally when a symbol is defined multiple times, the linker will report a fatal error. These options allow multiple definitions -- -z --imagic ... and thus should be avoided. `zig cc`, when used as the C compiler (`CC="zig cc" go build ...`), will bark, because `zig cc` accepts only `-z PARAM`, as documented. Closes ziglang/zig#11669 Change-Id: I758054ecaa3ce01a72600bf65d7f7b5c3ec46d09 GitHub-Last-Rev: e068e007da9f2b0441ee0aa8b198a7ba3cd93ed3 GitHub-Pull-Request: golang/go#53030 Reviewed-on: https://go-review.googlesource.com/c/go/+/407834 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com>
-rw-r--r--src/cmd/link/internal/ld/lib.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
index 19678adbd5..9a5d89a6f7 100644
--- a/src/cmd/link/internal/ld/lib.go
+++ b/src/cmd/link/internal/ld/lib.go
@@ -1463,12 +1463,12 @@ func (ctxt *Link) hostlink() {
// We force all symbol resolution to be done at program startup
// because lazy PLT resolution can use large amounts of stack at
// times we cannot allow it to do so.
- argv = append(argv, "-Wl,-znow")
+ argv = append(argv, "-Wl,-z,now")
// Do not let the host linker generate COPY relocations. These
// can move symbols out of sections that rely on stable offsets
// from the beginning of the section (like sym.STYPE).
- argv = append(argv, "-Wl,-znocopyreloc")
+ argv = append(argv, "-Wl,-z,nocopyreloc")
if buildcfg.GOOS == "android" {
// Use lld to avoid errors from default linker (issue #38838)