gerard4143 explained 6 years ago how to store binary code in memory and then execute it. See https://www.daniweb.com/programming/software-development/threads/353077/store-binary-code-in-memory-then-execute-it#post1500738.
In the example, we create an array of unsigned char containing these values:
This works fine when I use the binary code provided with the example.
How does one generate the binary code that can be used in this manner?
I'm trying to generalize this "Hello, World!" example. The goal is to load binary code for a set of functions into memory, as an array of arrays of unsigned char, for instance. Set page attributes to permit execution. And execute the functions by treating pointers to memory locations as function pointers.
It seems eminently doable, but I don't know how to generate binary code suitable for loading into memory and executing from that. I thought maybe generate object code files and ignore the ELF header? Working with Linux on x86_64 systems.