Closed mkettn closed 3 years ago
I've never looked at doing this myself (although I may need to in the future), but I suspect that the easiest way to do this is by allocating the memory yourself from the same pointer.
That is, instead of registering the memory with uc_mem_map twice, you register it with mem_map_ptr.
That is, instead of doing this:
uc_mem_map(uc, 0x0, ram_size, permissions);
uc_mem_map(uc, 0x08000000, ram_size, permissions);
Which would give you two distinct areas with different mappings, you instead do something like this:
void *ptr = malloc(ram_size);
uc_mem_map_ptr(uc, 0x0, ram_size, permissions, ptr);
uc_mem_map_ptr(uc, 0x08000000, ram_size, permissions, ptr);
Which will give you two regions which map to the same memory area. How this is dealt with through the cache is left as an exercise for the reader.
On some microcontrollers memory is aliased. e.g. for arm cortex m address 0x0 is an alias to 0x08000000. is this possible to do in unicorn? AFAIK Qemu can alias memory regions.