From 34489eb2af3bbb7be101bc838615cf4a4dc6828d Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 25 Oct 2018 22:18:08 +0000 Subject: compiler: improve name mangling for packpaths The current implementation of Gogo::pkgpath_for_symbol was written in a way that allowed two distinct package paths to map to the same symbol, which could cause collisions at link- time or compile-time. Switch to a better mangling scheme to insure that we get a unique packagepath symbol for each package. In the new scheme instead of having separate mangling schemes for identifiers and package paths, the main identifier mangler ("go_encode_id") now handles mangling of both packagepath characters and identifier characters. The new mangling scheme is more intrusive: "foo/bar.Baz" is mangled as "foo..z2fbar.Baz" instead of "foo_bar.Baz". To mitigate this, this patch also adds a demangling capability so that function names returned from runtime.CallersFrames are converted back to their original unmangled form. Changing the pkgpath_for_symbol scheme requires updating a number of //go:linkname directives and C "__asm__" directives to match the new scheme, as well as updating the 'gotest' driver (which makes assumptions about the correct mapping from pkgpath symbol to package name). Fixes golang/go#27534. Reviewed-on: https://go-review.googlesource.com/c/135455 From-SVN: r265510 --- libgo/go/runtime/sigqueue.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'libgo/go/runtime/sigqueue.go') diff --git a/libgo/go/runtime/sigqueue.go b/libgo/go/runtime/sigqueue.go index cf926a9..1a29b20 100644 --- a/libgo/go/runtime/sigqueue.go +++ b/libgo/go/runtime/sigqueue.go @@ -117,7 +117,7 @@ Send: // Called to receive the next queued signal. // Must only be called from a single goroutine at a time. -//go:linkname signal_recv os_signal.signal_recv +//go:linkname signal_recv os..z2fsignal.signal_recv func signal_recv() uint32 { for { // Serve any signals from local copy. @@ -161,7 +161,7 @@ func signal_recv() uint32 { // the signal(s) in question, and here we are just waiting to make sure // that all the signals have been delivered to the user channels // by the os/signal package. -//go:linkname signalWaitUntilIdle os_signal.signalWaitUntilIdle +//go:linkname signalWaitUntilIdle os..z2fsignal.signalWaitUntilIdle func signalWaitUntilIdle() { // Although the signals we care about have been removed from // sig.wanted, it is possible that another thread has received @@ -181,7 +181,7 @@ func signalWaitUntilIdle() { } // Must only be called from a single goroutine at a time. -//go:linkname signal_enable os_signal.signal_enable +//go:linkname signal_enable os..z2fsignal.signal_enable func signal_enable(s uint32) { if !sig.inuse { // The first call to signal_enable is for us @@ -208,7 +208,7 @@ func signal_enable(s uint32) { } // Must only be called from a single goroutine at a time. -//go:linkname signal_disable os_signal.signal_disable +//go:linkname signal_disable os..z2fsignal.signal_disable func signal_disable(s uint32) { if s >= uint32(len(sig.wanted)*32) { return @@ -221,7 +221,7 @@ func signal_disable(s uint32) { } // Must only be called from a single goroutine at a time. -//go:linkname signal_ignore os_signal.signal_ignore +//go:linkname signal_ignore os..z2fsignal.signal_ignore func signal_ignore(s uint32) { if s >= uint32(len(sig.wanted)*32) { return @@ -248,7 +248,7 @@ func sigInitIgnored(s uint32) { } // Checked by signal handlers. -//go:linkname signal_ignored os_signal.signal_ignored +//go:linkname signal_ignored os..z2fsignal.signal_ignored func signal_ignored(s uint32) bool { i := atomic.Load(&sig.ignored[s/32]) return i&(1<<(s&31)) != 0 -- cgit v1.1