Skip to content

Instantly share code, notes, and snippets.

@jldodds
Last active April 16, 2021 21:58
Show Gist options
  • Save jldodds/faef72d7f5978218c7f07053c185ef52 to your computer and use it in GitHub Desktop.
Save jldodds/faef72d7f5978218c7f07053c185ef52 to your computer and use it in GitHub Desktop.
SAW stack pointers
#include<stdio.h>
void incptr(int* n){
*n = *n+1;
}
int* return_out_of_scope(){
int n=0;
return &n;
}
int main(){
int* x = return_out_of_scope();
incptr(x);
printf("%d\n",*x);
return *x;
}
m <- llvm_load_module "ptr.bc";
let main_verify= do {
llvm_execute_func [];
llvm_return (llvm_term {{1 : [32]}});
};
llvm_verify m "main" [] false main_verify abc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment