From eb21349a11d589b2ead82edf5b3a8aa3b90871da Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Fri, 3 Jul 2026 14:12:13 +0100 Subject: [PATCH] Fix elf squashing Don't attempt to squash segments which are on top of previous segments (e.g. a partition table on top of .bss) Fixes pico-examples enc_bootloader build on clang, and any other signed builds with embedded partition tables --- elf/elf_file.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/elf/elf_file.cpp b/elf/elf_file.cpp index f76eaf46..d5cd5e93 100644 --- a/elf/elf_file.cpp +++ b/elf/elf_file.cpp @@ -588,6 +588,7 @@ void elf_file::store_squashed(model_t model) { } uint32_t last_seg_end = 0; + uint32_t last_seg_start = 0; std::vector xip_sram_segs = {}; @@ -595,7 +596,11 @@ void elf_file::store_squashed(model_t model) { const uint32_t paddr = seg->physical_address(); const uint32_t psize = seg->physical_size(); if (!seg->is_load()) return; - if (psize == 0) return; + + const bool is_alias = paddr == last_seg_start; + last_seg_start = paddr; + + if (psize == 0 || is_alias) return; if (last_seg_end) { if (paddr != last_seg_end) {