aboutsummaryrefslogtreecommitdiff
path: root/src/debug
diff options
context:
space:
mode:
authorJeremy Faller <jeremy@golang.org>2019-09-16 11:32:35 -0400
committerJeremy Faller <jeremy@golang.org>2019-09-17 19:29:43 +0000
commit06e5529eceae35bb26b51f2430c2c9425149ede2 (patch)
tree0d0a181dc0faf7cc32668f52c6d6832a55dcd212 /src/debug
parentdf855da653095e606fe69503b075e45d53d86ad7 (diff)
downloadgo-06e5529eceae35bb26b51f2430c2c9425149ede2.tar.xz
cmd/link: prefix syms with "_" on darwin links
RELNOTE=This change adds an underscore to all Go symbols in darwin, and the behavior might be confusing to users of tools like "nm", etc. Fixes #33808 Change-Id: I19ad626026ccae1e87b3bb97b6bb9fd55e95e121 Reviewed-on: https://go-review.googlesource.com/c/go/+/195619 Run-TryBot: Jeremy Faller <jeremy@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/debug')
-rw-r--r--src/debug/macho/file.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/debug/macho/file.go b/src/debug/macho/file.go
index 16708e5247..085b0c8219 100644
--- a/src/debug/macho/file.go
+++ b/src/debug/macho/file.go
@@ -473,7 +473,12 @@ func (f *File) parseSymtab(symdat, strtab, cmddat []byte, hdr *SymtabCmd, offset
if n.Name >= uint32(len(strtab)) {
return nil, &FormatError{offset, "invalid name in symbol table", n.Name}
}
- sym.Name = cstring(strtab[n.Name:])
+ // We add "_" to Go symbols. Strip it here. See issue 33808.
+ name := cstring(strtab[n.Name:])
+ if strings.Contains(name, ".") && name[0] == '_' {
+ name = name[1:]
+ }
+ sym.Name = name
sym.Type = n.Type
sym.Sect = n.Sect
sym.Desc = n.Desc