[fpc-devel] mangling of function names

Jonas Maebe jonas.maebe at elis.ugent.be
Mon Jun 24 15:25:21 CEST 2013

On 24 Jun 2013, at 15:07, 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.

> 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$...
> but I also saw
> 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).


More information about the fpc-devel mailing list