This is the mail archive of the
c++-embedded@sourceware.cygnus.com
mailing list .
Re: gcc vs g++ and linking with as
- To: Chris Howard <choward at intellistor dot com>
- Subject: Re: gcc vs g++ and linking with as
- From: Stephen Williams <steve at icarus dot icarus dot com>
- Date: Thu, 25 Jun 1998 23:03:21 -0700
- Cc: c++-embedded at cygnus dot com, crossgcc at cygnus dot com
choward@intellistor.com said:
> Compiling with as,gcc and linking with ld works fine. Compiling with
> as,g++ and linking with ld does not work,
> undefined symbols for those things written in assembler.
Even in C you can have troubles. What I do is use the "asm" attribute
to declare external variables, i.e.:
extern unsigned char __index_space asm("__index_space__");
which causes __index_space__ to be the actual symbol name at link time.
A function would work like this:
int foo(int i) asm("test_symbol");
int foo(int i)
{
return i+1;
}
This works with (GNU) C and C++. It is a good thing to do even with C
because sometimes you get the leasing _, sometimes you don't. etc.
--
Steve Williams "The woods are lovely, dark and deep.
steve@icarus.com But I have promises to keep,
steve@picturel.com and lines to code before I sleep,
http://www.picturel.com And lines to code before I sleep."