From a95afd67df44efa803e4d3d134e4f8d4f70e7863 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Sat, 3 Oct 2020 19:12:11 +0800 Subject: [PATCH] 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 --- lang/golang/golang/Makefile | 2 ++ 1 file changed, 2 insertions(+) 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