Skip to content

Commit

Permalink
Fix bss section placement in db mode
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MabezDev committed Aug 9, 2022
1 parent 91ea205 commit 99ae152
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions esp32c3-hal/ld/db-riscv-link.x
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) :
{
Expand Down

0 comments on commit 99ae152

Please sign in to comment.