Sunday, February 5, 2017

SIGSEGV second attempt

The previous SIGSEGV example didn't work on my Dragonboard when I compiled with:
gcc version 4.9.x 20150123 (prerelease) (GCC) 
Which is the gcc (with libs) that is included in the Android NDK R13b. The following was used for compiling:
aarch64-linux-android-gcc -Wall -g ${1}.c -o ${1}_arm64 -static
The problem is that siglongjmp() doesn't restore the sigprocmask. It's necessary to use "-static" for these binaries and the libc code in the NDK doesn't contain the call sigprocmask() which my Ubuntu libc does.


Thus the following is necessary to include:

static void sigsegvhandler(int sig, siginfo_t *siginfo, void *ptr) {
    sigset_t set;
    sigaddset(&set, SIGSEGV);
    sigprocmask(SIG_UNBLOCK, &set, NULL);
    siglongjmp(env, 1);

No comments:

Post a Comment