Commit b5e964cc authored by Alex Brainman's avatar Alex Brainman

cmd/link: make sure that runtime.epclntab lives in .text section

Second attempt to fix #14710.

CL 35272 already tried to fix this issue. But CL 35272 assumed
that runtime.epclntab type is STEXT, while it is actually SRODATA.

This CL uses Symbol.Sect.Seg to determine if symbol is part
of Segtext or Segdata.

Fixes #14710

Change-Id: Ic6b6f657555c87a64d2bc36cc4c07ab0591d00c4
Reviewed-on: https://go-review.googlesource.com/42390
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent f700f89b
......@@ -1016,17 +1016,17 @@ func writePESymTableRecords(ctxt *Link) int {
typ := uint16(IMAGE_SYM_TYPE_NULL)
var sect int
var value int64
if s.Sect != nil && s.Sect.Seg == &Segdata {
// 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 != SDATA && Linkmode == LinkExternal {
value = int64(uint64(s.Value) - Segdata.Vaddr - Segdata.Filelen)
sect = bsssect
} else if uint64(s.Value) >= Segdata.Vaddr && s.Type != STEXT {
} else {
value = int64(uint64(s.Value) - Segdata.Vaddr)
sect = datasect
} else if uint64(s.Value) >= Segtext.Vaddr {
}
} else if s.Sect != nil && s.Sect.Seg == &Segtext {
value = int64(uint64(s.Value) - Segtext.Vaddr)
sect = textsect
} else if type_ == UndefinedSym {
......
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