From: qmuntal Date: Wed, 10 Sep 2025 11:16:00 +0000 (+0200) Subject: debug/macho: filter non-external symbols when reading imported symbols without LC_DYS... X-Git-Tag: go1.26rc1~903 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=253dd08f5d;p=gostls13.git debug/macho: filter non-external symbols when reading imported symbols without LC_DYSYMTAB File.ImportedSymbols will return symbols with a type that has one of the N_STAB (0xe0) bits set and no section. That's not the expected behavior, as those symbols might not be external. We should expand the type check to also account for the N_EXT bit. The section check is not necessary, as N_EXT symbols never have it set. I have found this issue in the wild by running "go tool cgo -dynimport", but unfortuantely I couldn't get a minimal C code that generates N_STAB symbols without section, so this CL doesn't add any new test. Change-Id: Ib0093ff66b50c7cc2f39d83936314fc293236917 Reviewed-on: https://go-review.googlesource.com/c/go/+/702296 Reviewed-by: Cherry Mui Reviewed-by: David Chase LUCI-TryBot-Result: Go LUCI --- diff --git a/src/debug/macho/file.go b/src/debug/macho/file.go index 52ff81750c..8a40888284 100644 --- a/src/debug/macho/file.go +++ b/src/debug/macho/file.go @@ -735,9 +735,10 @@ func (f *File) ImportedSymbols() ([]string, error) { const ( N_TYPE = 0x0e N_UNDF = 0x0 + N_EXT = 0x01 ) for _, s := range st.Syms { - if s.Type&N_TYPE == N_UNDF && s.Sect == 0 { + if s.Type&N_TYPE == N_UNDF && s.Type&N_EXT != 0 { all = append(all, s.Name) } }