Commit 507f4d5f authored by Alex Brainman's avatar Alex Brainman

cmd/link: do not read .bss sections in ldpe

For .bss section symbol ldelf does not set P (raw symbol data).
Make ldpe do the same.

Change-Id: Ib3d558456f505ee568d0972465fa9b08b5794a87
Reviewed-on: https://go-review.googlesource.com/42631Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 8d63408f
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment