[K42-discussion] c++ -> c calling conventions and assembly

Donour Sizemore donour at cs.unm.edu
Wed Oct 4 09:40:04 EST 2006


I've run into a linking problem with gcc 4. GCC 4 doesn't emit .text 
segment symbols for extern "C" funtions. It only generates a data 
segement entry for an indirect call. You can see this clearly with a 
small example

extern "C" {
int printf(char *, ...);
void foobar(void);
}

extern "C" void foobar(void)
{
         printf("In foobar!\n");
}


with gcc3:

[donour at milhouse]$ /home/kitchawa/k42/bin/powerpc-linux-nm foo.o
00000000 T foobar
          U __gxx_personality_v0
          U printf


with gcc 4:

0000000000000000 V DW.ref.__gxx_personality_v0
0000000000000000 D foobar
                  U __gxx_personality_v0
                  U printf



As far as I can tell, this makes it impossible to call the function from 
assembly. The only solution I see is to create a c wrapper for each of 
these functions -- a real c wrapper -- but that seems like it would add 
an undesirable amount of complexity. Ideas?

donour



More information about the K42-discussion mailing list