From: Eugene Uriev Date: Sun, 31 Mar 2024 20:03:25 +0000 (+0300) Subject: mcheck: introduce mcheck_on_ramrelocation(.) X-Git-Url: http://git.dujemihanovic.xyz/html/static/%7B%7B%20.RelPermalink%20%7D%7D?a=commitdiff_plain;h=7bceb16106e5db971e3b9c457d6274f7dbd76f7d;p=u-boot.git mcheck: introduce mcheck_on_ramrelocation(.) The using of pre-reloc/malloc_simple heap is too hard to follow after the relocation. So lets drop it from the pedantic registry and switch to dlmalloc, when moved. The offset is ignored, but kept in the API for the probable case, when that early heap is relocated too. Signed-off-by: Eugene Uriev --- diff --git a/common/board_f.c b/common/board_f.c index 8bada6ff2e..039d6d712d 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -718,6 +718,7 @@ static int reloc_bloblist(void) return 0; } +void mcheck_on_ramrelocation(size_t offset); static int setup_reloc(void) { if (!(gd->flags & GD_FLG_SKIP_RELOC)) { @@ -743,6 +744,9 @@ static int setup_reloc(void) if (gd->flags & GD_FLG_SKIP_RELOC) { debug("Skipping relocation due to flag\n"); } else { +#ifdef MCHECK_HEAP_PROTECTION + mcheck_on_ramrelocation(gd->reloc_off); +#endif debug("Relocation Offset is: %08lx\n", gd->reloc_off); debug("Relocating to %08lx, new gd at %08lx, sp at %08lx\n", gd->relocaddr, (ulong)map_to_sysmem(gd->new_gd), diff --git a/common/mcheck_core.inc.h b/common/mcheck_core.inc.h index 85a34de295..bade03598f 100644 --- a/common/mcheck_core.inc.h +++ b/common/mcheck_core.inc.h @@ -273,5 +273,16 @@ static void mcheck_initialize(mcheck_abortfunc_t new_func, char pedantic_flag) mcheck_pedantic_flag = pedantic_flag; } +void mcheck_on_ramrelocation(size_t offset) +{ + char *p; + int i; + // Simple, but inaccurate strategy: drop the pre-reloc heap + for (i = 0; i < REGISTRY_SZ; ++i) + if ((p = mcheck_registry[i]) != NULL ) { + printf("mcheck, WRN: forgetting %p chunk\n", p); + mcheck_registry[i] = 0; + } +} #endif #endif