This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Reserving the same virtual address space range in several programs


Hi,

I am trying to solve this problem: reserve the same
virtual memory address range in a given set of
programs so that no addresses falling within this
range will be used by the processes for any other
purpose. Later I'll map a shared memory region to this
address using mmap(.) or shmat(.).

My question is: is there a way I can use GCC to
achieve this VM address reservation? The programs are
fully in my control and are extremely specialized, so
I am at liberty to use techniques sane people would
balk at.

To give a clearer idea of what I'm getting at,
reserving 10 MB of memory space might be achieved
through something like:

char g_MemArray[ 10 * ( 1 << 20 ) ];

int
main()
{
    printf("Starts at %p\n", g_MemArray );
    return 0;
}

But of course, layout of global variables will vary
from program to program. I am trying to see if somehow
the layout can be specified so that VM addresses are
guaranteed to be the same.

TIA for the replies. I would also welcome any
solutions that do not involve gcc, though I realize
this would be off-topic (for which I apologize in
advance!). 

Regards,
Vishnu


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]