This is the mail archive of the libc-help@sourceware.org mailing list for the glibc 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]

Re: Creating aliases for memory ranges


On 26/01/13 03:18, Maxim Kuvyrkov wrote:
> On 23/01/2013, at 11:18 PM, Florian Weimer wrote:
>
>> This is probably more of a Linux question, but given that it's about user space and glibc hopefully has the necessary function declarations, I'm asking here.
>>
>> Is there a way to create pages which share the underlying content with other pages in the same process?  In essence, I want to character pointers p, q, such that p != q, and writing to *p changes the value of *q.  And in a next step, I'd like that the aliased page is read-only, while the original is not. 8-)
>>
>> I think this is easily to achieve if the original pages are mapped from a file on the file system, so the VM hardware has to support it.
> mmap (MAP_ANONYMOUS) ?
No, with MAP_ANONYMOUS he wouldn't be able to map it twice.
Florian, you need to open a temporary file and map it twice (once ro and
the other rw). You can then unlink the file after opening. You can't
duplicate a mapping with no associated file.

Regards




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