Skip to content

Commit

Permalink
lmdk: Add support for dynamic memory allocation by a loadable modules
Browse files Browse the repository at this point in the history
This commit adds a necessary symbols in the linker script which allows use
a memory allocation functions from libc (malloc, calloc, etc.) in loadable
modules.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
  • Loading branch information
softwarecki authored and kv2019i committed Nov 9, 2023
1 parent 1b3403a commit ad2123d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lmdk/cmake/ldscripts/bss_linker_script.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,18 @@ SECTIONS {
_next_end = ABSOLUTE(.);
*(.bss)
*(.bss.*)

/* Heap memory */
. = ALIGN(4);
__stack = .;
_end = .;
KEEP(*(.heap_mem))

/* Use the unused rest of the memory page as a heap */
. = ALIGN(4096);

/* The sbrk function implementation by xtensa incorrectly checks whether the allocated
memory block fits in the heap, so we have to add 1 to the end of the heap marker. */
_heap_sentry = . + 1;
} >HPSRAM_seg : bss_phdr
}
1 change: 1 addition & 0 deletions lmdk/cmake/ldscripts/data_linker_script.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ SECTIONS {
_data_start = ABSOLUTE(.);
*(.data)
*(.data.*)
*(.*.data)
_data_end = ABSOLUTE(.);
} >HPSRAM_seg : data_phdr

Expand Down

0 comments on commit ad2123d

Please sign in to comment.