aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link/internal/ld/lib.go
diff options
context:
space:
mode:
authorThan McIntosh <thanm@google.com>2024-03-13 17:49:32 +0000
committerThan McIntosh <thanm@google.com>2024-03-15 16:11:52 +0000
commit88480fadcc5874f880623ca50713d0c62cc5259b (patch)
tree13850dc7f3cfa5c7229c46e109695b8aadc6c734 /src/cmd/link/internal/ld/lib.go
parentd838e4dcdf89124ed051e1c53e8472e900664a6b (diff)
downloadgo-88480fadcc5874f880623ca50713d0c62cc5259b.tar.xz
cmd/link: support -bindnow option and permit use of "-Wl,-z,now"
This is a partial roll-forward of CL 473495, which was subsequently reverted. The second half of CL 473495 will appear in a future CL. In this patch we introduce a new Go linker "-bindnow" command line flag, and update the Go command to permit the use of the -Wl,-z,now option, to allow users to produce binaries that have immediate binding. Updates #45681. Change-Id: Idd61b0d6597bcd37b16c343714c55a4ef6dfb534 Reviewed-on: https://go-review.googlesource.com/c/go/+/571416 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/cmd/link/internal/ld/lib.go')
-rw-r--r--src/cmd/link/internal/ld/lib.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
index ae19896077..c68da4070b 100644
--- a/src/cmd/link/internal/ld/lib.go
+++ b/src/cmd/link/internal/ld/lib.go
@@ -1604,12 +1604,16 @@ func (ctxt *Link) hostlink() {
}
var altLinker string
- if ctxt.IsELF && ctxt.DynlinkingGo() {
- // We force all symbol resolution to be done at program startup
+ if ctxt.IsELF && (ctxt.DynlinkingGo() || *flagBindNow) {
+ // For ELF targets, when producing dynamically linked Go code
+ // or when immediate binding is explicitly requested,
+ // we force all symbol resolution to be done at program startup
// because lazy PLT resolution can use large amounts of stack at
// times we cannot allow it to do so.
argv = append(argv, "-Wl,-z,now")
+ }
+ if ctxt.IsELF && ctxt.DynlinkingGo() {
// Do not let the host linker generate COPY relocations. These
// can move symbols out of sections that rely on stable offsets
// from the beginning of the section (like sym.STYPE).