1
0
mirror of https://github.com/golang/go synced 2024-09-30 05:34:35 -06:00

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 <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
David Crawshaw 2016-09-06 08:08:47 -04:00
parent 04b4dbe1f0
commit 1a42d8fbd6

View File

@ -453,9 +453,9 @@ func (ctxt *Link) loadlib() {
Linkmode = LinkExternal
}
// Force external linking for PIE executables, as
// internal linking does not support TLS_IE.
if Buildmode == BuildmodePIE {
// Force external linking for PIE binaries on systems
// that do not support internal PIE linking.
if Buildmode == BuildmodePIE && (obj.GOOS != "linux" || SysArch.Family != sys.AMD64) {
Linkmode = LinkExternal
}
@ -636,8 +636,7 @@ func (ctxt *Link) loadlib() {
// binaries, so leave it enabled on OS X (Mach-O) binaries.
// Also leave it enabled on Solaris which doesn't support
// statically linked binaries.
switch Buildmode {
case BuildmodeExe, BuildmodePIE:
if Buildmode == BuildmodeExe {
if havedynamic == 0 && Headtype != obj.Hdarwin && Headtype != obj.Hsolaris {
*FlagD = true
}