mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link: do not export plugin C symbols
Explicitly filter any C-only cgo functions out of pclntable, which allows them to be duplicated with the host binary. Updates #18190. Change-Id: I50d8706777a6133b3e95f696bc0bc586b84faa9e Reviewed-on: https://go-review.googlesource.com/34199 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
901005e8fc
commit
96414ca39f
4 changed files with 77 additions and 5 deletions
|
|
@ -154,10 +154,26 @@ func renumberfiles(ctxt *Link, files []*Symbol, d *Pcdata) {
|
|||
*d = out
|
||||
}
|
||||
|
||||
// onlycsymbol reports whether this is a cgo symbol provided by the
|
||||
// runtime and only used from C code.
|
||||
func onlycsymbol(s *Symbol) bool {
|
||||
switch s.Name {
|
||||
case "_cgo_topofstack", "_cgo_panic", "crosscall2":
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func container(s *Symbol) int {
|
||||
if s == nil {
|
||||
return 0
|
||||
}
|
||||
if Buildmode == BuildmodePlugin && onlycsymbol(s) {
|
||||
return 1
|
||||
}
|
||||
// We want to generate func table entries only for the "lowest level" symbols,
|
||||
// not containers of subsymbols.
|
||||
if s != nil && s.Type&obj.SCONTAINER != 0 {
|
||||
if s.Type&obj.SCONTAINER != 0 {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue