Go patch committed: Improve name mangling for package paths

Rainer Orth ro@CeBiTec.Uni-Bielefeld.DE
Fri Oct 26 12:56:00 GMT 2018


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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: libgo-syslog_c-mangling.patch
Type: text/x-patch
Size: 412 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20181026/938da717/attachment.bin>


More information about the Gcc-patches mailing list