From: Michael Hudson-Doyle Date: Thu, 15 Apr 2021 03:50:41 +0000 (+1200) Subject: cmd/link: convert -I foo to -Wl,--dynamic-linker,foo when externally linking X-Git-Tag: go1.17beta1~566 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=7252e1e5b6c99189dadb525a0793344ad9d137d5;p=gostls13.git cmd/link: convert -I foo to -Wl,--dynamic-linker,foo when externally linking Fixes #22446 Change-Id: Id5b3fbc9cd3a7d6c4bf4e28428b8cb6d45a9ca92 Reviewed-on: https://go-review.googlesource.com/c/go/+/310349 Run-TryBot: Michael Hudson-Doyle TryBot-Result: Go Bot Trust: Michael Knyszek Reviewed-by: Ian Lance Taylor --- diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index b814a277e6..c840e5ea51 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -1431,6 +1431,14 @@ func (ctxt *Link) hostlink() { argv = append(argv, fmt.Sprintf("-Wl,-rpath,%s", rpath.val)) } + if *flagInterpreter != "" { + // Many linkers support both -I and the --dynamic-linker flags + // to set the ELF interpreter, but lld only supports + // --dynamic-linker so prefer that (ld on very old Solaris only + // supports -I but that seems less important). + argv = append(argv, fmt.Sprintf("-Wl,--dynamic-linker,%s", *flagInterpreter)) + } + // Force global symbols to be exported for dlopen, etc. if ctxt.IsELF { argv = append(argv, "-rdynamic")