name mangling vs name decorating...

Y

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 ?
 
V

Victor Bazarov

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?
 
M

Mogens Heller Jensen

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 :eek:)

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

Regards,
Mogens
 
P

Pete Becker

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.
 
E

E. Robert Tisdale

Something that calls itself (e-mail address removed) 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.
 
Y

yyy

E. Robert Tisdale napisal(a):
Something that calls itself (e-mail address removed) wrote:



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" ?
 
E

E. Robert Tisdale

Something said:
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++
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top