GCC/GAS problem

William Roberts liam at cs.qmw.ac.uk
Fri Oct 5 06:54:57 AEST 1990


There is a nasty problem with gcc/gas as converted for A/UX to produce COFF
object files. There is an element of history involved so bear with me.

A/UX /bin/as uses the SGS mnemonics for 680x0 assembler, which allows
for an overspecified parser with special characters to donote labels and
register names, i.e. &fred is a label and %d0 is a register.

Other mnemonic systems don't have such special characters, so their languages
are actually ambiguous in that register names are effectively "reserved words"
or predefined names in the symbol table. This is true of the standard
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/UX /bin/ld doesn't need to do this because it goes with an assembler
that doesn't suffer the ambiguity problem in the first place.....
.... except, that is, until various good people managed to add COFF support
to gas and produce a matched pair of gcc and gas for A/UX. The gcc changes
included changing the assembler format into the normal gas syntax and removing
the extra "_" from the beginnings of labels, so that gas wouldn't emit
COFF files with symbols prefixed with "_" that the /bin/ld wouldn't resolve.

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

int a1, a2, a3, a4, a5, a6, a7;
int d0, d1, d2, d3, d4, d5, d6;
int cc;

main(argc,argv)
int argc;
char *argv[];
{
   a1=a2=a3=a4=a5=a6=a7=55;
   d0=d1=d2=d3=d4=d5=d6=57;
   cc =34;

   foo(&a1, &a2, &a3, &a4, &a5, &a6, &a7);
   foo(&d0, &d1, &d2, &d3, &d4, &d5, &d6);

   foo(&cc);
}

This produces error messages from gas such as

    "instruction/operands mismatch" -- Statement 'movel d1,cc' ignored
    "instruction/operands mismatch" -- Statement 'pea a7' ignored

and so on.

Question: Does the GNU version of ld handle COFF and do _foo=foo matching?

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

I don't have a gas manual or a spec for the standard Motorola syntax, so
I don't know what character would be a good choice. I'm prepared to do
the work (eventually) if necessary.

-- 

William Roberts                 ARPA: liam at cs.qmw.ac.uk
Queen Mary & Westfield College  UUCP: liam at qmw-cs.UUCP
Mile End Road                   AppleLink: UK0087
LONDON, E1 4NS, UK              Tel:  071-975 5250 (Fax: 081-980 6533)



More information about the Comp.unix.aux mailing list