Skip to content

Commit 3c8d6af

Browse files
committed
cmd/link: use -znocopyreloc when dynamic linking
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 135572e commit 3c8d6af

File tree

1 file changed

+12
-0
lines changed
  • src/cmd/link/internal/ld

1 file changed

+12
-0
lines changed

src/cmd/link/internal/ld/lib.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,18 @@ func hostlink() {
11171117
// because lazy PLT resolution can use large amounts of stack at
11181118
// times we cannot allow it to do so.
11191119
argv = append(argv, "-Wl,-znow")
1120+
1121+
// Do not let the host linker generate COPY relocations. These
1122+
// can move symbols out of sections that rely on stable offsets
1123+
// from the beginning of the section (like STYPE).
1124+
argv = append(argv, "-Wl,-znocopyreloc")
1125+
1126+
if SysArch.Family == sys.ARM {
1127+
// The GNU linker will generate COPY relocations on ARM
1128+
// even with -znocopyreloc set. Switch to gold.
1129+
// https://sourceware.org/bugzilla/show_bug.cgi?id=19962
1130+
argv = append(argv, "-fuse-ld=gold")
1131+
}
11201132
}
11211133

11221134
if Iself && len(buildinfo) > 0 {

0 commit comments

Comments
 (0)