Bug 10198 - GAS wrongly treats `$' as a symbol name
Summary: GAS wrongly treats `$' as a symbol name
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.19
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-26 06:28 UTC by Dmitry Gorbachev
Modified: 2009-06-01 16:32 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-mingw32
Build: i686-pc-linux-gnu
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Gorbachev 2009-05-26 06:28:11 UTC
GAS 2.19.51.20090519 incorrectly assembles

|.intel_syntax noprefix
|    jmp $+2
|    nop

as

|00000000 <.text>:
|   0:   e9 02 00 00 00          jmp    7 <.text+0x7>
|                        1: DISP32       $
|   5:   90                      nop
|   6:   90                      nop
|   7:   90                      nop

GAS 2.19.51.20090414 is correct:

|00000000 <.text>:
|   0:   eb 00                   jmp    2 <.text+0x2>
|   2:   90                      nop
|   3:   90                      nop
Comment 1 H.J. Lu 2009-05-29 05:22:33 UTC
What does "jmp $+2" mean? It seems invalid to me.
Comment 2 Dmitry Gorbachev 2009-05-29 23:06:20 UTC
"jmp $+2" jumps to the next instruction after itself (this form of "jmp" is 2
bytes long), i.e. essentially it is a no-op. It was often used in the past on
x86 to provide delays after I/O instructions. Now, these older programs cannot
be assembled with GAS. Notice that it is Intel syntax, it is valid.
Comment 3 H.J. Lu 2009-05-30 02:42:10 UTC
Is "jmp $+2" a documented syntax? The normal way is "jmp .+2".
Comment 4 Dmitry Gorbachev 2009-05-30 10:54:57 UTC
It's a usual syntax for x86 assemblers ( e.g. MASM
http://webster.cs.ucr.edu/Page_TechDocs/MASMDoc/ , NASM
http://www.nasm.us/doc/nasmdoc3.html#section-3.5 ). It seems it was not
documented in GAS, not for x86, at least.

The "jmp .+2" thing is AT&T syntax

|.att_syntax
|    jmp .+2
|    nop

This still works.
Comment 6 H.J. Lu 2009-06-01 16:32:16 UTC
Fixed.