]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/cmd/link/internal/ld/lib.go
[dev.boringcrypto] all: merge master into dev.boringcrypto
[gostls13.git] / src / cmd / link / internal / ld / lib.go
index 4aca36db9866d97ffc8a92195c85f8fd8cdff58d..5b82dc287d20bd9487908e15244d341f46935c57 100644 (file)
@@ -1104,7 +1104,6 @@ func hostlinksetup(ctxt *Link) {
                *flagTmpdir = dir
                ownTmpDir = true
                AtExit(func() {
-                       ctxt.Out.Close()
                        os.RemoveAll(*flagTmpdir)
                })
        }
@@ -1271,7 +1270,10 @@ func (ctxt *Link) hostlink() {
                if ctxt.DynlinkingGo() && buildcfg.GOOS != "ios" {
                        // -flat_namespace is deprecated on iOS.
                        // It is useful for supporting plugins. We don't support plugins on iOS.
-                       argv = append(argv, "-Wl,-flat_namespace")
+                       // -flat_namespace may cause the dynamic linker to hang at forkExec when
+                       // resolving a lazy binding. See issue 38824.
+                       // Force eager resolution to work around.
+                       argv = append(argv, "-Wl,-flat_namespace", "-Wl,-bind_at_load")
                }
                if !combineDwarf {
                        argv = append(argv, "-Wl,-S") // suppress STAB (symbolic debugging) symbols
@@ -1500,8 +1502,19 @@ func (ctxt *Link) hostlink() {
                        }
                        return strings.Trim(string(out), "\n")
                }
-               argv = append(argv, getPathFile("crtcxa.o"))
-               argv = append(argv, getPathFile("crtdbase.o"))
+               // Since GCC version 11, the 64-bit version of GCC starting files
+               // are now suffixed by "_64". Even under "-maix64" multilib directory
+               // "crtcxa.o" is 32-bit.
+               crtcxa := getPathFile("crtcxa_64.o")
+               if !filepath.IsAbs(crtcxa) {
+                       crtcxa = getPathFile("crtcxa.o")
+               }
+               crtdbase := getPathFile("crtdbase_64.o")
+               if !filepath.IsAbs(crtdbase) {
+                       crtdbase = getPathFile("crtdbase.o")
+               }
+               argv = append(argv, crtcxa)
+               argv = append(argv, crtdbase)
        }
 
        if ctxt.linkShared {