diff --git a/bootrom/CMakeLists.txt b/bootrom/CMakeLists.txt index 851da02b5..8c5976213 100644 --- a/bootrom/CMakeLists.txt +++ b/bootrom/CMakeLists.txt @@ -98,9 +98,6 @@ if (PM5) set(LIBS ${LIBS} pm5_at32_armlib) endif () -# Fix: warning: bootrom\bootrom.elf has a LOAD segment with RWX permissions -set(CROSS_LDFLAGS ${CROSS_LDFLAGS} -Wl,--no-warn-rwx-segments) - # Create version_pm3.c before bootrom build. add_custom_command( OUTPUT ${VERSION_PM3_C} diff --git a/bootrom/ldscript-flash-common b/bootrom/ldscript-flash-common index 23ad383a9..a3caed6f6 100644 --- a/bootrom/ldscript-flash-common +++ b/bootrom/ldscript-flash-common @@ -23,6 +23,7 @@ PHDRS { phase1 PT_LOAD; phase2 PT_LOAD; + phase2data PT_LOAD; bss PT_LOAD; } @@ -49,15 +50,23 @@ SECTIONS *(.glue_7t) *(.rodata) *(.rodata.*) - *(.data) - *(.data.*) *(.ramfunc) . = ALIGN(4); } >ram AT>bootphase2 :phase2 + /* own RW segment, else phase2 is RWX; copied together with .bootphase2 */ + .bootphase2_data : { + *(.data) + *(.data.*) + . = ALIGN(4); + } >ram AT>bootphase2 :phase2data + __bootphase2_src_start__ = LOADADDR(.bootphase2); __bootphase2_start__ = ADDR(.bootphase2); - __bootphase2_end__ = __bootphase2_start__ + SIZEOF(.bootphase2); + __bootphase2_end__ = ADDR(.bootphase2_data) + SIZEOF(.bootphase2_data); + + ASSERT(ADDR(.bootphase2_data) == __bootphase2_start__ + SIZEOF(.bootphase2), "bootphase2 data not contiguous in RAM") + ASSERT(LOADADDR(.bootphase2_data) == __bootphase2_src_start__ + SIZEOF(.bootphase2), "bootphase2 data not contiguous in flash") .bss : { __bss_start__ = .;