[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: function name commingle

From: Bernd Strieder
Subject: Re: function name commingle
Date: Tue, 28 Mar 2006 17:31:16 +0200
User-agent: KNode/0.10.1


David Alasiga wrote:

> Does g++ have option to disable function name commingle.  When I
> compile like:
> g++ -S Test.cpp
> the file Test.s has function name commingled.  For example, function
> name
> foo becomes like __foo79emskd8.  Is there any options which output
> function
> name as original instead of commingled name?  Thanks in advance.

This is ususally called name mangling. You should find lots of
information on this in the net. Look also for linkage, extern "C" to
get the whole picture.

C++ allows overloading, i.e. functions with the same function name, but
different argument lists. The only way to map this onto the existing
linker structure (which comes from C, which does not allow overloading)
is coding the argument list and more into the actual name the function
is known to the linker. So overloaded functions have unique names
again. Since overloading could happen in different compilation units,
i.e. the compiler cannot decide whether mangling is unnecessary,
mangling is done by default, for all functions.

There is a small app called c++filt, which takes some text as input and
translates mangled names into readable names. Many applications like
objdump or nm dealing with object files and other binaries have the
ability to translate mangled names to readable output by some option.
See the manuals.


cat Test.s | c++filt | less

Bernd Strieder

reply via email to

[Prev in Thread] Current Thread [Next in Thread]