Skip to content

Commit e9abf1a

Browse files
committed
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/36977 Reviewed-by: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent a7e2556 commit e9abf1a

File tree

1 file changed

+10
-3
lines changed
  • src/cmd/link/internal/ld

1 file changed

+10
-3
lines changed

src/cmd/link/internal/ld/pe.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,9 @@ var oh64 PE64_IMAGE_OPTIONAL_HEADER
356356

357357
var sh [16]IMAGE_SECTION_HEADER
358358

359+
// shNames stores full names of PE sections stored in sh.
360+
var shNames []string
361+
359362
var dd []IMAGE_DATA_DIRECTORY
360363

361364
type Imp struct {
@@ -379,15 +382,16 @@ var dexport [1024]*Symbol
379382

380383
var nexport int
381384

382-
func addpesection(ctxt *Link, name string, sectsize int, filesize int) *IMAGE_SECTION_HEADER {
385+
func addpesectionWithLongName(ctxt *Link, shortname, longname string, sectsize int, filesize int) *IMAGE_SECTION_HEADER {
383386
if pensect == 16 {
384387
Errorf(nil, "too many sections")
385388
errorexit()
386389
}
387390

388391
h := &sh[pensect]
389392
pensect++
390-
copy(h.Name[:], name)
393+
copy(h.Name[:], shortname)
394+
shNames = append(shNames, longname)
391395
h.VirtualSize = uint32(sectsize)
392396
h.VirtualAddress = uint32(nextsectoff)
393397
nextsectoff = int(Rnd(int64(nextsectoff)+int64(sectsize), PESECTALIGN))
@@ -400,6 +404,9 @@ func addpesection(ctxt *Link, name string, sectsize int, filesize int) *IMAGE_SE
400404
return h
401405
}
402406

407+
func addpesection(ctxt *Link, name string, sectsize int, filesize int) *IMAGE_SECTION_HEADER {
408+
return addpesectionWithLongName(ctxt, name, name, sectsize, filesize)
409+
}
403410
func chksectoff(ctxt *Link, h *IMAGE_SECTION_HEADER, off int64) {
404411
if off != int64(h.PointerToRawData) {
405412
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
946953

947954
off := strtbladd(name)
948955
s := fmt.Sprintf("/%d", off)
949-
h := addpesection(ctxt, s, int(size), int(size))
956+
h := addpesectionWithLongName(ctxt, s, name, int(size), int(size))
950957
h.Characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_DISCARDABLE
951958

952959
return h

0 commit comments

Comments
 (0)