This is the mail archive of the gas2@sourceware.cygnus.com mailing list for the gas2 project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
> gas out of binutils-2.9.1.0.23 (and older versions) has a severe bug
> for the SPARC platform (sparc-sun-solaris2.6), i.e. it generates
> wrong code for
>
> sethi 0x4000,%i0
>
> (and probably in all other cases where sethi is used without the
> %hi(...)-construct).
>
> The sethi instruction has following suggested assembly syntax
> (see SPARC Architecture Manual):
>
> sethi const22,reg
>
> const22 is a 22-bit constant that is placed by sethi in the most
> significant 22 bits of reg (while it zeroes the 10 least significant
> bits of reg). Therefore we would expect the value 0x100000 in %i0
> after the execution of ``sethi 16384''. Instead of this, gas
> modifies the given constant such that 0x4000 will be found in %i0
> afterwards. This would have been equivalent to
>
> sethi %hi(0x4000),%i0
>
Please try this patch. I know next to nothing about Sparc asm. Please
make sure this patch won't break anything on Sparc and let me know
the result. I hope someone will make a real fix for this bug.
Thanks.
H.J.
----
Fri Apr 2 11:44:49 1999 H.J. Lu (hjl@gnu.org)
* config/tc-sparc.c (sparc_ip): Fix "sethi const22,reg".
Index: tc-sparc.c
===================================================================
RCS file: /local/work/cvs/gnu/binutils/gas/config/tc-sparc.c,v
retrieving revision 1.10
diff -u -p -r1.10 tc-sparc.c
--- tc-sparc.c 1999/03/31 17:24:48 1.10
+++ tc-sparc.c 1999/04/02 19:45:21
@@ -1126,6 +1126,7 @@ sparc_ip (str, pinsn)
unsigned int mask = 0;
int match = 0;
int comma = 0;
+ int unary = 0;
int v9_arg_p;
for (s = str; islower ((unsigned char) *s) || (s > str && *s >= '0' && *s <= '8'); ++s)
@@ -1876,6 +1877,9 @@ sparc_ip (str, pinsn)
};
struct ops *o;
+ /* We have seen "%xx". */
+ unary = 1;
+
for (o = ops; o->name; o++)
if (strncmp (s + 1, o->name, o->len) == 0)
break;
@@ -1940,6 +1944,21 @@ sparc_ip (str, pinsn)
error_message = ": PC-relative operand can't be a constant";
goto error;
}
+ else if (strcmp (insn->name, "sethi") == 0
+ && unary == 0)
+ /* The sethi instruction has following suggested
+ assembly syntax (see SPARC Architecture Manual):
+
+ sethi const22,reg
+
+ const22 is a 22-bit constant that is placed by
+ sethi in the most significant 22 bits of reg
+ (while it zeroes the 10 least significant bits
+ of reg). It is different from
+
+ sethi %hi(value),reg
+ */
+ the_insn.reloc = BFD_RELOC_SPARC22;
/* Constants that won't fit are checked in md_apply_fix3
and bfd_install_relocation.