Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2013-06

mangling of function names

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

martin

anyone knows *all* the different ways that function names may be mangled (for the linker)?

I asked because this is sometime the only info returned by gdb (if there is no debug info). And it could be useful to parse it.

It used to be Unit_class_$__function$...
SYSTEM_TOBJECT_$__DISPATCH$formal

but I also saw
CLASSES$_$TREADER_$__$$_READINTEGER$$LONGINT

makes me wonder if in some cases there may be more info between all the $$ ?

And also will need the format for plain functions (not methods)

Thanks

Reply by email

Jonas Maebe
to martin
martin wrote
anyone knows *all* the different ways that function names may be mangled (for the linker)?

Probably only "svn blame/praise" combined with checking out old versions of compiler/symdef.pas does.

Show quoted text 11 lines
I asked because this is sometime the only info returned by gdb (if there is no debug info). And it could be useful to parse it. It used to be Unit_class_$__function$... SYSTEM_TOBJECT_$__DISPATCH$formal but I also saw CLASSES$_$TREADER_$__$$_READINTEGER$$LONGINT makes me wonder if in some cases there may be more info between all the $$ ?

No. That's a change that was made because e.g. unit1._class1 and unit1_.class1 resulted in the same mangled name. "$" is not a valid character in Pascal identifiers and hence was added as a separator in the mangled name.

And also will need the format for plain functions (not methods)

You should not try to parse the mangled name, because FPC's name mangling is a one-way process at this time (and always has been until now). If the mangled name's length gets close to 250 characters, the end will be replaced by a CRC of the name (possibly multiple times).

Jonas

Reply by email

martin
to Jonas Maebe
Jonas Maebe wrote 7 lines
You should not try to parse the mangled name, because FPC's name mangling is a one-way process at this time (and always has been until now). If the mangled name's length gets close to 250 characters, the end will be replaced by a CRC of the name (possibly multiple times).

I know it can break and all

but that is no problem.
currently there is no other data in those cases, so the debugger can not to anything, not even open the unit.

if parsing fails (including codetool verifies if the result makes any sense at all), then still nothing happens. same as before.

if in some cases it works, then that is an improvement.

Reply by email

Sven Barth
to martin
martin wrote 18 lines
On 24/06/13 14:25, Jonas Maebe wrote: > > > You should not try to parse the mangled name, because FPC's name > mangling is a one-way process at this time (and always has been until > now). If the mangled name's length gets close to 250 characters, the > end will be replaced by a CRC of the name (possibly multiple times). > I know it can break and all but that is no problem. currently there is no other data in those cases, so the debugger can not to anything, not even open the unit. if parsing fails (including codetool verifies if the result makes any sense at all), then still nothing happens. same as before. if in some cases it works, then that is an improvement.

The most important part is "make_mangledname" in "symdef.pas" and should at least give you a hint how the mangled name is constructed. But as Jonas said, this can break at any time.

Regards,
Sven

Reply by email