Bug 12484 - avr-ld doesn't warn when a memory section is over
Summary: avr-ld doesn't warn when a memory section is over
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.21
: P2 critical
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-11 15:41 UTC by massi
Modified: 2017-06-17 04:48 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
A sample to reproduce the problem (2.29 KB, application/x-gzip)
2011-02-11 15:41 UTC, massi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description massi 2011-02-11 15:41:42 UTC
Created attachment 5235 [details]
A sample to reproduce the problem

the initialized data belongs to ram, but them images is hold in flash of microcontroller.

Suppose to have a 32KB flash ans 2KB sram microncontroller.
Suppose to have a .text section as big as 31KB, and suppose to have a vector of initialized data as big as 1.5KB.

The binary file will be 32.5KB long, too long to be programmed into microcontroller's flash.

I would expect a linker error like:
region `text' overflowed by xx bytes
Comment 1 Pitchumani 2017-06-12 13:02:48 UTC
IMO, linker script should have been changed,

from:
  .data   : AT (ADDR (.text) + SIZEOF (.text))                                                                                                        
   {
      PROVIDE (__data_start = .) ;
     *(.data) 
     *(.data*)
     *(.rodata)  /* We need to include .rodata here if gcc is used */
     *(.rodata*) /* with -fdata-sections.  */
     *(.gnu.linkonce.d*)
     . = ALIGN(2);
      _edata = . ;
      PROVIDE (__data_end = .) ;
   }  > data

to:
  .data   : 
   {
      PROVIDE (__data_start = .) ;
     *(.data) 
     *(.data*)
     *(.rodata)  /* We need to include .rodata here if gcc is used */
     *(.rodata*) /* with -fdata-sections.  */
     *(.gnu.linkonce.d*)
     . = ALIGN(2);
      _edata = . ;
      PROVIDE (__data_end = .) ;
   }  > data AT> text

This way linker knows from which region the .data to be loaded, and finds overflow correctly.
Comment 2 Nick Clifton 2017-06-16 11:00:41 UTC
Hi Pitchumani,

(In reply to Pitchumani from comment #1)
> IMO, linker script should have been changed,

I think that you are using an old version of the linker.  The latest release
(2.28) already contains the change you are suggesting.

Cheers
  Nick
Comment 3 Pitchumani 2017-06-17 04:48:59 UTC
(In reply to Nick Clifton from comment #2)
> Hi Pitchumani,
> 
> (In reply to Pitchumani from comment #1)
> > IMO, linker script should have been changed,
> 
> I think that you are using an old version of the linker.  The latest release
> (2.28) already contains the change you are suggesting.

Hi Nick
Thanks. Yes, I meant the OP's attached testcase/ linker script.