🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Paul Vaughan Mon, 01 Apr 1991 20:07
name mangler
#521
Author: Paul Vaughan
Date: Mon, 01 Apr 1991 20:07
58 lines
2950 bytes
Several people including myself have asked for a name mangler. Michael
Tiemann has replied that such a thing exists in the g++ file
cplus-method.c, but I haven't figured out any way to use that just
yet.  I've been looking into the problem a bit and have come to a
sticky question: Exactly what input strings should a name mangler
accept?


Michael's mangling function is called as part of the process of
compiling code and is oriented very strongly for this purpose. It
appears to accept any legal function declaration (or a start of a
definition) of the current context in parse tree form.  Any types
mentioned must have been declared, default argument expressions are
admitted, explicit type declarations (i.e. void foo(struct Bar);) etc.
are allowed. This makes for a very complex grammar for function
declarations--for instance, it subsumes the expression grammar of C++.

I looked into the way that gdb handles name mangling. It avoids the
issue by only doing name demangling. That is, when you type in a C++
function name (not a complete declaration) like "foo" to set a
breakpoint, it looks through all symbols that start with foo,
demangles any matches and compares the demangled base name (the
demangler has an option to return only the base name, instead of a
full declaration with argument specs) against the given base name. (As
an aside, this code doesn't quite work for ordinary functions in gdb
3.6, and I don't understand how it is intended to work when a function
is overloaded).

The reason I wanted a name mangler was in connection with dynamic
linking. I'd like to be able to specify a full declaration (but not in
any context of typedefed names, and without the return type) and get
out the mangled symbol.  For instance,


"foo(Foo, Bar*, int, int)"

would give 

"_foo__FG3FooP3Barii"

for g++-1.39

I'm wondering, is this even feasible? Would it be necessary to have
built up the context of typedef'ed names? Suppose that certain
restrictions to the input format of unmangled names, such as
prohibiting

	foo(Foo, struct Bar*, int, int)

were in effect. Then would there a exist a 1:1 mapping between legal
mangled and unmangled names?

Does anyone have a specification for the mangler that is simpler than
ferreting it out of the demangler in cplus-dem.cc?

How many people would be interested in having a bison grammar based
mangler and demangler?
name mangler
#520
Author: Michael Tiemann
Date: Tue, 02 Apr 1991 04:04
18 lines
920 bytes
    Does anyone have a specification for the mangler that is simpler than
    ferreting it out of the demangler in cplus-dem.cc?

You need to do the whole job because of typedefs.  I.e.,

	typedef int foo;
	typedef int bar;

	foo f (bar);

mangles to the same thing that

	bar f (foo);

mangles to.

Michael
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads