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)
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
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)