This is the mail archive of the crossgcc@cygnus.com mailing list for the crossgcc project.


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

Re: underscore - coff vs. aout




On Mon, 12 Jul 1999 Todd_Manchester@nmss.com wrote:

> I have a number of assembly files with symbols written with a underscore
> prepended so that they will link with .c files compiled for a.out format.
> I was thinking of changing to coff format, and I would like to know if
> there was a way to compile the .c files for coff so that they would still
> link correctly to the assembly files (that is, with prepended underscores).
> Changing every symbol would be a large undertaking, and I would like to
> avoid it if possible.
> Any suggestions?

Many of the gcc targets include enough information in the cpp predefines
to get this right with the help of a few macros.  This is a fragment from
newlib's m68k setjmp.S to show how:

* These are predefined by new versions of GNU cpp.  */

#ifndef __USER_LABEL_PREFIX__
#define __USER_LABEL_PREFIX__ _
#endif

#ifndef __REGISTER_PREFIX__
#define __REGISTER_PREFIX__
#endif

/* ANSI concatenation macros.  */

#define CONCAT1(a, b) CONCAT2(a, b)
#define CONCAT2(a, b) a ## b

/* Use the right prefix for global labels.  */

#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x)

.global SYM (setjmp)
.global SYM (longjmp)

SYM (setjmp):

Just be careful to use SYM everywhere.  There are also macros to hide the
differences in register naming (%reg vs. reg for example). RTEMS has an
asm.h file for each port which has these macros in it.

For RTEMS, this has worked well enough that we can compile easily for
a.out, coff, and elf.  I know the m68k has gone through all 3 formats.
Many of the other ports have been compiled with 2 of the 3. 

--joel
Joel Sherrill, Ph.D.             Director of Research & Development
joel@OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
   Support Available             (256) 722-9985


_______________________________________________
New CrossGCC FAQ: http://www.objsw.com/CrossGCC
_______________________________________________
To remove yourself from the crossgcc list, send
mail to crossgcc-request@cygnus.com with the
text 'unsubscribe' (without the quotes) in the
body of the message.

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