mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link: fix moduledata symbols for aix/ppc64 and external linking
Moduledata symbols like runtime.data or runtime.text must have the same position in the final executable (as some symbol accesses are made by offset from them). ld on AIX might move them randomly if there are nil size symbols. ld will also remove unreachable symbols like runtime.epclntab or runtime.rodata. In order to keep them, R_REF relocations are created between firstmoduledata and these symbols. This relocation tells ld to keep these symbols even if there aren't reachable. Change-Id: Ie5a28cf406977131cec6442f7f5b6fd89fb775a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/164004 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
80f10965ee
commit
f0749c74fd
6 changed files with 101 additions and 13 deletions
|
|
@ -2137,9 +2137,10 @@ func genasmsym(ctxt *Link, put func(*Link, *sym.Symbol, string, SymbolType, int6
|
|||
s := ctxt.Syms.Lookup("runtime.text", 0)
|
||||
if s.Type == sym.STEXT {
|
||||
// We've already included this symbol in ctxt.Textp
|
||||
// if ctxt.DynlinkingGo() && ctxt.HeadType == objabi.Hdarwin.
|
||||
// if ctxt.DynlinkingGo() && ctxt.HeadType == objabi.Hdarwin or
|
||||
// on AIX with external linker.
|
||||
// See data.go:/textaddress
|
||||
if !(ctxt.DynlinkingGo() && ctxt.HeadType == objabi.Hdarwin) {
|
||||
if !(ctxt.DynlinkingGo() && ctxt.HeadType == objabi.Hdarwin) && !(ctxt.HeadType == objabi.Haix && ctxt.LinkMode == LinkExternal) {
|
||||
put(ctxt, s, s.Name, TextSym, s.Value, nil)
|
||||
}
|
||||
}
|
||||
|
|
@ -2168,9 +2169,10 @@ func genasmsym(ctxt *Link, put func(*Link, *sym.Symbol, string, SymbolType, int6
|
|||
s = ctxt.Syms.Lookup("runtime.etext", 0)
|
||||
if s.Type == sym.STEXT {
|
||||
// We've already included this symbol in ctxt.Textp
|
||||
// if ctxt.DynlinkingGo() && ctxt.HeadType == objabi.Hdarwin.
|
||||
// if ctxt.DynlinkingGo() && ctxt.HeadType == objabi.Hdarwin or
|
||||
// on AIX with external linker.
|
||||
// See data.go:/textaddress
|
||||
if !(ctxt.DynlinkingGo() && ctxt.HeadType == objabi.Hdarwin) {
|
||||
if !(ctxt.DynlinkingGo() && ctxt.HeadType == objabi.Hdarwin) && !(ctxt.HeadType == objabi.Haix && ctxt.LinkMode == LinkExternal) {
|
||||
put(ctxt, s, s.Name, TextSym, s.Value, nil)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue