Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

x86 jump to an address

Tags:

x86

assembly

gdb

As an assignment for a security class, I am trying to use __asm__("jmp 0xbffff994"); in my code, but when I disassemble things in gdb, the instruction is changed to jmp 0xc8047e2a. Any idea why and how can I jump to a particular address?

like image 795
Martin Avatar asked Apr 21 '09 23:04

Martin


People also ask

What is a far jump in assembly?

A FAR jump specifies both a segment and offset, which are both absolute in the sense that they specify the required code segment and instruction pointer, rather than an offset relative to the current code segment / instruction pointer.

What does jmp instruction do?

Description. The jmp instruction transfers execution control to a different point in the instruction stream; records no return information. Jumps with destinations of disp[8|16|32] or r/m[16|32] are near jumps and do not require changes to the segment register value.

What is JA in x86?

JA is used for jumping if the last "flag changing" instruction was on unsigned numbers. but on the other hand, JG is used for jumping if the last "flag changing" instruction was on signed numbers.


1 Answers

Probably because it's a jumping to a relative address, and the linker or loader has moved your code. Try putting the address into a variable, and then do:

jmp dword [var]

or alternatively:

push 0xbffff994
ret
like image 144
Mark Avatar answered Oct 02 '22 16:10

Mark