I have a file which content represents x64 machine code in hex.
48 c7 c0 7b 00 00 00 48 c7 c1 59 01 00 00 48 01 c8 c3
The example above can be disassembled to:
0: 48 c7 c0 7b 00 00 00 mov rax,0x7b
7: 48 c7 c1 59 01 00 00 mov rcx,0x159
e: 48 01 c8 add rax,rcx
11: c3 ret
This machine code is being generated directly, so the assembler shown above is for the sake of the example. I do not have access to it in general.
What I want to do is convert this hex file to and executable in the most direct way possible. I tried using xxd -r
, but this does not seem to create a well-formatted executable since I get a Exec format error
when trying to run it.
How should I generate an executable from the hex code under Linux?