diff options
author | Jeremy Faller <jeremy@golang.org> | 2019-09-18 13:59:52 -0400 |
---|---|---|
committer | Jeremy Faller <jeremy@golang.org> | 2019-09-18 18:26:00 +0000 |
commit | 1aa64b55f1edc68b2e8f4b301e33f4a9588f7c1f (patch) | |
tree | a1dee7b3a0c04051777b74857ff9e485cbe18f63 /src/debug | |
parent | baf7d95350c9eab317efe769cf113b3611a6ccd0 (diff) | |
download | go-1aa64b55f1edc68b2e8f4b301e33f4a9588f7c1f.tar.gz go-1aa64b55f1edc68b2e8f4b301e33f4a9588f7c1f.zip |
cmd/link: prefix Go syms with _ on darwin
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: I1849e6618c81215cb9bfa62b678f6f389cd009d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/196217
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.go | 7 |
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 |