Skip to content

Commit 1a42d8f

Browse files
committed
cmd/link: allow internal PIE linking
Part of adding PIE internal linking on linux/amd64. Change-Id: I5ce01d1974e5d4b1a8cbcc8b08157477631d8d24 Reviewed-on: https://go-review.googlesource.com/28543 Run-TryBot: David Crawshaw <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 04b4dbe commit 1a42d8f

File tree

1 file changed

+4
-5
lines changed
  • src/cmd/link/internal/ld

1 file changed

+4
-5
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,9 @@ func (ctxt *Link) loadlib() {
453453
Linkmode = LinkExternal
454454
}
455455

456-
// Force external linking for PIE executables, as
457-
// internal linking does not support TLS_IE.
458-
if Buildmode == BuildmodePIE {
456+
// Force external linking for PIE binaries on systems
457+
// that do not support internal PIE linking.
458+
if Buildmode == BuildmodePIE && (obj.GOOS != "linux" || SysArch.Family != sys.AMD64) {
459459
Linkmode = LinkExternal
460460
}
461461

@@ -636,8 +636,7 @@ func (ctxt *Link) loadlib() {
636636
// binaries, so leave it enabled on OS X (Mach-O) binaries.
637637
// Also leave it enabled on Solaris which doesn't support
638638
// statically linked binaries.
639-
switch Buildmode {
640-
case BuildmodeExe, BuildmodePIE:
639+
if Buildmode == BuildmodeExe {
641640
if havedynamic == 0 && Headtype != obj.Hdarwin && Headtype != obj.Hsolaris {
642641
*FlagD = true
643642
}

0 commit comments

Comments
 (0)