aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorqmuntal <quimmuntal@gmail.com>2025-09-10 13:16:00 +0200
committerQuim Muntal <quimmuntal@gmail.com>2025-09-11 02:40:28 -0700
commit253dd08f5df3a45eafc97eec388636fcabfe0174 (patch)
tree350aeb85eab292997bf8953deade1ca5cab4e648 /src
parent2009e6c596551673ebb12050daa30171171cb432 (diff)
downloadgo-253dd08f5df3a45eafc97eec388636fcabfe0174.tar.xz
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 <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src')
-rw-r--r--src/debug/macho/file.go3
1 files changed, 2 insertions, 1 deletions
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)
}
}