This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Go patch committed: Improve name mangling for package paths


Hi Ian,

> This patch by Than McIntosh improves the mangling of package paths in
> the Go frontend.
>
> 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.
>
> This patch switches to a better mangling scheme to ensure 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).

it seems you missed a case here: both i386-pc-solaris2.* and
sparc-sun-solaris2.* bootstraps broke linking the gotools:

Undefined                       first referenced
 symbol                             in file
log..z2fsyslog.syslog_c             ../sparc-sun-solaris2.11/libgo/.libs/libgo.so
ld: fatal: symbol referencing errors
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:751: go] Error 1

The following patch fixes this allowing the links to succeed, though
I've not run the testsuite yet.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


diff --git a/libgo/go/log/syslog/syslog_c.c b/libgo/go/log/syslog/syslog_c.c
--- a/libgo/go/log/syslog/syslog_c.c
+++ b/libgo/go/log/syslog/syslog_c.c
@@ -12,7 +12,7 @@
    can't represent a C varargs function in Go.  */
 
 void syslog_c(intgo, const char*)
-  __asm__ (GOSYM_PREFIX "log_syslog.syslog_c");
+  __asm__ (GOSYM_PREFIX "log..z2fsyslog.syslog_c");
 
 void
 syslog_c (intgo priority, const char *msg)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]