Updated elf_loader library to latest from GitHub (#234)

This commit is contained in:
Ken Van Hoeylandt
2025-02-22 23:57:45 +01:00
committed by GitHub
parent 6d1d08944b
commit bd2786b122
45 changed files with 641 additions and 483 deletions
+21 -9
View File
@@ -23,15 +23,28 @@
*
* @param n - Memory size in byte
* @param exec - True: memory can run executable code; False: memory can R/W data
*
*
* @return Memory pointer if success or NULL if failed.
*/
void *esp_elf_malloc(uint32_t n, bool exec)
{
uint32_t caps;
#if CONFIG_ELF_LOADER_BUS_ADDRESS_MIRROR
#ifdef CONFIG_ELF_LOADER_LOAD_PSRAM
uint32_t caps = MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT;
caps = MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT;
#else
uint32_t caps = exec ? MALLOC_CAP_EXEC : MALLOC_CAP_8BIT;
caps = exec ? MALLOC_CAP_EXEC : MALLOC_CAP_8BIT;
#endif
#else
#ifdef CONFIG_ELF_LOADER_LOAD_PSRAM
caps = MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT;
#else
caps = MALLOC_CAP_8BIT;
#endif
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
caps |= MALLOC_CAP_CACHE_ALIGNED;
#endif
#endif
return heap_caps_malloc(n, caps);
@@ -41,7 +54,7 @@ void *esp_elf_malloc(uint32_t n, bool exec)
* @brief Free block of memory.
*
* @param ptr - memory block pointer allocated by "esp_elf_malloc"
*
*
* @return None
*/
void esp_elf_free(void *ptr)
@@ -50,11 +63,11 @@ void esp_elf_free(void *ptr)
}
/**
* @brief Remap symbol from ".data" to ".text" section.
* @brief Remap symbol from ".data" to ".text" section.
*
* @param elf - ELF object pointer
* @param sym - ELF symbol table
*
*
* @return Remapped symbol value
*/
#ifdef CONFIG_ELF_LOADER_CACHE_OFFSET
@@ -64,7 +77,7 @@ uintptr_t elf_remap_text(esp_elf_t *elf, uintptr_t sym)
esp_elf_sec_t *sec = &elf->sec[ELF_SEC_TEXT];
if ((sym >= sec->addr) &&
(sym < (sec->addr + sec->size))) {
(sym < (sec->addr + sec->size))) {
#ifdef CONFIG_ELF_LOADER_SET_MMU
mapped_sym = sym + elf->text_off;
#else
@@ -82,7 +95,7 @@ uintptr_t elf_remap_text(esp_elf_t *elf, uintptr_t sym)
* @brief Flush data from cache to external RAM.
*
* @param None
*
*
* @return None
*/
#ifdef CONFIG_ELF_LOADER_LOAD_PSRAM
@@ -105,4 +118,3 @@ void IRAM_ATTR esp_elf_arch_flush(void)
spi_flash_enable_interrupts_caches_and_other_cpu();
}
#endif