bootrom: give phase2 .data its own RW segment instead of an RWX one

.data shared the bootphase2 output section with the RAM-executed code, so
the PM5 bootrom linked with "LOAD segment with RWX permissions" (CMake
silenced it with --no-warn-rwx-segments). Put .data in .bootphase2_data
with its own PT_LOAD, placed right after .bootphase2 in RAM and flash so
the existing copy loop still covers it; asserts guard the contiguity.

Same image size on RDV4/PM5/PM5+BWM; code identical bar .ramfunc moving
ahead of .data, data bytes unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
iceman1001andClaude Opus 5.5 committed 2026-11-10 07:35:47 +07:00
1 parent 5e8d208264
commit 3515724f9a
2 files changed
+12 -6

No files matched your search

-3
View File
@@ -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}
+12 -3
View File
@@ -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__ = .;