]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: assume that runtime.epclntab lives in .text section
authorAlex Brainman <alex.brainman@gmail.com>
Tue, 17 Jan 2017 04:06:12 +0000 (15:06 +1100)
committerAlex Brainman <alex.brainman@gmail.com>
Thu, 2 Feb 2017 04:05:11 +0000 (04:05 +0000)
Sometimes STEXT symbols point to the first byte of .data
section, instead of the end of .text section. But, while writing
pe symbol table, we should treat them as if they belong to the
.text section. Change pe symbol table records for these symbols.

Fixes #14710

Change-Id: I1356e61aa8fa37d590d7b1677b2bac214ad0ba4e
Reviewed-on: https://go-review.googlesource.com/35272
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
src/cmd/link/internal/ld/pe.go

index 517ed6cf2a768416ced3b64db2c7a865a5171e96..06fe49369f061956e5a919889a451a253edaa9cd 100644 (file)
@@ -955,10 +955,12 @@ func writePESymTableRecords(ctxt *Link) int {
                var value int64
                // Note: although address of runtime.edata (type SDATA) is at the start of .bss section
                // it still belongs to the .data section, not the .bss section.
+               // Same for runtime.epclntab (type STEXT), it belongs to .text
+               // section, not the .data section.
                if uint64(s.Value) >= Segdata.Vaddr+Segdata.Filelen && s.Type != obj.SDATA && Linkmode == LinkExternal {
                        value = int64(uint64(s.Value) - Segdata.Vaddr - Segdata.Filelen)
                        sect = bsssect
-               } else if uint64(s.Value) >= Segdata.Vaddr {
+               } else if uint64(s.Value) >= Segdata.Vaddr && s.Type != obj.STEXT {
                        value = int64(uint64(s.Value) - Segdata.Vaddr)
                        sect = datasect
                } else if uint64(s.Value) >= Segtext.Vaddr {