bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug report


From: Sébastien Dusuel
Subject: Bug report
Date: Tue, 11 Apr 2017 10:48:06 +0200

Hello,

I seem to have found a bug in GNU as, when using the intel syntax on x86_64,
for some mov instructions, as explained below. I looked into the archive,
and could not find a mention of this bug. You'll find two source files
attached.

Best regards,
Sébastien Dusuel

-----------------------------------------------------------------------------

The att syntax has no problem:

# cat mov_att.s 
/* as -o mov_att.o mov_att.s && ld -o mov_att mov_att.o */
.global _start
_start:
mov %rax, 0x10(%rbp)
mov %ebx, 0x20(%rbx)
mov  %ax, 0x30(%rcx)
mov  %cl, 0x40(%rdx)

# as -o mov_att.o mov_att.s && ld -o mov_att mov_att.o

# gdb -q mov_att
Reading symbols from mov_att...(no debugging symbols found)...done.
(gdb) disassemble _start
Dump of assembler code for function _start:
   0x0000000000400078 <+0>: mov    %rax,0x10(%rbp)
   0x000000000040007c <+4>: mov    %ebx,0x20(%rbx)
   0x000000000040007f <+7>: mov    %ax,0x30(%rcx)
   0x0000000000400083 <+11>: mov    %cl,0x40(%rdx)
End of assembler dump.

-----------------------------------------------------------------------------

But the intel syntax has a problem:

# cat mov_intel.s 
/* as -o mov_intel.o mov_intel.s && ld -o mov_intel mov_intel.o */
.intel_syntax noprefix
.global _start
_start:
mov qword [rbp + 0x10], rax
mov dword [rbx + 0x20], ebx
mov word  [rcx + 0x30],  ax
mov byte  [rdx + 0x40],  cl

# as -o mov_intel.o mov_intel.s && ld -o mov_intel mov_intel.o

# gdb -q mov_intel
Reading symbols from mov_intel...(no debugging symbols found)...done.
(gdb) disassemble _start
Dump of assembler code for function _start:
   0x0000000000400078 <+0>: mov    %rax,0x18(%rbp)
   0x000000000040007c <+4>: mov    %ebx,0x24(%rbx)
   0x000000000040007f <+7>: mov    %ax,0x32(%rcx)
   0x0000000000400083 <+11>: mov    %cl,0x41(%rdx)
End of assembler dump.


As you can see, the numerical shifts are not properly treated when using the
intel syntax.

-----------------------------------------------------------------------------

The above has been tested on the three following setups:

#############################################################################
setup 1:

# uname -a
Linux kali 4.9.0-kali3-amd64 #1 SMP Debian 4.9.18-1kali1 (2017-04-04) x86_64
GNU/Linux

# as --version
GNU assembler (GNU Binutils for Debian) 2.28
Copyright (C) 2017 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `x86_64-linux-gnu'.


#############################################################################
setup 2:

$ uname -a
Linux *** 4.4.0-72-generic #93-Ubuntu SMP Fri Mar 31 14:07:41 UTC 2017
x86_64 x86_64 x86_64 GNU/Linux

$ as --version
GNU assembler (GNU Binutils for Ubuntu) 2.26.1
Copyright (C) 2015 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `x86_64-linux-gnu'.


#############################################################################
setup 3:

# uname -a
Linux *** 4.4.8-hardened-r1 #4 SMP Sat Oct 22 13:48:12 CEST 2016 x86_64
GNU/Linux

# as --version
GNU assembler (GNU Binutils for Debian) 2.25
Copyright (C) 2014 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `x86_64-linux-gnu'.

Attachment: mov_att.s
Description: Binary data

Attachment: mov_intel.s
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]