[PATCH] rebase: fix 32-bit rollover

Corinna Vinschen corinna-cygwin@cygwin.com
Tue Feb 11 10:22:00 GMT 2014


On Feb 10 15:07, Yaakov (Cygwin/X) wrote:
> When running rebase on multiple DLLs for x86, downwards rollover is
> now going back to the top of the 64-bit address space, which isn't
> right for x86 images.  This patch should restore the previous
> behaviour of rolling over (under?) to the top of the 32-bit space
> instead.  I didn't attempt to deal with upwards rollover due to the
> following comment.

Thanks for catching.  We should not rollover indiscriminately into the
upper two gigs either, though.  It won't work for real 32 bit systems,
only for WOW64 systems.

But given that rebase is running on a specific machine, we could take
the WOW64-iness into account.

Also, rebase should not start at the upper bound, because it will
collide with PEB, TEB and shared-user-data anyway, see the output of
/proc/$PID/maps.

AFAICS, we should start at either 0xfffe0000 (WOW64) or 0x7f60000
(real 32 bit).

Does that make sense?


Thanks,
Corinna



> Yaakov

> Index: rebase.c
> ===================================================================
> RCS file: /cvs/cygwin-apps/rebase/rebase.c,v
> retrieving revision 1.20
> diff -u -p -r1.20 rebase.c
> --- rebase.c	1 Dec 2013 12:19:07 -0000	1.20
> +++ rebase.c	10 Feb 2014 19:04:01 -0000
> @@ -1063,6 +1063,12 @@ retry:
>        return FALSE;
>      }
>  
> +  /* handle 32-bit rollover */
> +  if (down_flag
> +      && machine == IMAGE_FILE_MACHINE_I386
> +      && *new_image_base > 0xffffffff)
> +    *new_image_base = 0x100000000L - new_image_size;
> +
>  #if defined(__CYGWIN__) || defined(__MSYS__)
>    /* Avoid the case that a DLL is rebased into the address space taken
>       by the Cygwin DLL.  Only test in down_flag == TRUE case, otherwise


-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-apps/attachments/20140211/953e3f6c/attachment.sig>


More information about the Cygwin-apps mailing list