ld: pru: Allow IMEM and DMEM memory size overwriting

Message ID 20210508184102.29677-1-dimitar@dinux.eu
State New
Headers show
Series
  • ld: pru: Allow IMEM and DMEM memory size overwriting
Related show

Commit Message

Dimitar Dimitrov May 8, 2021, 6:41 p.m.
Allow IMEM and DMEM memory sizes to be overwritten from command line,
so that SoC-specific spec files can be simplified.

This would allow me to remove all SoC-specific linker scripts [1] and
instead maintain the differences using GCC specs only.

[1] https://github.com/dinuxbg/gnuprumcu/tree/master/ldscripts

ld/ChangeLog:

	* scripttempl/pru.sc: Use symbols for memory sizes.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>

---
 ld/scripttempl/pru.sc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

-- 
2.20.1

Comments

Mike Frysinger via Binutils May 10, 2021, 1:01 p.m. | #1
Hi Dimitar,

> ld/ChangeLog:

> 

> 	* scripttempl/pru.sc: Use symbols for memory sizes.


Approved and applied.

Cheers
   Nick

Patch

diff --git a/ld/scripttempl/pru.sc b/ld/scripttempl/pru.sc
index 9fda2084991..b2c941b7911 100644
--- a/ld/scripttempl/pru.sc
+++ b/ld/scripttempl/pru.sc
@@ -5,10 +5,14 @@  OUTPUT_ARCH(${ARCH})
 EOF
 
 test -n "${RELOCATING}" && cat <<EOF
+/* Allow memory sizes to be overridden from command line.  */
+__IMEM_SIZE = DEFINED(__IMEM_SIZE) ? __IMEM_SIZE : $TEXT_LENGTH;
+__DMEM_SIZE = DEFINED(__DMEM_SIZE) ? __DMEM_SIZE : $DATA_LENGTH;
+
 MEMORY
 {
-  imem   (x)   : ORIGIN = $TEXT_ORIGIN, LENGTH = $TEXT_LENGTH
-  dmem   (rw!x) : ORIGIN = $DATA_ORIGIN, LENGTH = $DATA_LENGTH
+  imem   (x)   : ORIGIN = $TEXT_ORIGIN, LENGTH = __IMEM_SIZE
+  dmem   (rw!x) : ORIGIN = $DATA_ORIGIN, LENGTH = __DMEM_SIZE
 }
 
 __HEAP_SIZE = DEFINED(__HEAP_SIZE) ? __HEAP_SIZE : 32;