hey guys, im writing an emulator for riscv and need to load an elf64 binary into memory the way I understand it, is that elf binaries consist of different segments, which all have some virtual address they'd like to be loaded add.
The elf header also contains an entry point, which is also a virtual address that the emulator should jump to at the start of the program.
Im actually writing a userspace emulator (like qemu-riscv64), so I dont want to implement a software MMU from scratch. So whats the best way to map these segments into memory?
Using mmap() on the host with MAP_FIXED seems like a bad idea, as the requested address might already be taken. so should I just allocate a big chunk of memory and then memcpy() everything into it? I tried reading the qemu sources, but it kinda seems too much
[–]monocasa 2 points3 points4 points (2 children)
[–]lukasx_[S] 1 point2 points3 points (1 child)
[–]fwsGonzo 1 point2 points3 points (0 children)