The parser for windows x86_64 does sign extensions on values from 0x80000000 to 0xffffffff even for constant 64-bit values.
Even if 32-bit is the norm for constant expressions, at least MOVABS instruction is supposed to accept 64-bit immediate values, but the sign extension mechanism is still applied in that case. This happens in config/tc-i386.c in i386_finalize_immediate. Linux assembler is not affected as `use_rela_relocations' variable is set to 1 for 64 bit ELF target objects. This creates incompatible output from a single assembler source. >>>> Example <<<<<<< >>>> source file: test-sign.s <<<<<<< .data test: .quad 0 .text .global _settest1 _settest1: movq $0x80000001,%rax movq %rax,test retq .global _settest2 _settest2: movq $0x180000001,%rax movq %rax,test retq .global _gettest _gettest: movq test,%rax retq .global _test_push_imm _test_push_imm: pushq %rbp movq %rsp,%rbp pushq $0x80000001 movq -8(%rbp),%rax movq %rax,test leaveq retq .global _settestmovabs _settestmovabs: movabsq $0x80000001,%rax retq >>>> End of source <<<<<<< >>>> Source file test.c <<<<<<< #include <stdio.h> extern void settest1 (); extern void settest2 (); extern void settestmovabs (); extern long long int gettest (); int main () { long long int res; res = gettest (); if (res != 0) printf ("Error for value 0\n"); settest2 (); res = gettest (); if (res != (long long int) (0x180000001)) printf ("Error for value 0x180000001\n"); settest1 (); res = gettest (); if (res != (long long int) (0x80000001)) printf ("Error for value 0x80000001\n"); settestmovabs (); res = gettest (); if (res != (long long int) (0x80000001)) printf ("Error for value 0x80000001\n"); return 0; } >>>> End of source <<<<<<< Assemble sign-test.s using GNU as for x86_64 windows as -o test-sign.o test-sign.s Compile test.c: gcc -o test.exe test-sign.o test.c Run ./test.exe: $ ./test Error for value 0x80000001 with settest1 Error for value 0x80000001 with settestmovabs -- Summary: windows x86_64 sign extension Product: binutils Version: 2.21 (HEAD) Status: NEW Severity: normal Priority: P2 Component: gas AssignedTo: unassigned at sources dot redhat dot com ReportedBy: muller at ics dot u-strasbg dot fr CC: bug-binutils at gnu dot org GCC host triplet: x86_64-w64-mingw32 http://sourceware.org/bugzilla/show_bug.cgi?id=11974 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils