2021-10-25

示例程序

#include <stdio.h>
int main(int ac, char **av) {
        int localfn(int a) {
                return a+ac;
        }
        int (*fptr)(int) = localfn;

        printf("%d\n", fptr(-1));
        return 0;
}

编译 1

gcc trampoline.c -z execstack -o t
./t
0

编译2

gcc trampoline.c -z noexecstack -o t
./t
[1]    1499 segmentation fault  ./t

参考文献