public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc name mangling
@ 2003-10-20 21:29 y2bismil
  2003-10-21 12:06 ` Eljay Love-Jensen
  0 siblings, 1 reply; 4+ messages in thread
From: y2bismil @ 2003-10-20 21:29 UTC (permalink / raw)
  To: GCC- help

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gcc name mangling
  2003-10-20 21:29 gcc name mangling y2bismil
@ 2003-10-21 12:06 ` Eljay Love-Jensen
  2003-10-21 15:24   ` y2bismil
  2003-10-21 15:49   ` gcc name mangling - resolved y2bismil
  0 siblings, 2 replies; 4+ messages in thread
From: Eljay Love-Jensen @ 2003-10-21 12:06 UTC (permalink / raw)
  To: y2bismil, GCC- help

Hi Yamin,

Checkout the -fleading-underscore / -fno-leading-underscore flag.

Note:  this is a powerful flag, since it has sweeping effects.

HTH,
--Eljay


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gcc name mangling
  2003-10-21 12:06 ` Eljay Love-Jensen
@ 2003-10-21 15:24   ` y2bismil
  2003-10-21 15:49   ` gcc name mangling - resolved y2bismil
  1 sibling, 0 replies; 4+ messages in thread
From: y2bismil @ 2003-10-21 15:24 UTC (permalink / raw)
  To: GCC- help

Okay, 
reading the description, it seems to make a big deal of not being binary
compatible with code not compiled with this option.

Perhaps the best solution would be to simply prepend all assembler names with
underscores?

Anyone have any experience with using gAS and GCC together.  What is the common
practice?  I hope I'm not imagining, but I did some work using gcc and external
assembler (s files), using the m68k.  I don't recall name mangling being an issue.

Yamin

Quoting Eljay Love-Jensen <eljay@adobe.com>:

> Hi Yamin,
> 
> Checkout the -fleading-underscore / -fno-leading-underscore flag.
> 
> Note:  this is a powerful flag, since it has sweeping effects.
> 
> HTH,
> --Eljay
> 
> 




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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gcc name mangling - resolved
  2003-10-21 12:06 ` Eljay Love-Jensen
  2003-10-21 15:24   ` y2bismil
@ 2003-10-21 15:49   ` y2bismil
  1 sibling, 0 replies; 4+ messages in thread
From: y2bismil @ 2003-10-21 15:49 UTC (permalink / raw)
  To: GCC- help

Hi all,

I think I've found the most appropriate solution.  Define the functions within
an extern "C" and using the asm 'naming' system.  

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


And if I can remember my old work correctly.  They had something like that,
which is why name mangling was not an issue.

Yamin

Quoting Eljay Love-Jensen <eljay@adobe.com>:

> Hi Yamin,
> 
> Checkout the -fleading-underscore / -fno-leading-underscore flag.
> 
> Note:  this is a powerful flag, since it has sweeping effects.
> 
> HTH,
> --Eljay
> 
> 




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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-10-21 15:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-20 21:29 gcc name mangling y2bismil
2003-10-21 12:06 ` Eljay Love-Jensen
2003-10-21 15:24   ` y2bismil
2003-10-21 15:49   ` gcc name mangling - resolved y2bismil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).