
4 May
2021
4 May
'21
5:26 p.m.
On Sun, 2 May 2021 at 20:55, Sean Anderson seanga2@gmail.com wrote:
This annotates malloc and friends so that valgrind can track the heap. To do this, we need to follow a few rules:
- Call VALGRIND_MALLOCLIKE_BLOCK whenever we malloc something
- Call VALGRIND_FREELIKE_BLOCK whenever we free something (generally after we have done our bookkeeping)
- Call VALGRIND_RESIZEINPLACE_BLOCK whenever we change the size of an allocation. Generally this just needs to happen in realloc, but only if the address stays the same.
In addition to the above, dlmalloc itself tends to make a lot of accesses which we know are safe, but which would be unsafe outside of dlmalloc. For this reason, we provide a suppression file which ignores errors ocurring in dlmalloc.c
Signed-off-by: Sean Anderson seanga2@gmail.com
common/dlmalloc.c | 29 ++++++++++++++++++++++++++++- common/malloc_simple.c | 10 ++++++++++ include/malloc.h | 4 ++++ scripts/u-boot.supp | 30 ++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 scripts/u-boot.supp
Reviewed-by: Simon Glass sjg@chromium.org