mirror of
https://github.com/golang/go
synced 2024-11-11 21:20:21 -07:00
cmd/link: never coalesce type descriptors when dynamically linking Go
Add a test by making misc/cgo/testshared/src/trivial.go marginally less trivial. Fixes #25970. Change-Id: I8815d0c56b8850fcdbf9b45f8406f37bd21b6865 Reviewed-on: https://go-review.googlesource.com/120235 Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
899e0e3525
commit
d6a27e8edc
@ -1,4 +1,9 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
// This is enough to make sure that the executable references
|
||||
// a type descriptor, which was the cause of
|
||||
// https://golang.org/issue/25970.
|
||||
c := make(chan int)
|
||||
_ = c
|
||||
}
|
||||
|
@ -368,28 +368,30 @@ func (ctxt *Link) symtab() {
|
||||
// pseudo-symbols to mark locations of type, string, and go string data.
|
||||
var symtype *sym.Symbol
|
||||
var symtyperel *sym.Symbol
|
||||
if ctxt.UseRelro() && (ctxt.BuildMode == BuildModeCArchive || ctxt.BuildMode == BuildModeCShared || ctxt.BuildMode == BuildModePIE) {
|
||||
s = ctxt.Syms.Lookup("type.*", 0)
|
||||
if !ctxt.DynlinkingGo() {
|
||||
if ctxt.UseRelro() && (ctxt.BuildMode == BuildModeCArchive || ctxt.BuildMode == BuildModeCShared || ctxt.BuildMode == BuildModePIE) {
|
||||
s = ctxt.Syms.Lookup("type.*", 0)
|
||||
|
||||
s.Type = sym.STYPE
|
||||
s.Size = 0
|
||||
s.Attr |= sym.AttrReachable
|
||||
symtype = s
|
||||
s.Type = sym.STYPE
|
||||
s.Size = 0
|
||||
s.Attr |= sym.AttrReachable
|
||||
symtype = s
|
||||
|
||||
s = ctxt.Syms.Lookup("typerel.*", 0)
|
||||
s = ctxt.Syms.Lookup("typerel.*", 0)
|
||||
|
||||
s.Type = sym.STYPERELRO
|
||||
s.Size = 0
|
||||
s.Attr |= sym.AttrReachable
|
||||
symtyperel = s
|
||||
} else if !ctxt.DynlinkingGo() {
|
||||
s = ctxt.Syms.Lookup("type.*", 0)
|
||||
s.Type = sym.STYPERELRO
|
||||
s.Size = 0
|
||||
s.Attr |= sym.AttrReachable
|
||||
symtyperel = s
|
||||
} else {
|
||||
s = ctxt.Syms.Lookup("type.*", 0)
|
||||
|
||||
s.Type = sym.STYPE
|
||||
s.Size = 0
|
||||
s.Attr |= sym.AttrReachable
|
||||
symtype = s
|
||||
symtyperel = s
|
||||
s.Type = sym.STYPE
|
||||
s.Size = 0
|
||||
s.Attr |= sym.AttrReachable
|
||||
symtype = s
|
||||
symtyperel = s
|
||||
}
|
||||
}
|
||||
|
||||
groupSym := func(name string, t sym.SymKind) *sym.Symbol {
|
||||
|
Loading…
Reference in New Issue
Block a user