Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mhook module, apply malloc/free checks to list
- Loading branch information
Showing
7 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CFLAGS += | ||
LDFLAGS += -L "../mhook/$(BUILD_DIR)" |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
include ../rules.mk | ||
include ../module.mk | ||
|
||
clean: | ||
@ echo 'clean' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <stdio.h> | ||
#include "mhook.h" | ||
|
||
static uint64_t unfree = 0; | ||
|
||
uint64_t mhook_unfree() | ||
{ | ||
return unfree; | ||
} | ||
|
||
void mhook_print_unfree() | ||
{ | ||
printf("Unfree mallocs: %lu.\n", unfree); | ||
} | ||
|
||
void *__real_malloc(size_t); | ||
|
||
void *__wrap_malloc(size_t c) | ||
{ | ||
unfree++; | ||
return __real_malloc(c); | ||
} | ||
|
||
void *__real_free(size_t); | ||
|
||
void *__wrap_free(size_t c) | ||
{ | ||
unfree--; | ||
return __real_free(c); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
#include <stdint.h> | ||
#include <malloc.h> | ||
|
||
uint64_t mhook_unfree(); | ||
void mhook_print_unfree(); | ||
|
||
void *__wrap_malloc(size_t); | ||
void *__wrap_free(size_t); |
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