Skip to content

Commit 790f250

Browse files
committed
cmd/link/internal/ld: fix text section splitting for ARM
Fix a problem with trampoline generation for ARM that was causing link failures when building selected k8s targets. Representative error (this is coming from the external linker): go.go:(.text+...): relocation truncated to fit: R_ARM_CALL against `runtime.duffcopy' The Go linker is supposed to be limiting text section size for ARM to 0x1c00000 bytes, however due to a problem in the tramp generation phase this limit wasn't being enforced. Updates #58428. Fixes #58425. Change-Id: I4e778bdcbebeab607a6e626b354ca5109e52a1aa Reviewed-on: https://go-review.googlesource.com/c/go/+/467715 Run-TryBot: Than McIntosh <[email protected]> Reviewed-by: David Chase <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 7f5274a commit 790f250

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/cmd/link/internal/ld/data.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ func maxSizeTrampolines(ctxt *Link, ldr *loader.Loader, s loader.Sym, isTramp bo
8484
}
8585
}
8686

87+
if ctxt.IsARM() {
88+
return n * 20 // Trampolines in ARM range from 3 to 5 instructions.
89+
}
8790
if ctxt.IsPPC64() {
8891
return n * 16 // Trampolines in PPC64 are 4 instructions.
8992
}
@@ -2533,7 +2536,7 @@ func assignAddress(ctxt *Link, sect *sym.Section, n int, s loader.Sym, va uint64
25332536
//
25342537
// The same applies to Darwin/ARM64, with 2^27 byte threshold.
25352538
func splitTextSections(ctxt *Link) bool {
2536-
return (ctxt.IsPPC64() || (ctxt.IsARM64() && ctxt.IsDarwin())) && ctxt.IsExternal()
2539+
return (ctxt.IsARM() || ctxt.IsPPC64() || (ctxt.IsARM64() && ctxt.IsDarwin())) && ctxt.IsExternal()
25372540
}
25382541

25392542
// On Wasm, we reserve 4096 bytes for zero page, then 8192 bytes for wasm_exec.js

0 commit comments

Comments
 (0)