diff --git a/src/cmd/link/internal/ld/ldpe.go b/src/cmd/link/internal/ld/ldpe.go index fd3664c2ed1..14f56d4b3c7 100644 --- a/src/cmd/link/internal/ld/ldpe.go +++ b/src/cmd/link/internal/ld/ldpe.go @@ -162,12 +162,6 @@ func ldpeError(ctxt *Link, input *bio.Reader, pkg string, length int64, pn strin continue } - data, err := sect.Data() - if err != nil { - return err - } - sectdata[sect] = data - name := fmt.Sprintf("%s(%s)", pkg, sect.Name) s := ctxt.Syms.Lookup(name, localSymVersion) @@ -177,18 +171,6 @@ func ldpeError(ctxt *Link, input *bio.Reader, pkg string, length int64, pn strin case IMAGE_SCN_CNT_UNINITIALIZED_DATA | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE: //.bss s.Type = SNOPTRBSS - // It seems like this shouldn't happen, but it does, with symbol "runtime/cgo(.bss)". - // TODO: Figure out why and either document why it is ok or fix it at the source-- - // either by eliminating the all-zero data or - // by making this SNOPTRDATA (IMAGE_SCN_CNT_INITIALIZED_DATA) to begin with. - if len(data) > 0 { - for _, x := range data { - if x != 0 { - Errorf(s, "non-zero data in .bss section: %q", data) - } - } - s.Type = SNOPTRDATA - } case IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE: //.data s.Type = SNOPTRDATA @@ -200,8 +182,15 @@ func ldpeError(ctxt *Link, input *bio.Reader, pkg string, length int64, pn strin return fmt.Errorf("unexpected flags %#06x for PE section %s", sect.Characteristics, sect.Name) } - s.P = data - s.Size = int64(len(data)) + if s.Type != SNOPTRBSS { + data, err := sect.Data() + if err != nil { + return err + } + sectdata[sect] = data + s.P = data + } + s.Size = int64(sect.Size) sectsyms[sect] = s if sect.Name == ".rsrc" { setpersrc(ctxt, s)