473,386 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

name mangling vs name decorating...

yyy
my question is rather theoretical than practical in the pure programming
aspect...

is "name mangling" the same as "name decorating" ?

browsing the web, you might find multiple people saying "yes", but i
vaguely remember having read that it's not exactly like that

one might say that "name mangling" is a part of c++ compiler specification
and is a naming scheme to support function overloading

"name decorating" on the other side, could be a part of a calling
convention naming scheme that supports symbol binding on the operating
system level

both affect the way given symbol is represented in the binary image, and
thus share a common field of operation, but still would denote a different
mechanism, at least considering its purpose...

are the terms perfectly equal ?
Sep 7 '05 #1
6 6494
yy*@yyy.yyy wrote:
my question is rather theoretical than practical in the pure
programming aspect...
If it's not C++-language specific, it doesn't belong here, then.
is "name mangling" the same as "name decorating" ?
AFAIK. The beauty is in the eye of the beholder. You decorate my
room and if I don't like it, I'll say that you've mangled it. :-)
browsing the web, you might find multiple people saying "yes", but i
vaguely remember having read that it's not exactly like that

one might say that "name mangling" is a part of c++ compiler
specification and is a naming scheme to support function overloading

"name decorating" on the other side, could be a part of a calling
convention naming scheme that supports symbol binding on the operating
system level
Yes, it could. How is it different?
both affect the way given symbol is represented in the binary image,
and thus share a common field of operation, but still would denote a
different mechanism, at least considering its purpose...

are the terms perfectly equal ?


Of course not. Names are changed differently depending on where the
change has meaning, right? Wait... If we're talking of the fact that the
original name is changed (supplied with additional information) to reflect
the use of the name, then there is no difference, the name _is_ changed,
regardless of why it was necessary, right?
Sep 7 '05 #2

<yy*@yyy.yyy> wrote in message news:opswqhav0riafrhz@q-0ipvqbesgeo8i...
my question is rather theoretical than practical in the pure programming
aspect...

is "name mangling" the same as "name decorating" ?

browsing the web, you might find multiple people saying "yes", but i
vaguely remember having read that it's not exactly like that

one might say that "name mangling" is a part of c++ compiler specification
and is a naming scheme to support function overloading

"name decorating" on the other side, could be a part of a calling
convention naming scheme that supports symbol binding on the operating
system level

both affect the way given symbol is represented in the binary image, and
thus share a common field of operation, but still would denote a different
mechanism, at least considering its purpose...

are the terms perfectly equal ?

I am not able to answer you question fully, but a guess would be that name
decoration is what happens when you compile your C program and every symbol
has an _ (underscore) prefixed because that is just the way C compilers
sometimes do (of course this is entirely up to the compiler).

Name mangling, at least to my knowledge, is what the C++ compiler does to
every function name because you may have multiple overloads and functions
whose names are the same inside different classes - this way the name
mangling of a symbol in some way reflects the types of arguments and the
class to which it belongs.

Still, I do not _know_ this, this is just what I imagine :o)

If someone actually knows this, please enlighten all of us...

Regards,
Mogens
Sep 7 '05 #3
yy*@yyy.yyy wrote:
my question is rather theoretical than practical in the pure
programming aspect...

is "name mangling" the same as "name decorating" ?


"Name mangling" is the term used in the C++ world from time immemorial
(i.e. since the creation of cfront). Microsoft, being Smarter Than
Everyone Else (tm), decided to use the term "name decorating." Unless
you, too, are Smarter Than Everyone Else (tm), you can use them
interchangeably.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Sep 7 '05 #4
Something that calls itself yy*@yyy.yyy wrote:

Is "name mangling" the same as "name decorating"?

Browsing the web, you might find multiple people saying "yes"
But I vaguely remember having read that it's not exactly like that.

One might say that "name mangling" is a part of C++ compiler specification
and is a naming scheme to support function overloading.

"name decorating", on the other side,
could be a part of a calling convention naming scheme
that supports symbol binding on the operating system level.

Both affect the way given symbol is represented in the binary image,
and, thus, share a common field of operation
but still would denote a different mechanism,
at least considering its purpose.

Are the terms perfectly equal?


A function name *may* be mangled by simply "decorating" it
with prefixes and/or suffixes to the generate symbols
that the compiler leaves behind for the link editor.
The so-called "UNIX convention" for Fortran prescribes:

1.) converting the function name to lower case and
2.) appending a single underscore to the function name.

Name mangling is necessary only to provide a unique symbol
for each function so that, for example, the link editor
can distinguish a Fortran subprogram from a C function
with the same name.
C++ function names are "mangled" (usually just decorated) because
the link editor accepts only a restricted set of identifiers as symbols.
There is no real reason why link editors couldn't be modified
to accept a function signature, for example:

strtok(char*, const char*)

as an entry in its symbol table.
Sep 7 '05 #5
yyy
E. Robert Tisdale napisal(a):
Something that calls itself yy*@yyy.yyy wrote:

Is "name mangling" the same as "name decorating"?

Browsing the web, you might find multiple people saying "yes"
But I vaguely remember having read that it's not exactly like that.

