Commit 4a585ccb2f45446a127a9f7a5147b033ac02bd5f

Authored by bellard
1 parent aa0aa4fa

avoid unaligned file offset in anonymous mapping


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@215 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 7 additions and 2 deletions
linux-user/mmap.c
... ... @@ -188,7 +188,7 @@ long target_mmap(unsigned long start, unsigned long len, int prot,
188 188 host_start = start & host_page_mask;
189 189  
190 190 if (!(flags & MAP_FIXED)) {
191   -#ifdef __alpha__
  191 +#if defined(__alpha__) || defined(__sparc__)
192 192 /* tell the kenel to search at the same place as i386 */
193 193 if (host_start == 0)
194 194 host_start = 0x40000000;
... ... @@ -282,8 +282,13 @@ long target_mmap(unsigned long start, unsigned long len, int prot,
282 282  
283 283 /* map the middle (easier) */
284 284 if (host_start < host_end) {
  285 + unsigned long offset1;
  286 + if (flags & MAP_ANONYMOUS)
  287 + offset1 = 0;
  288 + else
  289 + offset1 = offset + host_start - start;
285 290 ret = (long)mmap((void *)host_start, host_end - host_start,
286   - prot, flags, fd, offset + host_start - start);
  291 + prot, flags, fd, offset1);
287 292 if (ret == -1)
288 293 return ret;
289 294 }
... ...