Skip to content

Commit

Permalink
Add no-PIC patch for golang
Browse files Browse the repository at this point in the history
See docker-library/golang#91 for details.
  • Loading branch information
dochang committed Jun 3, 2016
1 parent 7c03832 commit 98a5516
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scripts/golang/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ goroot_bootstrap=${bootstrap_prefix}/go
go_archive=/golang.tar.gz
go_root=${prefix}/go

# https://golang.org/issue/14851
no_pic_patch="$(dirname $0)/no-pic.patch"

golang_url() {
printf "https://golang.org/dl/go%s.src.tar.gz" "$1"
}
Expand Down Expand Up @@ -53,6 +56,7 @@ rm -f "${go_archive}"
# Build golang.
export GOROOT_BOOTSTRAP=${goroot_bootstrap}
cd "${go_root}/src"
patch -p2 -i "${no_pic_patch}"
./make.bash

# Remove bootstrap package.
Expand Down
16 changes: 16 additions & 0 deletions scripts/golang/no-pic.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
index 8ccbec9dd634..4e96bfadc260 100644
--- a/src/cmd/link/internal/ld/lib.go
+++ b/src/cmd/link/internal/ld/lib.go
@@ -1194,6 +1194,11 @@ func hostlink() {
argv = append(argv, peimporteddlls()...)
}

+ // The Go linker does not currently support building PIE
+ // executables when using the external linker. See:
+ // https://github.com/golang/go/issues/6940
+ argv = append(argv, "-fno-PIC")
+
if Debug['v'] != 0 {
fmt.Fprintf(&Bso, "host link:")
for _, v := range argv {

0 comments on commit 98a5516

Please sign in to comment.