tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] RE :Re: Use an anonymous file to back mmap


From: Keren Tan
Subject: Re: [Tinycc-devel] RE :Re: Use an anonymous file to back mmap
Date: Fri, 10 Jan 2014 10:13:32 -0800

I did some search, and you are correct that different platforms may behave a bit different. Below are some info extracted from various platforms' mmap() man page:

Linux -- has both MAP_ANON and MAP_ANONYMOUS. The latter is preferred.
http://linux.die.net/man/2/mmap

FreeBSD -- has both MAP_ANON and MAP_ANONYMOUS. The latter is an alias of the former.
http://www.freebsd.org/cgi/man.cgi?query=mmap&sektion=2

OpenBSD -- only has MAP_ANON
http://www.openbsd.org/cgi-bin/man.cgi?query=mmap&apropos=0&sektion=0&manpath=OpenBSD+Current&arch=amd64&format=html

DragonFly -- only has MAP_ANON
http://leaf.dragonflybsd.org/cgi/web-man?command=mmap&section=2

Mac OS X -- only has MAP_ANON
https://developer.apple.com/library/ios/documentation/system/conceptual/manpages_iphoneos/man2/mmap.2.html

Mingw -- no support for mmap()
http://www.mingw.org/node/21

Based on the info collected above, it seems that mmap() with MAP_ANON has the widest support across various Linux and *BSD platforms. On another side, because using mmap() is under "--with-selinux" option, I am wondering if focusing on Linux platform solely is good enough for now?

Thanks,
Keren




On Fri, Jan 10, 2014 at 12:37 AM, Christian JULLIEN <address@hidden> wrote:
If I recall correctly, MAP_ANONYMOUS is not true POSIX but an extension most un*x system implement yet it is sometime call MAP_ANON.
To be portable, you must detect in ./configure if mmap supports either MAP_ANONYMOUS or MAP_ANON and fallback to /tmp/xxx if none is supported.

Christian


----- Message d'origine -----
De : "Thomas Preud'homme" <address@hidden>
Date ven. 10/01/2014 07:33 (GMT +01:00)
À : "address@hidden" <address@hidden>
Cc : "Keren Tan" <address@hidden>
Objet : Re: [Tinycc-devel] Use an anonymous file to back mmap


Le jeudi 9 janvier 2014, 14:21:59 Keren Tan a écrit :
> Hi All,
>
> I just submitted a tentative patch to the mob branch about mmap. When
> selinux is enabled, tccrun.c uses mmap to hold the dynamically generated
> code/data. It is backed by a randomly named file under /tmp directory. My
> patch is to use an anonymous file in mmap instead, so that the generated
> code/data only resides in memory, and tcc does not depend on a writable
> /tmp anymore.
>
> tcc is fantastic! I am new to this community. Your comments are very
> welcome!

Here is my comment: you removed the line s1->mem_size = ret; which is used to
unmap these memory regions in libtcc.c

>
> http://repo.or.cz/w/tinycc.git/commit/935d8169b8e3570f1a5e726c5295be2f460c15
> 40
>
> Best,
> Keren Tan

Thanks for your patch.

Best regards,

Thomas

_______________________________________________
Tinycc-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


reply via email to

[Prev in Thread] Current Thread [Next in Thread]