GCC/GAS problem

Richard Michael Todd rmtodd at uokmax.ecn.uoknor.edu
Fri Oct 5 13:43:23 AEST 1990


liam at cs.qmw.ac.uk (William Roberts) writes:
>Motorola mnemonics and the variant which the m68k.c file in gas understands.
>Most other UNIX C compilers get round this by a convention which puts an
>underscore on the beginning of all C variable names and labels, so that the
>ambiguity is removed. This in turn leads to strange perversions in the
>linker which has to believe that "lable" matches "_lable".

[A good many non-Unix C compilers do this too, either putting a _ in front
of or at the end of symbols declared in C code.  I recall Aztec C doing
this on a PC, and I had to do something similar when I got Small-C running
on my Model I, when I noticed that declaring an "char *sp;" did interesting
things :-).  I suspect almost every C compiler that produces assembly code
does this.  Don't recall *ever* seeing a linker that mapped "_label" to
"label" or vice versa, though; most of the ones I've seen assumed that
anyone writing assembly routines to be called from C would know where this
C compiler put the "_" in label names.]

>Consider the following bit of code (you can guess what's coming...)

[code segment that uses lots of variables with the same name as registers
deleted]

>If it doesn't, then I think the following needs to be done:

>1) Modify gcc again so that there is a prefix character on labels
>2) Modify gas to use the prefix character to disambiguate labels/registers

John Coolidge has already done this, on the version of gcc/gas available for
ftp from wuarchive.wustl.edu.  (I believe the charhe's using on aregister names
is '%').  I guess this newest version hasn't made it across the Atlantic
yet.  Anyway, your program compiles with no problems on the current version 
(except that the linker objects that you never provided a function "foo" :-).

-- 
Richard Todd   rmtodd at chinet.chi.il.us  or  rmtodd at uokmax.ecn.uoknor.edu  



More information about the Comp.unix.aux mailing list