This is the mail archive of the crossgcc@cygnus.com mailing list for the crossgcc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: gcc vs g++ and linking with as



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