This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Linkinging Assembler with C++
- To: yohankun at geocities dot com
- Subject: Re: Linkinging Assembler with C++
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Sat, 13 May 2000 16:27:40 +0200
- CC: gcc at gcc dot gnu dot org
- References: <391D4305.5BBB1352@mi.is>
> Can anyone tell me where I find documents on assembly linkage to C++
C++, as defined in the standard, does not support linking assembly
code. It would be an extension of the compiler (e.g. g++) to support
that. g++, in turn, does not *specifically* support linking assembly
code. Instead, it supports linking C code, and you have to arrange to
make your assembly functions appear like C functions to g++.
That is, you need to declare the functions as extern "C", and then
implement them in assembly.
> ...or more specificly: How are function calls handled in g++ and what
> kernel system calls are there.
g++, in general, follows the ABI (Application Binary Interface) of the
target operating system. g++ itself does not implement, nor use, any
kernel system calls.
> My system is GCC 2.95.2 on i686-pc-linux-gnu
You should have started with this information; the C calling
convention on this machine is totally different from, say,
rs6000-ibm-aix3.1.
Linux mostly follows the System V ABI for Intel ia32; you'll find the
ABI specification as part of the System V specification. I believe you
can currently obtain this specification from SCO. In short, parameters
are passed on the stack, and C function names appear in assembler code
as they appear in source code.
Linux uses a different system calling convention; see
/usr/include/asm/unistd.h.
In any case, this topic is better discussed on Linux newsgroups and
mailing lists; except for the extern "C" part, is has nothing to do
with g++.
Regards,
Martin