public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [Patch, avr] Use symbols for MEMORY region lengths if available
@ 2015-02-02  9:11 Senthil Kumar Selvaraj
  2015-02-24 13:27 ` Nicholas Clifton
  0 siblings, 1 reply; 2+ messages in thread
From: Senthil Kumar Selvaraj @ 2015-02-02  9:11 UTC (permalink / raw)
  To: binutils; +Cc: rchertykov, nickc

This patch modifies the AVR linker script templates to use
__<name>_REGION_LENGTH__ symbols, if provided, for setting memory region
lengths, defaulting to the current constant values otherwise. 

The ability to use symbols for MEMORY regions was added
recently, and this patch allows the user/compiler driver to control
region sizes on a per device basis by defining the appropriate symbols.
This way, more flash/RAM overflow errors will be caught at link time.

If this is ok, could someone commit please? I don't have commit access.

Regards
Senthil

ld/ChangeLog

2015-02-02  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>

	* scripttempl/avr.sc: Add new user_signatures region. Define and Use 
	symbols for all region lengths.
	* scripttempl/avrtiny.sc: Define and use symbols for all region lengths.

ld/testsuite/ChangeLog

2015-02-02  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>

	* ld-avr/region_overflow.d: New test.
	* ld-avr/region_overflow.s: Likewise.

diff --git a/ld/scripttempl/avr.sc b/ld/scripttempl/avr.sc
index cc4561f..038e7ab 100644
--- a/ld/scripttempl/avr.sc
+++ b/ld/scripttempl/avr.sc
@@ -14,14 +14,23 @@ cat <<EOF
 OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}")
 OUTPUT_ARCH(${ARCH})
 
+__TEXT_REGION_LENGTH__ = DEFINED(__TEXT_REGION_LENGTH__) ? __TEXT_REGION_LENGTH__ : $TEXT_LENGTH;
+__DATA_REGION_LENGTH__ = DEFINED(__DATA_REGION_LENGTH__) ? __DATA_REGION_LENGTH__ : $DATA_LENGTH;
+__EEPROM_REGION_LENGTH__ = DEFINED(__EEPROM_REGION_LENGTH__) ? __EEPROM_REGION_LENGTH__ : 64K;
+__FUSE_REGION_LENGTH__ = DEFINED(__FUSE_REGION_LENGTH__) ? __FUSE_REGION_LENGTH__ : 1K;
+__LOCK_REGION_LENGTH__ = DEFINED(__LOCK_REGION_LENGTH__) ? __LOCK_REGION_LENGTH__ : 1K;
+__SIGNATURE_REGION_LENGTH__ = DEFINED(__SIGNATURE_REGION_LENGTH__) ? __SIGNATURE_REGION_LENGTH__ : 1K;
+__USER_SIGNATURE_REGION_LENGTH__ = DEFINED(__USER_SIGNATURE_REGION_LENGTH__) ? __USER_SIGNATURE_REGION_LENGTH__ : 1K;
+
 MEMORY
 {
-  text   (rx)   : ORIGIN = 0, LENGTH = $TEXT_LENGTH
-  data   (rw!x) : ORIGIN = $DATA_ORIGIN, LENGTH = $DATA_LENGTH
-  eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 64K
-  fuse      (rw!x) : ORIGIN = 0x820000, LENGTH = 1K
-  lock      (rw!x) : ORIGIN = 0x830000, LENGTH = 1K
-  signature (rw!x) : ORIGIN = 0x840000, LENGTH = 1K
+  text   (rx)   : ORIGIN = 0, LENGTH = __TEXT_REGION_LENGTH__
+  data   (rw!x) : ORIGIN = $DATA_ORIGIN, LENGTH = __DATA_REGION_LENGTH__
+  eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = __EEPROM_REGION_LENGTH__
+  fuse      (rw!x) : ORIGIN = 0x820000, LENGTH = __FUSE_REGION_LENGTH__
+  lock      (rw!x) : ORIGIN = 0x830000, LENGTH = __LOCK_REGION_LENGTH__
+  signature (rw!x) : ORIGIN = 0x840000, LENGTH = __SIGNATURE_REGION_LENGTH__
+  user_signatures (rw!x) : ORIGIN = 0x850000, LENGTH = __USER_SIGNATURE_REGION_LENGTH__
 }
 
 SECTIONS
diff --git a/ld/scripttempl/avrtiny.sc b/ld/scripttempl/avrtiny.sc
index 6e8b09d..a4cf5db 100644
--- a/ld/scripttempl/avrtiny.sc
+++ b/ld/scripttempl/avrtiny.sc
@@ -14,17 +14,23 @@ cat <<EOF
 OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}")
 OUTPUT_ARCH(${ARCH})
 
+__TEXT_REGION_LENGTH__ = DEFINED(__TEXT_REGION_LENGTH__) ? __TEXT_REGION_LENGTH__ : $TEXT_LENGTH;
+__DATA_REGION_LENGTH__ = DEFINED(__DATA_REGION_LENGTH__) ? __DATA_REGION_LENGTH__ : $DATA_LENGTH;
+__FUSE_REGION_LENGTH__ = DEFINED(__FUSE_REGION_LENGTH__) ? __FUSE_REGION_LENGTH__ : 2;
+__LOCK_REGION_LENGTH__ = DEFINED(__LOCK_REGION_LENGTH__) ? __LOCK_REGION_LENGTH__ : 2;
+__SIGNATURE_REGION_LENGTH__ = DEFINED(__SIGNATURE_REGION_LENGTH__) ? __SIGNATURE_REGION_LENGTH__ : 4;
+
 MEMORY
 {
-  text   (rx)   : ORIGIN = $TEXT_ORIGIN, LENGTH = $TEXT_LENGTH
-  data   (rw!x) : ORIGIN = $DATA_ORIGIN, LENGTH = $DATA_LENGTH
+  text   (rx)   : ORIGIN = $TEXT_ORIGIN, LENGTH = __TEXT_REGION_LENGTH__
+  data   (rw!x) : ORIGIN = $DATA_ORIGIN, LENGTH = __DATA_REGION_LENGTH__
 
   /* Provide offsets for config, lock and signature to match
      production file format. Ignore offsets in datasheet.  */
 
-  config    (rw!x) : ORIGIN = 0x820000, LENGTH = 2
-  lock      (rw!x) : ORIGIN = 0x830000, LENGTH = 2
-  signature (rw!x) : ORIGIN = 0x840000, LENGTH = 4
+  config    (rw!x) : ORIGIN = 0x820000, LENGTH = __FUSE_REGION_LENGTH__
+  lock      (rw!x) : ORIGIN = 0x830000, LENGTH = __LOCK_REGION_LENGTH__
+  signature (rw!x) : ORIGIN = 0x840000, LENGTH = __SIGNATURE_REGION_LENGTH__
 }
 
 SECTIONS
diff --git a/ld/testsuite/ld-avr/region_overflow.d b/ld/testsuite/ld-avr/region_overflow.d
new file mode 100644
index 0000000..305d242
--- /dev/null
+++ b/ld/testsuite/ld-avr/region_overflow.d
@@ -0,0 +1,6 @@
+#name: AVR catch region overflow errors
+#as: -mmcu=avrxmega2
+#ld:  -mavrxmega2 --relax --defsym __TEXT_REGION_LENGTH__=2
+#source: region_overflow.s
+#target: avr-*-*
+#error: `.text' will not fit in region `text'
diff --git a/ld/testsuite/ld-avr/region_overflow.s b/ld/testsuite/ld-avr/region_overflow.s
new file mode 100644
index 0000000..c2899e7
--- /dev/null
+++ b/ld/testsuite/ld-avr/region_overflow.s
@@ -0,0 +1,5 @@
+.section .text
+.byte 0xA
+.byte 0xB
+.byte 0xC
+.byte 0xD

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Patch, avr] Use symbols for MEMORY region lengths if available
  2015-02-02  9:11 [Patch, avr] Use symbols for MEMORY region lengths if available Senthil Kumar Selvaraj
@ 2015-02-24 13:27 ` Nicholas Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nicholas Clifton @ 2015-02-24 13:27 UTC (permalink / raw)
  To: Senthil Kumar Selvaraj, binutils; +Cc: rchertykov

Hi Senthil,

> ld/ChangeLog
>
> 2015-02-02  Senthil Kumar Selvaraj<senthil_kumar.selvaraj@atmel.com>
>
> 	* scripttempl/avr.sc: Add new user_signatures region. Define and Use
> 	symbols for all region lengths.
> 	* scripttempl/avrtiny.sc: Define and use symbols for all region lengths.
>
> ld/testsuite/ChangeLog
>
> 2015-02-02  Senthil Kumar Selvaraj<senthil_kumar.selvaraj@atmel.com>
>
> 	* ld-avr/region_overflow.d: New test.
> 	* ld-avr/region_overflow.s: Likewise.
>

Approved and applied.

Cheers
   Nick


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-02-24 11:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-02  9:11 [Patch, avr] Use symbols for MEMORY region lengths if available Senthil Kumar Selvaraj
2015-02-24 13:27 ` Nicholas Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).