This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: Properly sign extend offset
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sources dot redhat dot com
- Date: Tue, 15 Sep 2009 11:51:28 -0700
- Subject: Re: PATCH: Properly sign extend offset
- References: <20090915174652.GA6326@lucon.org>
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
On Tue, Sep 15, 2009 at 10:46:52AM -0700, H.J. Lu wrote:
> We need to sign extend offset only for 32bit address mode. We shouldn't
> check use_rela_relocations since w64 doesn't set it.
>
>
> H.J.
> ---
> 2009-09-15 H.J. Lu <hongjiu.lu@intel.com>
>
> * config/tc-i386.c (offset_in_range): Sign extend offset only
> for 32bit address mode.
> Index: config/tc-i386.c
> ===================================================================
> --- config/tc-i386.c (revision 6828)
> +++ config/tc-i386.c (working copy)
> @@ -1762,8 +1762,11 @@ offset_in_range (offsetT val, int size)
> default: abort ();
> }
>
> - /* If BFD64, sign extend val. */
> - if (!use_rela_relocations)
> +#ifdef BFD64
> + /* If BFD64, sign extend val for 32bit address mode. */
> + if (flag_code != CODE_64BIT
> + || i.prefix[ADDR_PREFIX])
> +#endif
> if ((val & ~(((addressT) 2 << 31) - 1)) == 0)
> val = (val ^ ((addressT) 1 << 31)) - ((addressT) 1 << 31);
>
There is no need to do sign extend if BFD64 isn't defined. I
am checking in this patch.
H.J.
---
Index: ChangeLog
===================================================================
--- ChangeLog (revision 6842)
+++ ChangeLog (working copy)
@@ -1,5 +1,10 @@
2009-09-15 H.J. Lu <hongjiu.lu@intel.com>
+ * config/tc-i386.c (offset_in_range): Sign extend offset only
+ if BFD64 is defined.
+
+2009-09-15 H.J. Lu <hongjiu.lu@intel.com>
+
* config/tc-i386-intel.c (i386_intel_operand): Initialize
intel_state.has_offset to 0.
Index: config/tc-i386.c
===================================================================
--- config/tc-i386.c (revision 6841)
+++ config/tc-i386.c (working copy)
@@ -1766,9 +1766,9 @@ offset_in_range (offsetT val, int size)
/* If BFD64, sign extend val for 32bit address mode. */
if (flag_code != CODE_64BIT
|| i.prefix[ADDR_PREFIX])
-#endif
if ((val & ~(((addressT) 2 << 31) - 1)) == 0)
val = (val ^ ((addressT) 1 << 31)) - ((addressT) 1 << 31);
+#endif
if ((val & ~mask) != 0 && (val & ~mask) != ~mask)
{