Skip to content

Instantly share code, notes, and snippets.

@maxrp
Last active June 13, 2017 02:56
Show Gist options
  • Select an option

  • Save maxrp/b5f402a288b6fd37af984d9144ff1ea7 to your computer and use it in GitHub Desktop.

Select an option

Save maxrp/b5f402a288b6fd37af984d9144ff1ea7 to your computer and use it in GitHub Desktop.
aslr_test c vs. nim
#include <stdio.h>
#include <stdlib.h>
int main() {
int stack = 10;
int* heap = malloc(sizeof(int));
printf("stack = %p\nheap = %p\n\n", &stack, heap);
return 0;
}
proc main() =
var
robert_stack = 10
what_a_heap = alloc(sizeof(int))
stack_addr = addr(robert_stack)
heap_addr = addr(what_a_heap)
echo "stack = ",repr(stack_addr), "heap = ", repr(heap_addr)
main()
fn main() {
let stack = 10;
let heap = Box::new(std::mem::size_of::<i64>);
println!("stack = {:p}\nheap = {:p}", &stack, &heap);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment