Recently we have updated the armgcc toolchain version to 8-2018-q4-major, and we found that our previous memory definition way in linker file is invalid.
Previously, we are using below LENGTH() way to calculate the origin for a defined memory:
IMAGE_START_ADDR = DEFINED(XIP_IMAGE) ? 0x10000000 : 0x00000000;DATA_START_ADDR = DEFINED(XIP_IMAGE) ? 0x00000004 : 0x20000000;TEXT_SECTION_SIZE = DEFINED(XIP_IMAGE) ? 0x00FFFE3C : 0x0002FE3C;DATA_SECTION_SIZE = DEFINED(XIP_IMAGE) ? 0x0002FFFC : 0x00028000;
/* Specify the memory areas */MEMORY{ m_interrupts (RX) : ORIGIN = IMAGE_START_ADDR, LENGTH = 0x000001C4 m_text (RX) : ORIGIN = IMAGE_START_ADDR + LENGTH(m_interrupts), LENGTH = TEXT_SECTION_SIZE m_data (RW) : ORIGIN = DATA_START_ADDR, LENGTH = DATA_SECTION_SIZE m_usb_sram (RW) : ORIGIN = 0x40100000, LENGTH = 0x00002000}
AND there will show build error as below:
/usr/local/gcc-arm-none-eabi-8-2018-q4-major/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld: invalid origin for memory region m_text
After replace the LENGTH(m_interrupts) with Immediate 0x000001C4, https://roadrunneremail.org l the compile error gone.
No such issue with armgcc version 7-2018-q2-update, so, why gcc8 cannot support the way in memory definition?
The largely identical question was asked here https://community.arm.com/developer/tools-software/oss-platforms/f/gnu-toolchain-forum/44650/cannot-use-length-in-memory-definition-in-linker-file-for-arm-gcc-8-2018-q4-major , which has been answered.