mirror of
https://github.com/golang/go
synced 2024-11-23 20:40:07 -07:00
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/42631 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
8d63408f46
commit
507f4d5f48
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user