As pointed out in the comments, just using call 0xdeadbeef
should work. I have now verified this, and it works on my machine as well. So the answer below is not useful. I'll still leave it here so nobody later comes upon this question and disappointedly thinks there is no answer though.
I hope the code examples are still helpful to some other beginners.
Assuming ia-32 means GAS Syntax, it should be possible to use *
to designate it as an absolute address (and not a relative jump) and $
to designate it as a constant instead of having it load the value from this address.
It would thus make sense if it were
call *$0xdeadbeef
but this doesn't work. So here some suggestions that do seem to work.
For 32-bit (gcc -m32
), I know that the following works:
movl $0xdeadbeef, %edi
call *%edi
For 64-bit, you'd probably need to use %rdi
instead.
Another option, if you don't want to use a reg, would be to use a label:
.section .text
.globl main
main:
movl $0x3, %eax # some other instructions
call *(THE_ADDR) # call to your constant absolute address
ret # some other instructions
THE_ADDR:
.long 0x80483e6 # your constant absolute address
other_func: # here is 0x80483e6
movl $0x4, %eax # this code is executed
Again, this is 32-bit AT&T GAS Syntax assembly code, assembled with gcc -m32
.
For completeness' sake:
mov eax, 0x08048b98
call eax
This gives me a seg fault at the mov instruction.
This is because you're trying to move eax to the address, if you're using GAS Syntax. It would rather be mov $0x08048b98, %eax
.
This Q&A might help you as well.