From 3380b180c66ffcee2bec37877f4a5be5ab78fd5c Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Tue, 11 May 2021 22:40:02 -0400 Subject: [PATCH] [release-branch.go1.15] cmd/link: don't cast end address to int32 When linking a very large binary, the section address may not fit in int32. Don't truncate it. Fixes #46127. Updates #46126. Change-Id: Ibcc8d74bf5662611949e547ce44ca8b973de383f Reviewed-on: https://go-review.googlesource.com/c/go/+/319289 Trust: Cherry Mui Run-TryBot: Cherry Mui Reviewed-by: Than McIntosh TryBot-Result: Go Bot (cherry picked from commit af0f8c149e8a4b237910fc7b41739bedc546473c) Reviewed-on: https://go-review.googlesource.com/c/go/+/319370 --- src/cmd/link/internal/ld/elf.go | 2 +- src/cmd/link/internal/ld/macho.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/link/internal/ld/elf.go b/src/cmd/link/internal/ld/elf.go index 78298beafe..36ec4035c3 100644 --- a/src/cmd/link/internal/ld/elf.go +++ b/src/cmd/link/internal/ld/elf.go @@ -1400,7 +1400,7 @@ func elfrelocsect(ctxt *Link, sect *sym.Section, syms []*sym.Symbol) { } ldr := ctxt.loader - eaddr := int32(sect.Vaddr + sect.Length) + eaddr := sect.Vaddr + sect.Length for _, s := range syms { if !s.Attr.Reachable() { continue diff --git a/src/cmd/link/internal/ld/macho.go b/src/cmd/link/internal/ld/macho.go index 5548b8c666..df016f3d43 100644 --- a/src/cmd/link/internal/ld/macho.go +++ b/src/cmd/link/internal/ld/macho.go @@ -1044,7 +1044,7 @@ func machorelocsect(ctxt *Link, sect *sym.Section, syms []*sym.Symbol) { } } - eaddr := int32(sect.Vaddr + sect.Length) + eaddr := sect.Vaddr + sect.Length for _, s := range syms { if !s.Attr.Reachable() { continue