Created
February 11, 2019 20:07
-
-
Save b12mihai/d10f2a54ea29f73a8656669ab67f6a91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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