cmd/dist, cmd/link, cmd/go: make c-shared work on windows

Thanks to Christopher Nelson for spearheading the effort.

Fixes #11058

Change-Id: Icafabac8dc697626ff1bd943cc577b0b1cc6b349
Reviewed-on: https://go-review.googlesource.com/69091
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Alex Brainman 2017-10-05 17:36:13 +11:00
parent 0174858c71
commit bb0bfd002a
4 changed files with 19 additions and 8 deletions

View file

@ -592,7 +592,7 @@ func (ctxt *Link) loadlib() {
}
if ctxt.Arch == sys.Arch386 {
if (ctxt.BuildMode == BuildModeCArchive && Iself) || ctxt.BuildMode == BuildModeCShared || ctxt.BuildMode == BuildModePIE || ctxt.DynlinkingGo() {
if (ctxt.BuildMode == BuildModeCArchive && Iself) || (ctxt.BuildMode == BuildModeCShared && Headtype != objabi.Hwindows) || ctxt.BuildMode == BuildModePIE || ctxt.DynlinkingGo() {
got := ctxt.Syms.Lookup("_GLOBAL_OFFSET_TABLE_", 0)
got.Type = sym.SDYNIMPORT
got.Attr |= sym.AttrReachable
@ -1126,9 +1126,12 @@ func (ctxt *Link) hostlink() {
if ctxt.UseRelro() {
argv = append(argv, "-Wl,-z,relro")
}
// Pass -z nodelete to mark the shared library as
// non-closeable: a dlclose will do nothing.
argv = append(argv, "-shared", "-Wl,-z,nodelete")
argv = append(argv, "-shared")
if Headtype != objabi.Hwindows {
// Pass -z nodelete to mark the shared library as
// non-closeable: a dlclose will do nothing.
argv = append(argv, "-Wl,-z,nodelete")
}
}
case BuildModeShared:
if ctxt.UseRelro() {