fix(linker): fixed extern linker symbol type from int to char

This commit is contained in:
Armando 2024-09-12 09:52:52 +08:00
parent c7415fc78d
commit 256ef127dd
4 changed files with 41 additions and 16 deletions

View File

@ -136,10 +136,18 @@ esp_err_t mmu_config_psram_rodata_segment(uint32_t start_page, uint32_t psram_si
/*---------------------------------------------------------------------------- /*----------------------------------------------------------------------------
Part 2 APIs (See @Backgrounds on top of this file) Part 2 APIs (See @Backgrounds on top of this file)
-------------------------------------------------------------------------------*/ -------------------------------------------------------------------------------*/
extern int _instruction_reserved_start; /**
extern int _instruction_reserved_end; * If using `int`, then for CLANG, with enabled optimization when inlined function is provided with the address of external symbol, the two least bits of the constant used inside that function get cleared.
extern int _rodata_reserved_start; * Optimizer assumes that address of external symbol should be aligned to 4-bytes and therefore aligns constant value used for bitwise AND operation with that address.
extern int _rodata_reserved_end; *
* This means `extern int _instruction_reserved_start;` can be unaligned to 4 bytes, whereas using `char` can solve this issue.
*
* As we only use these symbol address, we declare them as `char` here
*/
extern char _instruction_reserved_start;
extern char _instruction_reserved_end;
extern char _rodata_reserved_start;
extern char _rodata_reserved_end;
//------------------------------------Copy Flash .text to PSRAM-------------------------------------// //------------------------------------Copy Flash .text to PSRAM-------------------------------------//
#if CONFIG_SPIRAM_FETCH_INSTRUCTIONS #if CONFIG_SPIRAM_FETCH_INSTRUCTIONS

View File

@ -28,10 +28,18 @@
#define ALIGN_UP_BY(num, align) (((num) + ((align) - 1)) & ~((align) - 1)) #define ALIGN_UP_BY(num, align) (((num) + ((align) - 1)) & ~((align) - 1))
#define ALIGN_DOWN_BY(num, align) ((num) & (~((align) - 1))) #define ALIGN_DOWN_BY(num, align) ((num) & (~((align) - 1)))
extern int _instruction_reserved_start; /**
extern int _instruction_reserved_end; * If using `int`, then for CLANG, with enabled optimization when inlined function is provided with the address of external symbol, the two least bits of the constant used inside that function get cleared.
extern int _rodata_reserved_start; * Optimizer assumes that address of external symbol should be aligned to 4-bytes and therefore aligns constant value used for bitwise AND operation with that address.
extern int _rodata_reserved_end; *
* This means `extern int _instruction_reserved_start;` can be unaligned to 4 bytes, whereas using `char` can solve this issue.
*
* As we only use these symbol address, we declare them as `char` here
*/
extern char _instruction_reserved_start;
extern char _instruction_reserved_end;
extern char _rodata_reserved_start;
extern char _rodata_reserved_end;
const static char *TAG = "mmu_psram"; const static char *TAG = "mmu_psram";
static uint32_t s_irom_vaddr_start; static uint32_t s_irom_vaddr_start;

View File

@ -136,10 +136,19 @@ extern int _rtc_bss_end;
extern int _bss_bt_start; extern int _bss_bt_start;
extern int _bss_bt_end; extern int _bss_bt_end;
#endif // CONFIG_BT_LE_RELEASE_IRAM_SUPPORTED #endif // CONFIG_BT_LE_RELEASE_IRAM_SUPPORTED
extern int _instruction_reserved_start;
extern int _instruction_reserved_end; /**
extern int _rodata_reserved_start; * If using `int`, then for CLANG, with enabled optimization when inlined function is provided with the address of external symbol, the two least bits of the constant used inside that function get cleared.
extern int _rodata_reserved_end; * Optimizer assumes that address of external symbol should be aligned to 4-bytes and therefore aligns constant value used for bitwise AND operation with that address.
*
* This means `extern int _instruction_reserved_start;` can be unaligned to 4 bytes, whereas using `char` can solve this issue.
*
* As we only use these symbol address, we declare them as `char` here
*/
extern char _instruction_reserved_start;
extern char _instruction_reserved_end;
extern char _rodata_reserved_start;
extern char _rodata_reserved_end;
extern int _vector_table; extern int _vector_table;
#if SOC_INT_CLIC_SUPPORTED #if SOC_INT_CLIC_SUPPORTED

View File

@ -36,13 +36,13 @@
#include "spi_flash_mmap.h" #include "spi_flash_mmap.h"
#if CONFIG_SPIRAM_FETCH_INSTRUCTIONS #if CONFIG_SPIRAM_FETCH_INSTRUCTIONS
extern int _instruction_reserved_start; extern char _instruction_reserved_start;
extern int _instruction_reserved_end; extern char _instruction_reserved_end;
#endif #endif
#if CONFIG_SPIRAM_RODATA #if CONFIG_SPIRAM_RODATA
extern int _rodata_reserved_start; extern char _rodata_reserved_start;
extern int _rodata_reserved_end; extern char _rodata_reserved_end;
#endif #endif
#if !CONFIG_SPI_FLASH_ROM_IMPL #if !CONFIG_SPI_FLASH_ROM_IMPL