Skip to content

Instantly share code, notes, and snippets.

@b12mihai
Created February 11, 2019 20:07
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 b12mihai/d10f2a54ea29f73a8656669ab67f6a91 to your computer and use it in GitHub Desktop.
Save b12mihai/d10f2a54ea29f73a8656669ab67f6a91 to your computer and use it in GitHub Desktop.
mihai@ryzen:~/facultate/so/scratch$ cat some_random_malloc.c
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <stdint.h>int main()
{
uint8_t* addr;
addr = malloc(5);
/* if (addr == NULL) {
printf("malloc fails!!!!!\n");
return -ENOMEM;
} */
printf("malloc done, addr=%p\n", addr);
addr[1] = 210;
free(addr);
return 0;
}
mihai@ryzen:~/facultate/so/scratch$ cat wrapped_test.c
#include <stdio.h>
#include <stdlib.h>void* __wrap_malloc(size_t s)
{
printf("calling __wrap_malloc\n");
return NULL;
}
mihai@ryzen:~/facultate/so/scratch$ gcc some_random_malloc.c wrapped_test.c -Wl,--wrap=malloc`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment