1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-22 11:17:19 +00:00

There are some Linux binaries that expect the system to obey the "addr"

parameter to mmap(2), even if MAP_FIXED is not explicitly specified.
Android ART is one example.  Implement bug compatibility for this case
in linuxulator.

Reviewed by:	dchagin@
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D9373
This commit is contained in:
Edward Tomasz Napierala 2017-02-19 17:17:06 +00:00
parent 6f03f3d85c
commit c6d57d3073
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=313947

View File

@ -203,8 +203,23 @@ linux_mmap_common(struct thread *td, uintptr_t addr, size_t len, int prot,
}
}
error = kern_mmap(td, addr, len, prot, bsd_flags, fd, pos);
/*
* FreeBSD is free to ignore the address hint if MAP_FIXED wasn't
* passed. However, some Linux applications, like the ART runtime,
* depend on the hint. If the MAP_FIXED wasn't passed, but the
* address is not zero, try with MAP_FIXED and MAP_EXCL first,
* and fall back to the normal behaviour if that fails.
*/
if (addr != 0 && (bsd_flags & MAP_FIXED) == 0 &&
(bsd_flags & MAP_EXCL) == 0) {
error = kern_mmap(td, addr, len, prot,
bsd_flags | MAP_FIXED | MAP_EXCL, fd, pos);
if (error == 0)
goto out;
}
error = kern_mmap(td, addr, len, prot, bsd_flags, fd, pos);
out:
LINUX_CTR2(mmap2, "return: %d (%p)", error, td->td_retval[0]);
return (error);