You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2022/08/25 11:50:19 UTC

[mynewt-core] branch master updated: riscv: Fix initialized data

This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 988562e1b riscv: Fix initialized data
988562e1b is described below

commit 988562e1b7f2346fcf02dc809ff1a8ee6e575578
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Thu Aug 25 08:44:51 2022 +0200

    riscv: Fix initialized data
    
    Startup script has only one loop that copies initialized data and
    code that should execute from RAM.
    It implies that variables in .data .ram_text .srodata .sdata and such
    has same layout in flash and in RAM.
    Those data are packed by default in flash so output sections
    (.data .srodata .sdata) if they start with something that requires
    alignment change may end up with wrong data being copied to
    statically initialized data.
    One way to prevent such case is to copy each output section in separate
    loop. But it is also possibly to add output section attribute ALIGN_WITH_INPUT
    and then linker will fill necessary space in flash image.
---
 hw/bsp/hifive1/hifive1.ld | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/bsp/hifive1/hifive1.ld b/hw/bsp/hifive1/hifive1.ld
index 1d86c8b58..40ff08b1b 100644
--- a/hw/bsp/hifive1/hifive1.ld
+++ b/hw/bsp/hifive1/hifive1.ld
@@ -128,14 +128,14 @@ SECTIONS
     PROVIDE( _data = . );
   } >ram AT>flash
 
-  .data          :
+  .data          :  ALIGN_WITH_INPUT
   {
     *(.ram_text, .ram_text.*)
     *(.data .data.*)
     *(.gnu.linkonce.d.*)
   } >ram AT>flash
 
-  .srodata        :
+  .srodata        : ALIGN_WITH_INPUT
   {
     PROVIDE( _gp = . + 0x800 );
     PROVIDE( __global_pointer$ = _gp);
@@ -146,7 +146,7 @@ SECTIONS
     *(.srodata .srodata.*)
   } >ram AT>flash
 
-  .sdata          :
+  .sdata          : ALIGN_WITH_INPUT
   {
     *(.sdata .sdata.*)
     *(.gnu.linkonce.s.*)