One might say that "name mangling" is a part of C++ compiler specification
and is a naming scheme to support function overloading.

"name decorating", on the other side,
could be a part of a calling convention naming scheme
that supports symbol binding on the operating system level.

Both affect the way given symbol is represented in the binary image,
and, thus, share a common field of operation
but still would denote a different mechanism,
at least considering its purpose.

Are the terms perfectly equal?


A function name *may* be mangled by simply "decorating" it
with prefixes and/or suffixes to the generate symbols
that the compiler leaves behind for the link editor.
The so-called "UNIX convention" for Fortran prescribes:

1.) converting the function name to lower case and
2.) appending a single underscore to the function name.

Name mangling is necessary only to provide a unique symbol
for each function so that, for example, the link editor
can distinguish a Fortran subprogram from a C function
with the same name.
C++ function names are "mangled" (usually just decorated) because
the link editor accepts only a restricted set of identifiers as symbols.
There is no real reason why link editors couldn't be modified
to accept a function signature, for example:

strtok(char*, const char*)

as an entry in its symbol table.

i've always considered "name mangling" a technical term, describing a
mechanism specific only to c++, and possibly other objective languages,
that tries to remedy the fact, that due to language specification
(overloading), an atom identifier at compiler level was not enough to
distinguish between procedures having same names but different set of
arguments. From your answer i get the impression that "decorating"
stands for some *practical* means of satisfying a *logical* concept of
"mangling".

the question was inspired in some degree, by microsoft's msdn entries,
as one of the previous posts hinted, where "name decorating" was used
in the context of calling conventions. at least in the ms compiler the
calling convention does affect the binary symbols generated when
compiled as standard c, or for c++ functions with the 'extern "C"'
directive.

cdecl: prepended with an underscore
stdcall: gets appended an "at sign" followed by the number of bytes
pushed on stack
fastcall: like stdcall, but gets an additional "at" at the beginning

so, would the names in this case be mangled, decorated, both, none or
"can't really say" ?

Sep 7 '05 #6
Something that calls itself yy*@yyy.yyy wrote:
I've always considered "name mangling" a technical term
describing a mechanism specific only to C++ and, possibly, other objective languages
that tries to remedy the fact that, due to language specification (overloading),
an atom identifier at compiler level was not enough
to distinguish between procedures
having same names but different set of arguments.
From your answer, I get the impression that
"decorating" stands for some *practical* means
of satisfying a *logical* concept of "mangling".

The question was inspired in some degree by microsoft's msdn entries
as one of the previous posts hinted
where "name decorating" was used in the context of calling conventions.
At least in the ms compiler,
the calling convention does affect the binary symbols generated
when compiled as standard C or for C++ functions with the 'extern "C"' directive.

cdecl: prepended with an underscore
stdcall: gets appended an "at sign"
followed by the number of bytes pushed on stack
fastcall: like stdcall, but gets an additional "at" at the beginning

So, would the names in this case be mangled, decorated, both, none or
"can't really say"?


I can't speak to any special meaning that Microsoft programmers
may have attached to the terms "mangle" or "decorate".
If you don't actually change the name
but simply prepend prefixes or append suffixes,
then you can say that the name is "decorated".
If you actually modify the name
(convert it to all lower case for example),
then you must say that the name has been mangled.
The C++ standards do *not* specify any particular name mangling rules.
Name mangling and the meaning of mangled names
is implementation dependent and off-topic in comp.lang.c++

Sep 8 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: sunny | last post by:
Hi, I was trying to call a function in an an asm file from a C file(driver). In c file the funcrtion is defined as: extern int foo(int,int); In the asm file the function is defined as _foo. ...
8
by: Bern | last post by:
hi all, what is the rule for decorating a symbol in c++?
1
by: Tim Slattery | last post by:
Does the C++ language standard mandate a particular name-mangling method? I'm trying to use the Entrust toolkit to create a C++ program that encrypts and decrypts files. Entrust supplies header...
20
by: Randy Yates | last post by:
Why is this necessary? The identifiers provide by the programmer are unique, and that is what is important - why map what the user has specified to something else? -- Randy Yates Sony Ericsson...
6
by: David Wade | last post by:
Folks, Does any one know of any "name mangling" software that allows standard C with long names to be linked? Any suggestions for a better place to look? I have tried putting various searchs...
5
by: Subhransu Sahoo | last post by:
Hi All, Does the C++ standard tell function overloading can't be done with the return types of two functions ? If so, is it true that the name mangling scheme does not take the return type into...
8
by: sam_cit | last post by:
Hi Everyone, I read somwhere that c++ compiler does name mangling of functions which is why c source code can't invoke functions from object files that were generated using c++ compiler. Can...
4
by: jason.cipriani | last post by:
Does anybody know if C++0x is going to change C++ name mangling at all? Such as, standardizing name mangling instead of leaving it up to the compiler? Jason
14
by: Megalo | last post by:
why not make "name mangling" of C++ standard so should be possible to call the classes and the functions of C++ from other C++ compiler thanks
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.