Mail Archives: cygwin/2003/07/03/16:53:51
On Thu, Jul 03, 2003 at 11:33:02AM -0700, Earl Chew wrote:
> Corinna Vinschen wrote:
> >On Thu, Jul 03, 2003 at 10:19:42AM -0400, Christopher Faylor wrote:
> >>On Thu, Jul 03, 2003 at 11:47:28AM +0200, Corinna Vinschen wrote:
> >>>Do you mean something like this:
> >>>
> >>> If addr is given, check if it's 64K aligned. If not, align and
> >>> raise the memory requirement accordingly. Call MapViewOfFileEx
> >>> with the aligned address. If it works, return the addr given as
> >>> parameter, otherwise return MapViewOfFileEx(NULL).
>
> Patching gcc to use MAP_FIXED is possible, but I'm not sure that
> it's really necessary, and there's another complication.
IMO it's not a question of necessity but of correctness.
> preferred_base = mmap (NULL, size,
> PROT_READ | PROT_WRITE, MAP_PRIVATE,
> f, offset);
>
> munmap(preferred_base, size);
>
> newbase = mmap (preferred_base, size,
> PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED,
> f, offset);
>
> There's a good chance that this fails because preferred_base
> is the fudged value from MapViewOfFileEx() and is no longer 64k
> aligned (only 4k aligned), and MAP_FIXED contains a check
> to ensure that the address is 64k aligned :-(
It depends on offset being 0 or not. Is gcc using offset !=0?
> So a patch to gcc to use MAP_FIXED would also require somehow
> making gcc aware of the 64k alignment.
No chance since it can't actually control the return value from mmap.
So I guess we should actually try it with your suggested approach.
> If addr is given, perform the 64k fixup. Essentially this means
> undoing the mmap64() fudge that might have been done previously:
>
> caddr_t ret = rec->get_address () + (off - gran_off);
>
> (Adjust the size appropriately too.)
Adjusting the size?!? We're just potentially moving the mapping addr,
this shouldn't have any influence to len resp. gran_len.
> In other words, addr -= (off - gran_off). This address should
> now be 64k aligned. Error if it isn't.
>
> Use this address when calling MapViewOfFileEx(). If the call fails
> and MAP_FIXED is not set, then try again with addr = 0.
Yes, that's what I mentioned in my first reply. I think it's worth
a try. I've checked in a patch. I've tested it and it looks pretty
good.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Developer mailto:cygwin AT cygwin DOT com
Red Hat, Inc.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -