This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
RE: PATCH: PR gas/11974: windows x86_64 sign extension
- From: "Pierre Muller" <pierre dot muller at ics-cnrs dot unistra dot fr>
- To: "'H.J. Lu'" <hjl dot tools at gmail dot com>, <binutils at sourceware dot org>
- Date: Mon, 6 Sep 2010 16:27:55 +0200
- Subject: RE: PATCH: PR gas/11974: windows x86_64 sign extension
- References: <20100903174025.GA23835@intel.com>
Hi,
Thanks for reacting so fast on my bug report,
however I fear that this patch will generate
problems with people currently using GNU as for win64:
The push instruction for instance
allows to push a 8-byte qword value but only
as a 4-byte immediate value that is sign extended
to 8-bytes before being stored to the stack.
Before your patch:
pushq 0x80000001
was allowed on win64 and resulted in
having 0xffffffff80000001
at %esp address.
Now that code generates an error:
operand type mismatch for push.
I suspect that lots has to do with the
problem of 'long' type being a 4-byte integer on win64 systems :(
I was hoping that there would be some way to
to only do the sign extension from 32 to 64 bits
if no real 64-bit immediate constant is supported.
Pierre Muller
Pascal language support maintainer for GDB
> -----Message d'origine-----
> De?: binutils-owner@sourceware.org [mailto:binutils-
> owner@sourceware.org] De la part de H.J. Lu
> Envoyé?: Friday, September 03, 2010 7:40 PM
> À?: binutils@sourceware.org
> Objet?: PATCH: PR gas/11974: windows x86_64 sign extension
>
> Hi,
>
> I checked in this patch to fix 64bit immediate for 64bit Windows.
>
>
> H.J.
> ---
> Index: ChangeLog
> ===================================================================
> RCS file: /cvs/src/src/gas/ChangeLog,v
> retrieving revision 1.4240
> diff -u -p -r1.4240 ChangeLog
> --- ChangeLog 2 Sep 2010 22:43:44 -0000 1.4240
> +++ ChangeLog 3 Sep 2010 17:37:18 -0000
> @@ -1,3 +1,9 @@
> +2010-09-03 H.J. Lu <hongjiu.lu@intel.com>
> +
> + PR gas/11974
> + * config/tc-i386.c (i386_finalize_immediate): Check flag_code
> + instead of use_rela_relocations for 64bit.
> +
> 2010-09-02 Richard Henderson <rth@redhat.com>
>
> * dw2gencfi.c (TC_DWARF2_EMIT_OFFSET): Provide default.
> Index: config/tc-i386.c
> ===================================================================
> RCS file: /cvs/src/src/gas/config/tc-i386.c,v
> retrieving revision 1.447
> diff -u -p -r1.447 tc-i386.c
> --- config/tc-i386.c 19 Aug 2010 21:04:36 -0000 1.447
> +++ config/tc-i386.c 3 Sep 2010 17:37:19 -0000
> @@ -6626,8 +6626,8 @@ i386_finalize_immediate (segT exp_seg AT
> {
> /* Size it properly later. */
> i.types[this_operand].bitfield.imm64 = 1;
> - /* If BFD64, sign extend val. */
> - if (!use_rela_relocations
> + /* If not 64bit, sign extend val. */
> + if (flag_code != CODE_64BIT
> && (exp->X_add_number & ~(((addressT) 2 << 31) - 1)) == 0)
> exp->X_add_number
> = (exp->X_add_number ^ ((addressT) 1 << 31)) - ((addressT) 1 <<
> 31);
> Index: testsuite/ChangeLog
> ===================================================================
> RCS file: /cvs/src/src/gas/testsuite/ChangeLog,v
> retrieving revision 1.1728
> diff -u -p -r1.1728 ChangeLog
> --- testsuite/ChangeLog 3 Sep 2010 15:54:31 -0000 1.1728
> +++ testsuite/ChangeLog 3 Sep 2010 17:37:19 -0000
> @@ -1,3 +1,9 @@
> +2010-09-03 H.J. Lu <hongjiu.lu@intel.com>
> +
> + PR gas/11974
> + * gas/i386/immed64.s: Add more movabs tests.
> + * gas/i386/immed64.d: Updated.
> +
> 2010-09-03 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> * gas/elf/dwarf2-1.d: Update DW_OP_reg5 expected output.
> Index: testsuite/gas/i386/immed64.d
> ===================================================================
> RCS file: /cvs/src/src/gas/testsuite/gas/i386/immed64.d,v
> retrieving revision 1.3
> diff -u -p -r1.3 immed64.d
> --- testsuite/gas/i386/immed64.d 20 Oct 2009 22:18:18 -0000 1.3
> +++ testsuite/gas/i386/immed64.d 3 Sep 2010 17:37:20 -0000
> @@ -57,4 +57,6 @@ Disassembly of section \.text:
> [ ]*[0-9a-fA-F]+:[ ]+e5 04[ ]+inl? +\$0x4,%eax
> [ ]*[0-9a-fA-F]+:[ ]+e5 08[ ]+inl? +\$0x8,%eax
> [ ]*[0-9a-fA-F]+:[ ]+e5 00[ ]+inl? +\$0x0,%eax
> +[ ]*[a-f0-9]+: 48 b8 01 00 00 80 00 00 00 00 movabs
> \$0x80000001,%rax
> +[ ]*[a-f0-9]+: 48 b8 01 00 00 80 00 00 00 00 movabs
> \$0x80000001,%rax
> #pass
> Index: testsuite/gas/i386/immed64.s
> ===================================================================
> RCS file: /cvs/src/src/gas/testsuite/gas/i386/immed64.s,v
> retrieving revision 1.1
> diff -u -p -r1.1 immed64.s
> --- testsuite/gas/i386/immed64.s 26 Jul 2005 15:34:11 -0000 1.1
> +++ testsuite/gas/i386/immed64.s 3 Sep 2010 17:37:20 -0000
> @@ -54,3 +54,6 @@ _start:
> inl $xtrn, %eax
>
> .equiv late, 8
> +
> + movabs $0x80000001, %rax
> + movabsq $0x80000001, %rax