I have an asm program made with intel syntax. In this program, I am using this syntax jz $+1
from INTEL (+gcc), that means that I jump into the jz
instruction (which is 2 bytes). I jump 1 byte further the current instruction.
I am trying to find what is the correct syntax to do the same thing in GAS AT&T syntax, but I can't find the information.
Does anyone know that?
Add a comment
|
2 Answers
This is not really an RE question, but I think .
is used to refer to current location in many GAS architectures.
you can use intel syntax if you prefer in gas and use $+1 to jump into the middle of the instruction
$ cat foo.s
.intel_syntax noprefix
.global start
_start:
jz $+1
.byte 0x25,0x45,0x33,0x40,0x00
assemble
$ as -o foo.o foo.s
disassemble
$ objdump.exe -d foo.o
foo.o: file format pe-x86-64
Disassembly of section .text:
0000000000000000 <_start>:
0: 74 ff je 1 <_start+0x1>
2: 25 45 33 40 00 and $0x403345,%eax
7: 90 nop
8: 90 nop
link
$ ld -m i386pep -o foo foo.o
debug
$ gdb ./foo
GNU gdb (GDB) 8.2.1
(gdb) break _start
Breakpoint 1 at 0x100401000
(gdb) r
Starting program:
[New Thread 7876.0x2614]
Breakpoint 1, 0x0000000100401000 in __rt_psrelocs_start ()
(gdb) x/2i $rip
=> 0x100401000 <__rt_psrelocs_start>:
je 0x100401001 <__rt_psrelocs_start+1>
0x100401002 <__rt_psrelocs_start+2>: and $0x403345,%eax
(gdb) si
0x0000000100401001 in __rt_psrelocs_start ()
(gdb) x/2i $rip
=> 0x100401001 <__rt_psrelocs_start+1>:
jmpq *0x403345(%rip) # 0x10080434c
0x100401007 <__rt_psrelocs_start+7>: nop
(gdb)