[PATCH] Fix sign-extended immediates for SH on 64-bit host

Matt Fleming matt@console-pimps.org
Sat Aug 29 00:43:00 GMT 2009


Hi,

it appears that the SH backend for gas has a bug in it that is exposed
when using a cross-compiled toolchain that is built on a 64-bit host. As
an example, the assembler does not interpret the immediate constant
0xfffffff0 as a negative value when run on a 64-bit machine, rather it
is zero-extended. The constant is correctly recognised as a negative
integer on a 32-bit machine.

The attached patches introduce two new macros, SEXT and TRUNC to
sign-extend and truncate a long, respectively. Using these macros allows
us to obtain the same result from using sign-extended immediates on both
32-bit and 64-bit hosts.

Comments?

2009-08-29  Matt Fleming  <matt@console-pimps.org>

	* config/tc-sh.c (TRUNC): Define.
	(SEXT): Define.
	(md_apply_fix): Use new SEXT macro.

2009-08-29  Matt Fleming  <matt@console-pimps.org>

	* gas/sh/sign-extension.d: New file.
	* gas/sh/sign-extension.s: New file.
	* gas/sh/basic.exp: Run new test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 64-bit-host-bug.patch
Type: text/x-patch
Size: 1172 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20090829/0bd946d0/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sign-extend.patch
Type: text/x-patch
Size: 1001 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20090829/0bd946d0/attachment-0001.bin>


More information about the Binutils mailing list