Name mangling

Sune Foldager cryo@worldonline.dk
Thu Sep 20 07:36:00 GMT 2001


Greetings,

During my work on a kernel project for x86 based PC's, I have encountered
a problem with the way the gcc compiller mangles/formats names into symbols
for the linker. First time was when I switched from DOS djgpp, to Linux native
gcc (RedHat, later Mandrake). Second time was today when I tried to compile
my kernel under CygWin.

The problem is that I use a number of assembler files to facilitate things
like x86 instructions 'cli' and 'sti' and alot of other lowlevel stuff. Under
DOS using djgpp, whenever I made a prototype like:
void disable();
djgpp would produce a reference to the symbol '_disable', which I then also
named my label in the assembler file (assembled using NASM). However, when
I migrated to Linux, the same prototype produced and produces the symbol
'disable' without the underscore, requiering me to change all my assembler
files.

I have without success searched for options to change this behaviour of GCC.
The latest problem then is that under CygWin, the gcc compiller (which is
the same or close to the same version as the one in my Linux), again mangles
names like djgpp did, with the leading underscore.

My question then is this: Is there any way to control how the symbols are
generated, and is the behaviour even documented anywhere? I haven't been
able to find either.

Thanks alot in advance,
Sune Foldager.



More information about the Gcc-help mailing list