Skip to content

Commit 32f26b4

Browse files
committed
toolchain: linker: Temp workaround for missing heap size info
At the moment there is no way to specify defines that should be passed on to the linker when using the linker file generator. This is due to the fact that for GCC they use the same executable for both compiling and linking, and also that Zephyr uses a file to alloc the heap, but IAR uses the linker to reserve a memory block instead, which is why it requires the heap size info. The thing that's actually causing the problem is the fact that if the size of the heap is set to non-zero, there will be a heap variable of the set size, but if size is zero the heap should take up as much memory as it can. To support both solutions, IAR need the size info for the link phase, as that is where we can expand the heap to use the unallocated memory when size is zero, but use the heap variable when size is non-zero. My temporary solution is that when the heap size is not passed on the command line to the IAR linker, we set it to zero and thus use as much memory for the heap as possible. This solution should work for now. Signed-off-by: Lars-Ove Karlsson <lars-ove.karlsson@iar.com>
1 parent 369f15d commit 32f26b4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

cmake/linker/iar/config_file_script.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ function(system_to_string)
268268
endforeach()
269269

270270
if(IAR_LIBC)
271+
set(${STRING_STRING} "${${STRING_STRING}}if (!isdefinedsymbol(K_HEAP_MEM_POOL_SIZE))\n{\n")
272+
set(${STRING_STRING} "${${STRING_STRING}} define symbol K_HEAP_MEM_POOL_SIZE=0;\n")
273+
set(${STRING_STRING} "${${STRING_STRING}}}\n")
271274
set(${STRING_STRING} "${${STRING_STRING}}if (K_HEAP_MEM_POOL_SIZE>0)\n{\n")
272275
set(${STRING_STRING} "${${STRING_STRING}} define block HEAP with alignment=8 { symbol kheap__system_heap };\n")
273276
set(${STRING_STRING} "${${STRING_STRING}}}\nelse\n{\n")

0 commit comments

Comments
 (0)