1
0
mirror of https://github.com/golang/go synced 2024-11-07 11:46:17 -07:00

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 <michael.hudson@canonical.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Michael Hudson-Doyle 2021-04-15 15:50:41 +12:00
parent 88655480f3
commit 7252e1e5b6

View File

@ -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")