]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: use -znocopyreloc when dynamic linking
authorDavid Crawshaw <crawshaw@golang.org>
Sat, 16 Apr 2016 15:08:41 +0000 (11:08 -0400)
committerDavid Crawshaw <crawshaw@golang.org>
Mon, 18 Apr 2016 09:03:42 +0000 (09:03 +0000)
On ARM, use the gold linker to avoid copy relocations.
https://sourceware.org/bugzilla/show_bug.cgi?id=19962

Change-Id: Icf82a38d39495d4518812713b957a03a6652c728
Reviewed-on: https://go-review.googlesource.com/22141
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/link/internal/ld/lib.go

index a18098e7e734b518f816030bd6ca25a8774718d0..56a37363100c4a0067291a2cd6918ee25badd73c 100644 (file)
@@ -1117,6 +1117,18 @@ func hostlink() {
                // because lazy PLT resolution can use large amounts of stack at
                // times we cannot allow it to do so.
                argv = append(argv, "-Wl,-znow")
+
+               // 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 STYPE).
+               argv = append(argv, "-Wl,-znocopyreloc")
+
+               if SysArch.Family == sys.ARM {
+                       // The GNU linker will generate COPY relocations on ARM
+                       // even with -znocopyreloc set. Switch to gold.
+                       // https://sourceware.org/bugzilla/show_bug.cgi?id=19962
+                       argv = append(argv, "-fuse-ld=gold")
+               }
        }
 
        if Iself && len(buildinfo) > 0 {