From 1f95182e555bc7a00b40f8a56229cf33141f0c66 Mon Sep 17 00:00:00 2001 From: Li Shuai Date: Wed, 5 Nov 2025 20:53:49 +0800 Subject: [PATCH] fix(ld): fix cannot move location counter backwards (from 3fc88000 to 3fc87a00) --- components/esp_system/ld/esp32s3/sections.ld.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/esp_system/ld/esp32s3/sections.ld.in b/components/esp_system/ld/esp32s3/sections.ld.in index c6649ba3a6..f293976428 100644 --- a/components/esp_system/ld/esp32s3/sections.ld.in +++ b/components/esp_system/ld/esp32s3/sections.ld.in @@ -205,7 +205,8 @@ SECTIONS */ .dram0.dummy (NOLOAD): { - . = ORIGIN(dram0_0_seg) + MAX(_iram_end - _diram_i_start, 0); + /* MAX() uses unsigned long arithmetic. Add offset to prevent underflow when _iram_end < _diram_i_start */ + . = ORIGIN(dram0_0_seg) + MAX(_iram_end - _diram_i_start + (_diram_i_start - ORIGIN(iram0_0_seg)), (_diram_i_start - ORIGIN(iram0_0_seg))) - (_diram_i_start - ORIGIN(iram0_0_seg)); } > dram0_0_seg .dram0.data :