Reputation: 13
Say, I have the following number of OpCode Bytes \x90\x90\x90\xb8\x05\x00\x00\x00
(Note the length of bytes could differ). I would like to execute these opcodes without having to store it into a buffer, and the reason I don't like it, is because a buffer is stored in data segment of the memory which then you have to provide execute permission to the buffer which may raise security concerns.
Since, we can use c's inline-assembly to execute assembly instruction, I was expecting that below may work:
__asm__("db 0x90");
but it throws Error: no such instruction: db 0x90
Can anyone tell me how do I execute opcodes without storing it into a buffer, I don't mind using either c
or python
as I am using cython.
Upvotes: 0
Views: 448
Reputation: 12600
The syntax for your assembler requires to use .byte
instead of db
.
GCC accepts two different dialects, "att" and "intel". The default is "att", but you can change it with the option -masm=...
.
The default assembler's documentation can be found with the keywords "gnu binutils", for example the current version knows these pseudo operations. It also lists the mnemonic .dc.b
for bytes.
Upvotes: 1