gcc name mangling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I'm experimenting a bit trying to do some basic mixing between gcc and assembler.
Maybe this should all be manual work, but I'm inclined to think GCC its my setup
that's a problem.

Basically, to start, I want to call an assembler function from GCC.  

i'm just getting link errors.  the linker claims it cannot find _writechar in
main.o.  Now, its pretty easy to fix it...I need to use "_writechar" in my asm
file instead of writechar.  But, is there another way to use the name variable
name without the underscore?  Something so GCC won't mangle the name at all?  Or
something to add the the assembler file to 'export function' names differently.

Thanks for any advice.

Yamin

************************************
ASM FILE

.globl write_char


.data 
 message:
         .string "Hello, world\n" 
 .text 
 .global write_char
 write_char:
         ...some code that's incomplete
         ret 
**************************************
main.cpp

#include <iostream>

void testfunc();
extern "C"
{
   extern void write_char(char);
}

int main()
{
    std::printf("i am running now\n");
    write_char('B');
    std::printf("i did run\n");
    return 0;
}

*****************************************



----------------------------------------
This mail sent through www.mywaterloo.ca


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux