瀏覽代碼

align VMA not LMA

This aligns the VMA (virtual adddress at runtime):

    .rodata ALIGN(4) :
    {
        ...

whereas this aligns the LMA (load address):

    .rodata : ALIGN(4)
    {
        ...

If we ensure the VMA is aligned the linker will keep the corresponding
LMA in sync (and it will be aligned too).

Previously, by forcing the LMA to be aligned but leaving the VMA
unspecified, the linker would split .text and .rodata into two
separate loads because their addresses fell out of sync.
Dan Callaghan 6 年之前
父節點
當前提交
9b5c0cd41b
共有 1 個文件被更改,包括 4 次插入5 次删除
  1. 4 5
      riscv-rt/link.x

+ 4 - 5
riscv-rt/link.x

@@ -7,7 +7,7 @@ SECTIONS
 {
   PROVIDE(_stext = ORIGIN(FLASH));
 
-  .text _stext : ALIGN(4)
+  .text ALIGN(_stext,4) :
   {
     /* Put reset handler first in .text section so it ends up as the entry */
     /* point of the program. */
@@ -19,21 +19,20 @@ SECTIONS
     *(.text .text.*);
   } > FLASH
 
-  .rodata : ALIGN(4)
+  .rodata ALIGN(4) :
   {
     *(.rodata .rodata.*);
-    . = ALIGN(4);
   } > FLASH
 
   PROVIDE(_sbss = ORIGIN(RAM));
-  .bss _sbss : ALIGN(4)
+  .bss ALIGN(_sbss,4) :
   {
     *(.bss .bss.*);
     . = ALIGN(4);
     _ebss = .;
   } > RAM
 
-  .data _ebss : ALIGN(4)
+  .data _ebss :
   {
     _sidata = LOADADDR(.data);
     _sdata = .;