Skip to content

Instantly share code, notes, and snippets.

@catphive
Created February 21, 2011 18:40
Show Gist options
  • Save catphive/837493 to your computer and use it in GitHub Desktop.
Save catphive/837493 to your computer and use it in GitHub Desktop.
example of a GNU C program that needs an executable stack
#include <stdlib.h>
#include <stdio.h>
int main() {
int count = 0;
int compar(const void *left_ptr, const void *right_ptr) {
int left = *(int*)left_ptr;
int right = *(int*)right_ptr;
++count;
return left - right;
}
int array[] = {8, 2, 4, 2, 7};
qsort(array, sizeof array / sizeof(int), sizeof(int), compar);
int ii;
for(ii = 0; ii < sizeof array / sizeof(int); ++ii) {
printf("%d ", array[ii]);
}
printf("\n");
printf("count: %d\n", count);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment