Commit e9abf1a7 authored by Alex Brainman's avatar Alex Brainman

cmd/link: introduce shNames

Introduce a slice that keeps long pe section names as we add them.
It will be used later to output pe symbol table and dwarf relocations.

For #10776.

Change-Id: I02f808a456393659db2354031baf1d4f9e0b2d61
Reviewed-on: https://go-review.googlesource.com/36977Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent a7e25562
...@@ -356,6 +356,9 @@ var oh64 PE64_IMAGE_OPTIONAL_HEADER ...@@ -356,6 +356,9 @@ var oh64 PE64_IMAGE_OPTIONAL_HEADER
var sh [16]IMAGE_SECTION_HEADER var sh [16]IMAGE_SECTION_HEADER
// shNames stores full names of PE sections stored in sh.
var shNames []string
var dd []IMAGE_DATA_DIRECTORY var dd []IMAGE_DATA_DIRECTORY
type Imp struct { type Imp struct {
...@@ -379,7 +382,7 @@ var dexport [1024]*Symbol ...@@ -379,7 +382,7 @@ var dexport [1024]*Symbol
var nexport int 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 { if pensect == 16 {
Errorf(nil, "too many sections") Errorf(nil, "too many sections")
errorexit() errorexit()
...@@ -387,7 +390,8 @@ func addpesection(ctxt *Link, name string, sectsize int, filesize int) *IMAGE_SE ...@@ -387,7 +390,8 @@ func addpesection(ctxt *Link, name string, sectsize int, filesize int) *IMAGE_SE
h := &sh[pensect] h := &sh[pensect]
pensect++ pensect++
copy(h.Name[:], name) copy(h.Name[:], shortname)
shNames = append(shNames, longname)
h.VirtualSize = uint32(sectsize) h.VirtualSize = uint32(sectsize)
h.VirtualAddress = uint32(nextsectoff) h.VirtualAddress = uint32(nextsectoff)
nextsectoff = int(Rnd(int64(nextsectoff)+int64(sectsize), PESECTALIGN)) nextsectoff = int(Rnd(int64(nextsectoff)+int64(sectsize), PESECTALIGN))
...@@ -400,6 +404,9 @@ func addpesection(ctxt *Link, name string, sectsize int, filesize int) *IMAGE_SE ...@@ -400,6 +404,9 @@ func addpesection(ctxt *Link, name string, sectsize int, filesize int) *IMAGE_SE
return h 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) { func chksectoff(ctxt *Link, h *IMAGE_SECTION_HEADER, off int64) {
if off != int64(h.PointerToRawData) { if off != int64(h.PointerToRawData) {
Errorf(nil, "%s.PointerToRawData = %#x, want %#x", cstring(h.Name[:]), uint64(int64(h.PointerToRawData)), uint64(off)) Errorf(nil, "%s.PointerToRawData = %#x, want %#x", cstring(h.Name[:]), uint64(int64(h.PointerToRawData)), uint64(off))
...@@ -946,7 +953,7 @@ func newPEDWARFSection(ctxt *Link, name string, size int64) *IMAGE_SECTION_HEADE ...@@ -946,7 +953,7 @@ func newPEDWARFSection(ctxt *Link, name string, size int64) *IMAGE_SECTION_HEADE
off := strtbladd(name) off := strtbladd(name)
s := fmt.Sprintf("/%d", off) 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 h.Characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_DISCARDABLE
return h return h
......
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