aboutsummaryrefslogtreecommitdiff
path: root/lang/golang
diff options
context:
space:
mode:
authorJeffery To <jeffery.to@gmail.com>2020-10-03 19:12:11 +0800
committerJeffery To <jeffery.to@gmail.com>2020-10-06 16:28:08 +0800
commita95afd67df44efa803e4d3d134e4f8d4f70e7863 (patch)
tree5df5a93475b6e143d222982afe63ede544424a09 /lang/golang
parent93ee27edb8785514142633d41a973a8c5ca79e4c (diff)
golang: Use external linking for target Go
In Go 1.15, the linker now defaults to internal linking mode for -buildmode=pie on amd64 and arm64[1], however this results in go tool binaries with the wrong dynamic linker/interpreter. External linking is still used when PIE is enabled for other platforms, whereas internal linking is used when PIE is not enabled. This changes target Go to always use external linking, to fix PIE binaries for amd64/arm64 and for consistency. [1]: https://golang.org/doc/go1.15#linker Signed-off-by: Jeffery To <jeffery.to@gmail.com>
Diffstat (limited to 'lang/golang')
-rw-r--r--lang/golang/golang/Makefile2
1 files changed, 2 insertions, 0 deletions
diff --git a/lang/golang/golang/Makefile b/lang/golang/golang/Makefile
index 241ba1e37..6990c249e 100644
--- a/lang/golang/golang/Makefile
+++ b/lang/golang/golang/Makefile
@@ -271,6 +271,8 @@ PKG_GO_VARS= \
PKG_GO_LDFLAGS= \
-buildid '$(SOURCE_DATE_EPOCH)' \
+ -linkmode external \
+ -extldflags '$(patsubst -z%,-Wl$(comma)-z$(comma)%,$(TARGET_LDFLAGS))' \
$(if $(CONFIG_NO_STRIP)$(CONFIG_DEBUG),,-s -w)
# setting -trimpath is not necessary here because the paths inside the