Skip to content

Instantly share code, notes, and snippets.

@mepcotterell
Created January 27, 2019 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mepcotterell/c597ff1526fed4e527efbecdd63ccb22 to your computer and use it in GitHub Desktop.
Save mepcotterell/c597ff1526fed4e527efbecdd63ccb22 to your computer and use it in GitHub Desktop.

pmem.c

#include <stdio.h>
#include <stdlib.h>
#include <signal.h>

int a = 4;
int b;

void foo(void) { }

int main(int argc, char * argv []) {
  int c = 2;
  void * p = malloc(1024);
  printf("[?????] argv = %p \n", (void *) argv);
  printf("[stack]   &c = %p \n", (void *) &c);
  printf("[heap ]    p = %p \n", (void *) p);
  printf("[.bss ]   &b = %p \n", (void *) &b);
  printf("[.data]   &a = %p \n", (void *) &a);
  printf("[.text] &foo = %p \n", (void *) (size_t) &foo);
  raise(SIGQUIT);
  free(p); // oof
  return 0;
} // main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment