]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: fix PE emitRelocations for >4GB base address
authorRuss Cox <rsc@golang.org>
Wed, 14 Apr 2021 16:55:43 +0000 (12:55 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 23 Apr 2021 21:43:03 +0000 (21:43 +0000)
Change-Id: I1dda31bb1efa177159e4e7b4c9c9cc615e2fdc0c
Reviewed-on: https://go-review.googlesource.com/c/go/+/312037
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/link/internal/ld/pe.go

index 9643f9690cda94f5f601a1221a631eea207921d5..3490dd698a224e5fc8f7413ec273be678a0bd259 100644 (file)
@@ -534,12 +534,12 @@ func (f *peFile) emitRelocations(ctxt *Link) {
                                break
                        }
                }
-               eaddr := int32(sect.Vaddr + sect.Length)
+               eaddr := int64(sect.Vaddr + sect.Length)
                for _, s := range syms {
                        if !ldr.AttrReachable(s) {
                                continue
                        }
-                       if ldr.SymValue(s) >= int64(eaddr) {
+                       if ldr.SymValue(s) >= eaddr {
                                break
                        }
                        // Compute external relocations on the go, and pass to PEreloc1
@@ -559,7 +559,7 @@ func (f *peFile) emitRelocations(ctxt *Link) {
                                        ctxt.Errorf(s, "reloc %d to non-coff symbol %s (outer=%s) %d", r.Type(), ldr.SymName(r.Sym()), ldr.SymName(rr.Xsym), ldr.SymType(r.Sym()))
                                }
                                if !thearch.PEreloc1(ctxt.Arch, ctxt.Out, ldr, s, rr, int64(uint64(ldr.SymValue(s)+int64(r.Off()))-base)) {
-                                       ctxt.Errorf(s, "unsupported obj reloc %d/%d to %s", r.Type(), r.Siz(), ldr.SymName(r.Sym()))
+                                       ctxt.Errorf(s, "unsupported obj reloc %v/%d to %s", r.Type(), r.Siz(), ldr.SymName(r.Sym()))
                                }
                        }
                }