var sh [16]IMAGE_SECTION_HEADER
+// shNames stores full names of PE sections stored in sh.
+var shNames []string
+
var dd []IMAGE_DATA_DIRECTORY
type Imp struct {
var nexport int
-func addpesection(ctxt *Link, name string, sectsize int, filesize int) *IMAGE_SECTION_HEADER {
+func addpesectionWithLongName(ctxt *Link, shortname, longname string, sectsize int, filesize int) *IMAGE_SECTION_HEADER {
if pensect == 16 {
Errorf(nil, "too many sections")
errorexit()
h := &sh[pensect]
pensect++
- copy(h.Name[:], name)
+ copy(h.Name[:], shortname)
+ shNames = append(shNames, longname)
h.VirtualSize = uint32(sectsize)
h.VirtualAddress = uint32(nextsectoff)
nextsectoff = int(Rnd(int64(nextsectoff)+int64(sectsize), PESECTALIGN))
return h
}
+func addpesection(ctxt *Link, name string, sectsize int, filesize int) *IMAGE_SECTION_HEADER {
+ return addpesectionWithLongName(ctxt, name, name, sectsize, filesize)
+}
func chksectoff(ctxt *Link, h *IMAGE_SECTION_HEADER, off int64) {
if off != int64(h.PointerToRawData) {
Errorf(nil, "%s.PointerToRawData = %#x, want %#x", cstring(h.Name[:]), uint64(int64(h.PointerToRawData)), uint64(off))
off := strtbladd(name)
s := fmt.Sprintf("/%d", off)
- h := addpesection(ctxt, s, int(size), int(size))
+ h := addpesectionWithLongName(ctxt, s, name, int(size), int(size))
h.Characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_DISCARDABLE
return h