Issue
I'm tring to build a executable with android ndk to test shellcode. I set 'LOCAL_CFLAGS := -z execstack' to make the stack executable but it does not work. Doesn't android ndk support '-z execstack' option?
Here's the code:
18 include $(CLEAR_VARS)
19 LOCAL_MODULE := shellcode-test
20 LOCAL_SRC_FILES := src/shellcode-test.c
21 LOCAL_CFLAGS := -z execstack -Wl,--execstack
Check result: only 'RW', no 'E'
$ aarch64-linux-gnu-readelf -l shellcode-test ... GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 RW 0x10 ...
Solution
Resolved.
Android NDK forces noexecstack options when build executables or libraries. So '-z execstack' in my Android.mk is overridden by NDK's default option:
./build/core/build-binary.mk:LOCAL_CFLAGS += -Wa,--noexecstack
./build/core/build-binary.mk:LOCAL_LDFLAGS += -Wl,-z,noexecstack
Answered By - Juhu
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.