Name mangling under WASM
- From: Jentje Goslinga <spamtrap@xxxxxxxxxx>
- Date: Mon, 27 Mar 2006 02:05:44 GMT
Hi all,
I am having a problem with WASM, the Watcom Assembler.
I am using both the Visual C++ (VC) development and the
Watcom development environment for developing a C++
application with assembler (ASM) support.
I am using WASM to compile the (ASM) code; the version
number on my Watcom IDE is 11.0
WASM
As confirmed in the NG openwatcom.users.c_cpp there is no
documentation for WASM. All I have is a Windows help file
for the Watcom "Tools Set" which lists the operators and
directives for WASM.
I only recently found out that WASM is very much like
(shares a "common ancestry" with) MASM at some point of
its evolution and have found some good MASM docs which
seem applicable.
VIRTUAL FUNCTIONS AND NAME MANGLING
I am trying to build a numerical linear algebra project
written in C++ which contains virtual functions.
I would like to override some of the virtual functions
with faster and more accurate ones written in ASM.
Maybe this is not such a great idea but I would like to
make it work in any case, also for future reference.
The functions being class members are not amenable to the
extern "C" directive, which operates at file scope only,
not inside classes (am I correct?) so I am stuck with the
name mangling which does not overly concern me since ASM
is not portable anyway.
[I have heard the suggestion of using "friend functions"
but that does not apply to virtual functions.]
Naturally, I have to swap the mangled function names in the
ASM code when I switch from the VC development environment
to the Watcom one but that is acceptable and can probably be
achieved by passing enviroment variables to WASM (-d?).
I was able to figure out how to make VC call WASM to compile
my ASM code. The Watcom IDE knows very well how to deal with
ASM files and calls WASM.
So I am now able to link my C++ with ASM code under VC which
does not use offending characters in its name mangling scheme
[after subsituting the mangled names in my ASM code].
However, the Watcom mangled function names contain unacceptable
letters: colon and left and right parentheses; the colon is
particularly offensive since it defines a label in the syntax
of most assemblers.
[Agner Fog's extremely useful manual "Calling Conventions"
describes the name mangling algorithm for most development
environments (I really appreciate his work).]
THE PROBLEM
---------------------------------------------------------------
Of course, I use a "public" directive to specify the
external name:
public somefunc
...
somefunc:
<somefunc's body>
end
The mangled names are like:
Visual C/C++ mangled name:
?somefunc@SomeClass@@UAAXHPAN@Z
Watcom C/C++ mangled name:
W?somefunc$:SomeClass$n(ipnd)v
^ ^ ^ << problem characters
---------------------------------------------------------------
The Watcom Assembler has no problem with the mangled name as
produced by VC but does not like the one produced by its own
native compiler.
Not unexpectedly, setting a string variable to this name and
using it instead does not make difference.
I am sure somebody in this NG knows how to do what I want.
Maybe MASM or NASM can be made to accept this syntax?
Should I maybe migrate to a different assembler? I currently
use WASM to compile my ASM, not MASM or NASM but could change
that.
LINUX
One related question now that I am here: I am planning to port
this project to Linux at some time. Does anyone have some
suggestions as to which tools to use? I will likely be using
the GNU C++ compiler also because of its support for long
double.
I am wondering which Assembler offers the best portability.
I know this question comes up once in a while but would like
to see it answered again in my context.
Thanks in advance,
Jen
.
- Follow-Ups:
- Re: Name mangling under WASM
- From: Ole Nielsby
- Re: Name mangling under WASM
- Prev by Date: Re: pushb assembler command in gas
- Next by Date: Re: Error A2006
- Previous by thread: xchg & lock question
- Next by thread: Re: Name mangling under WASM
- Index(es):