[PATCH] ld: pru: Allow IMEM and DMEM memory size overwriting

Dimitar Dimitrov dimitar@dinux.eu
Sat May 8 18:41:02 GMT 2021


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(-)

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;
-- 
2.20.1



More information about the Binutils mailing list