[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-dev] Export fuse memory size as a symbol

From: Senthil Kumar Selvaraj
Subject: [avr-libc-dev] Export fuse memory size as a symbol
Date: Wed, 16 Mar 2016 16:24:34 +0530
User-agent: mu4e 0.9.13; emacs 24.5.1


  Now that binutils 2.26 supports symbols for memory region lengths,
  I thought it would be nice to have avr-libc's crt file export those
  symbols from the gcrt1.S, so that overflows can be detected at link

  This is how the standard linker script memory map looks now, with the
  default values for the *_LENGTH__ symbols being the previous constant values.

  text   (rx)   : ORIGIN = 0, LENGTH = __TEXT_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 = 

Previously, only constant literals were allowed for the LENGTH
parameter, so the lengths were set to match the device with the biggest
size for each architecture, IIRC. Only if user code managed to overflow
one of those would the linker complain.

Now that symbols work, it is possible to set region lengths accurately on a per
device basis and have the linker error out if any of them
overflow. Someone needs to define them though, and I thought avr-libc's
crt file, being compiled for each device, might be a good candidate.

For starters, the below patch defines __FUSE_REGION_LENGTH__ as a weak

diff --git avr-libc/crt1/gcrt1.S avr-libc/crt1/gcrt1.S
index 561d4f8..b2f482b 100644
--- avr-libc/crt1/gcrt1.S
+++ avr-libc/crt1/gcrt1.S
@@ -390,3 +390,8 @@ __do_copy_data:
     .balign 4
+  /* Set length symbol values - this linker script
+  and the linker use these to detect size overflows.
+  */

Is this ok?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]