Browse Source

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>
lilik-openwrt-22.03
Jeffery To 4 years ago
parent
commit
a95afd67df
No known key found for this signature in database GPG Key ID: C616D9E719E868E4
1 changed files with 2 additions and 0 deletions
  1. +2
    -0
      lang/golang/golang/Makefile

+ 2
- 0
lang/golang/golang/Makefile View File

@ -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


Loading…
Cancel
Save