This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Assembly symbol generation


Andrew Haley wrote:
Katana Steel writes:
> > I wonder why; when I compile a C++ file with a header which looks like this:
> #ifndef __headername_h
> #define __headername_h 1
> > #ifdef __cplusplus
> > extern "C" void function1(int,char*,int);
> extern "C" void function2(int,char*,int);
> > #endif
> > #endif
> > under x86 & x64 linux this creates the symbols (output from nm):
> U function1
> U function2
> and using cygwin & mingw (x86) it creates these symbols (output from nm):
> U _function1
> U _function2
> > is there a good reason for this?


The ABI says so.  The ABI allows programs generated by different tools
to be linked together: it doesn't really matter what the convention
is, as long as everyone on a particular platform agrees.

The "_" prefix is in fact an old UNIX convention that was IIRC dropped
by UNIX System V when it went over to ELF format binaries.

On most platforms there is also a -mno-underscores or -fno-leading-underscores or similar option available that can be used to suppress this anachronism.


Daniel




-- Dipl.-Inf. Daniel Lohmann (Wissenschaftlicher Mitarbeiter) Friedrich-Alexander-Universität Erlangen-Nürnberg Informatik 4 Martensstr. 1 91058 Erlangen Tel : +49-9131-8527904 Fax : +49-9131-8528732 WWW : www4.informatik.uni-erlangen.de/~lohmann eMail : lohmann@informatik.uni-erlangen.de


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