[patch] MIPS gas problems with gcc's explicit relocs
Richard Sandiford
rsandifo@redhat.com
Mon Jun 14 14:06:00 GMT 2004
Catching up after a week's holiday, so sorry if this is repeating
something that has already been said...
Thiemo Seufer <ica2_ts@csv.ica.uni-stuttgart.de> writes:
> asm("ld\t%0,%1(%2)" : "=r" (foo) : "m" (bar), "r" (baz));
As Paul says, this is definitely invalid. It might have happened to
give you the asm code you wanted, but that was just a fluke.
If you want "bar" to be a symbolic constant, you should use a constraint
for a symbolic constant. "s" is what you want for that. E.g.:
int foo ()
{
extern char bar[];
int tmp;
asm ("la %0,%1" : "=d" (tmp), "s" (bar));
return tmp;
}
gives:
#APP
la $2,bar
#NO_APP
"i", which someone suggested later, is more general than "s" and
gives the same thing (at least with gcc 3.4.0).
On the other hand, the above asm should just be written:
> asm("ld\t%0,%1" : "=r" (foo) : "m" (bar[baz]));
So far, folks have been using toy cut-down examples (usually the most
helpful thing to do, of course). But Thiemo's example was invalid, and
Maciej's was too if you believe the current gas behaviour to be correct.
And both of the asms could be done easily enough in C.
So I'm curious: what's the "real" asm that started off this whole thing?
Richard
More information about the Binutils
mailing list