}
}
+// pad adds zeros to the section sect. It writes as many bytes
+// as necessary to make section sect.SizeOfRawData bytes long.
+// It assumes that n bytes are already written to the file.
+func (sect *peSection) pad(n uint32) {
+ strnput("", int(sect.SizeOfRawData-n))
+}
+
// write writes COFF section sect into the output file.
func (sect *peSection) write() error {
h := pe.SectionHeader32{
isect := pefile.addSection(".idata", int(n), int(n))
isect.Characteristics = IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE
isect.checkOffset(startoff)
- strnput("", int(uint64(isect.SizeOfRawData)-n))
+ isect.pad(uint32(n))
endoff := coutbuf.Offset()
// write FirstThunks (allocated in .data section)
for i := 0; i < nexport; i++ {
strnput(dexport[i].Extname, len(dexport[i].Extname)+1)
}
- strnput("", int(sect.SizeOfRawData-uint32(size)))
+ sect.pad(uint32(size))
}
// perelocsect relocates symbols from first in section sect, and returns
// write COFF string table
pefile.stringTable.write()
if Linkmode != LinkExternal {
- strnput("", int(h.SizeOfRawData-uint32(size)))
+ h.pad(uint32(size))
}
}
}
Cwrite(rsrcsym.P)
- strnput("", int(int64(h.SizeOfRawData)-rsrcsym.Size))
+ h.pad(uint32(rsrcsym.Size))
// update data directory
dd[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress = h.VirtualAddress