Add ENABLE_NO_HEAP to drop the unused reserved heap

This commit is contained in:
Armel FAUVEAU committed 2026-08-19 16:19:48 +02:00
1 parent 86e48f5f69
commit ec0d537b69
2 files changed
+11 -1

No files matched your search

+8
View File
@@ -110,6 +110,14 @@ set_target_properties(${EXE_NAME} PROPERTIES ADDITIONAL_CLEAN_FILES ${EXE_NAME}.
# Force linker to ignore RWX segment warning even if cache exists # Force linker to ignore RWX segment warning even if cache exists
target_link_options(${EXE_NAME} PRIVATE -Wl,--no-warn-rwx-segment) target_link_options(${EXE_NAME} PRIVATE -Wl,--no-warn-rwx-segment)
# ENABLE_NO_HEAP: no malloc/sbrk is linked (libc is discarded in py32f071xb.ld),
# so the reserved heap is dead weight. Zero it to reclaim ~512 B of RAM. This is
# a global toolchain optimization, independent of multiboot. The linker script
# reads __min_heap_size when defined, else keeps its 0x200 default.
if(ENABLE_NO_HEAP)
target_link_options(${EXE_NAME} PRIVATE "-Wl,--defsym=__min_heap_size=0")
endif()
# ----------------------------------- # -----------------------------------
# Post build processing # Post build processing
# #
+3 -1
View File
@@ -55,7 +55,9 @@ ENTRY(Reset_Handler)
/* Highest address of the user mode stack */ /* Highest address of the user mode stack */
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of RAM */ _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */ /* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x200; /* required amount of heap */ /* ENABLE_NO_HEAP passes --defsym=__min_heap_size=0 to drop the reserved heap
* (no malloc/sbrk is linked); default stays 0x200 otherwise. */
_Min_Heap_Size = DEFINED(__min_heap_size) ? __min_heap_size : 0x200; /* required amount of heap */
_Min_Stack_Size = 0x400; /* required amount of stack */ _Min_Stack_Size = 0x400; /* required amount of stack */
/* Specify the memory areas */ /* Specify the memory areas */