'GCC assembly and unsupported instruction `mov'
I'm trying to compile the following assembly code in level2.s
movl $0x0000000054756825, %rdi
movl $0x000000000040198c, $(0x0000000055685ff8) ; do I need $ for a memory address?
movl $0x0000000055685ff8, %rbp
retq
I'm compiling on a 64-bit machine, and it must be compiled with 64-bits. I have found various solutions where using the -m32
flag resolves the issue, but again I need the compilation to be in 64-bits
I'm getting the following error messages:
level2.s: Assembler messages:
level2.s:1: Error: incorrect register `%rdi' used with `l' suffix
level2.s:2: Error: unsupported instruction `mov'
level2.s:3: Error: incorrect register `%rbp' used with `l' suffix
Errors on lines 1&3 make no sense to me because the r
registers are 64-bits. The error on line 2 makes no sense at all to me.
For reference, this is part of a buffer overflow attack. I am placing these instructions on the stack where they are executed after an overflow return address space.
So the pseudocode is:
- place value in
rdi
register as a parameter - move a new return address (pointing to the
text/code
region) into a place on the stack - move the value of the address above ^^ (the
stack
address, not thetext/code
address) into therbp
register - return
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|