Browse Source

Show heap/stack size.

David Craven 7 years ago
parent
commit
03dec09e18
1 changed files with 22 additions and 5 deletions
  1. 22 5
      riscv-rt/link.x

+ 22 - 5
riscv-rt/link.x

@@ -25,15 +25,15 @@ SECTIONS
     . = ALIGN(4);
     . = ALIGN(4);
   } > FLASH
   } > FLASH
 
 
-  .bss : ALIGN(4)
+  PROVIDE(_sbss = ORIGIN(RAM));
+  .bss _sbss : ALIGN(4)
   {
   {
-    _sbss = .;
     *(.bss .bss.*);
     *(.bss .bss.*);
     . = ALIGN(4);
     . = ALIGN(4);
     _ebss = .;
     _ebss = .;
   } > RAM
   } > RAM
 
 
-  .data : ALIGN(4)
+  .data _ebss : ALIGN(4)
   {
   {
     _sidata = LOADADDR(.data);
     _sidata = LOADADDR(.data);
     _sdata = .;
     _sdata = .;
@@ -44,6 +44,25 @@ SECTIONS
     _edata = .;
     _edata = .;
   } > RAM AT > FLASH /* LLD fails on AT > FLASH */
   } > RAM AT > FLASH /* LLD fails on AT > FLASH */
 
 
+  PROVIDE(_heap_size = 0);
+
+  /* fictitious region that represents the memory available for the heap */
+  .heap _edata (INFO) : ALIGN(4)
+  {
+    _sheap = .;
+    . += _heap_size;
+    . = ALIGN(4);
+    _eheap = .;
+  }
+
+  /* fictitious region that represents the memory available for the stack */
+  .stack _eheap (INFO) : ALIGN(4)
+  {
+    _estack = .;
+    . = _stack_start;
+    _sstack = .;
+  }
+
   /* fake output .got section */
   /* fake output .got section */
   /* Dynamic relocations are unsupported. This section is only used to detect
   /* Dynamic relocations are unsupported. This section is only used to detect
      relocatable code in the input files and raise an error if relocatable code
      relocatable code in the input files and raise an error if relocatable code
@@ -55,8 +74,6 @@ SECTIONS
     _egot = .;
     _egot = .;
   } > RAM AT > FLASH /* LLD fails on AT > FLASH */
   } > RAM AT > FLASH /* LLD fails on AT > FLASH */
 
 
-  /* The heap starts right after the .bss + .data section ends */
-  _sheap = _edata;
 
 
   /* Due to an unfortunate combination of legacy concerns,
   /* Due to an unfortunate combination of legacy concerns,
      toolchain drawbacks, and insufficient attention to detail,
      toolchain drawbacks, and insufficient attention to detail,