From 99ae152f5588261b603b5284bdd49436270ff03d Mon Sep 17 00:00:00 2001 From: Scott Mabin Date: Tue, 9 Aug 2022 23:51:28 +0100 Subject: [PATCH] Fix bss section placement in db mode If bss contained anything a linker error was emitted about overlapping sections. Moving the .bss section to after the .rwtext, and adding a dummy section to pad data bus access to the bss section fixes this. --- esp32c3-hal/ld/db-riscv-link.x | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/esp32c3-hal/ld/db-riscv-link.x b/esp32c3-hal/ld/db-riscv-link.x index 7e061153d..2843e5da4 100644 --- a/esp32c3-hal/ld/db-riscv-link.x +++ b/esp32c3-hal/ld/db-riscv-link.x @@ -86,14 +86,6 @@ SECTIONS } > REGION_DATA _data_size = _edata - _sdata + 8; - .bss (NOLOAD) : - { - _sbss = .; - *(.sbss .sbss.* .bss .bss.*); - . = ALIGN(4); - _ebss = .; - } > REGION_BSS - .rwtext ORIGIN(REGION_RWTEXT) + _data_size : AT(_text_size + _rodata_size + _data_size){ _srwtext = .; *(.rwtext); @@ -102,6 +94,22 @@ SECTIONS } > REGION_RWTEXT _rwtext_size = _erwtext - _srwtext + 8; + .rwtext.dummy (NOLOAD): + { + /* This section is required to skip .rwtext area because REGION_RWTEXT + * and REGION_BSS reflect the same address space on different buses. + */ + . = ORIGIN(REGION_BSS) + _rwtext_size; + } > REGION_BSS + + .bss (NOLOAD) : + { + _sbss = .; + *(.sbss .sbss.* .bss .bss.*); + . = ALIGN(4); + _ebss = .; + } > REGION_BSS + /* fictitious region that represents the memory available for the heap */ .heap (NOLOAD) : {