Skip to content

make Android use mmap to make write+exec mappings#240

Closed
notaz wants to merge 2 commits intolibffi:masterfrom
notaz:android
Closed

make Android use mmap to make write+exec mappings#240
notaz wants to merge 2 commits intolibffi:masterfrom
notaz:android

Conversation

@notaz
Copy link
Copy Markdown

@notaz notaz commented Apr 8, 2016

This is already used by java-native-access/jna , for example

notaz added 2 commits April 8, 2016 19:34
Some Android versions use SELinux, but it doesn't seem to complain about
write+exec mappings.
Also the check depends on getline(), which older versions of NDK lack.
On Linux, by default libffi relies on malloc() memory to have
write+execute permissions, which is usually comes as a side effect of
making the stack executable (either by execstack linker option or
by compiling and linking some .S files; libffi linked programs get
linked to such objects).

On Android, at least on some versions of NDK for ARM, it is not enough
to just link some objects compiled from .S (or libffi) to enable
execstack and to get executable heap, so libffi just crashes in such
configuration. It can be argued it's not even desirable to make the
whole heap executable because of security implications, so enable
FFI_MMAP_EXEC_WRIT to make only needed memory executable instead.
alternative means])
;;
*-apple-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris*)
*-apple-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris* | *-linux-android*)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rebase this PR to master? Conflicts arise since commit 30b3440.

@notaz
Copy link
Copy Markdown
Author

notaz commented Jul 27, 2016

#265 created

@notaz notaz closed this Jul 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants