override memory allocation of global variables

Viewed 74

I need to assign a unique virtual page to each global object. For heap-allocated objects, I could override malloc/new calls and use mmap appropriately. But global objects like static struct {...} instance1; are allocated memory by the compiler itself in the data segment. How could I accomplish this?

1 Answers

Put them in specific sections and assign them virtual addresses in the linker script.

A more c++-ish way would be to use placement new to allocate them.

Related