]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: count relocations better
authorRuss Cox <rsc@golang.org>
Wed, 14 Apr 2021 23:53:43 +0000 (19:53 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 23 Apr 2021 21:43:01 +0000 (21:43 +0000)
Change-Id: Ie188abeb0194bf266d38c9bd0dda4b8f48934697
Reviewed-on: https://go-review.googlesource.com/c/go/+/312035
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 b70c0693e85384ad92d153fd2eb184993b747d7b..9643f9690cda94f5f601a1221a631eea207921d5 100644 (file)
@@ -524,7 +524,6 @@ func (f *peFile) emitRelocations(ctxt *Link) {
                if sect.Vaddr >= sect.Seg.Vaddr+sect.Seg.Filelen {
                        return 0
                }
-               nrelocs := 0
                sect.Reloff = uint64(ctxt.Out.Offset())
                for i, s := range syms {
                        if !ldr.AttrReachable(s) {
@@ -562,11 +561,11 @@ func (f *peFile) emitRelocations(ctxt *Link) {
                                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()))
                                }
-                               nrelocs++
                        }
                }
                sect.Rellen = uint64(ctxt.Out.Offset()) - sect.Reloff
-               return nrelocs
+               const relocLen = 4 + 4 + 2
+               return int(sect.Rellen / relocLen)
        }
 
        sects := []struct {