This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to inform the linker not to produce any data for a .bsssection?


Daniel Jacobowitz wrote:
This is necessary alignment. If you don't want .bss to take up space
in the file, do not put allocated sections after it.

Is there any way to change that behavior without causing problems?


I'm trying to regain a little extra memory for the heap on a newlib based toolchain where the device binary starts in RAM. It's an arm946 with 48k of tcm.

I've tried placing .itcm & .dtcm sections after the .bss section which causes it to consume space in the binary so I tried setting the VMA for the bss to the LMA for the first preceeding section, like this

__dtcm_lma = . ;

   .dtcm __dtcm_start : AT (__dtcm_lma)
   {
       *(.dtcm)
       *(.dtcm.*)
       . = ALIGN(4);
       __dtcm_end = ABSOLUTE(.);
   } >dtcm = 0xff


__itcm_lma = __dtcm_lma + SIZEOF(.dtcm);


.itcm __itcm_start : AT (__itcm_lma)
{
*(.itcm)
*itcm.*(.text)
. = ALIGN(4);
__itcm_end = ABSOLUTE(.);
} >itcm = 0xff
.sbss __dtcm_end :
{
__sbss_start = ABSOLUTE(.);
__sbss_start__ = ABSOLUTE(.);
*(.sbss)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
__sbss_end = ABSOLUTE(.);
} >dtcm


__bss_lma = __itcm_lma + SIZEOF(.itcm) ;
__appended_data = __itcm_lma + SIZEOF(.itcm) ;
.bss __bss_lma : AT (__dtcm_lma)
{
__bss_start = ABSOLUTE(.);
__bss_start__ = ABSOLUTE(.);
*(.dynbss)
*(.gnu.linkonce.b*)
*(.bss*)
*(COMMON)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
__bss_end = ABSOLUTE(.) ;
__bss_end__ = __bss_end ;
} >ewram



_end = . ; __end__ = . ; PROVIDE (end = _end);

ld errored with "section .bss [0200c5b8 -> 0200c647] overlaps section .itcm [0200c5b8 -> 0200c747]" so I tried placing .bss first & setting the LMA of the following section to the bss segment. That got me the opposite error.

   __dtcm_lma = . ;
 __bss_start = .;
 __bss_start__ = .;
 .bss            :
 {
  *(.dynbss)
  *(.bss .bss.* .gnu.linkonce.b.*)
  *(COMMON)
  /* Align here to ensure that the .bss section occupies space up to
     _end.  Align after .bss to ensure correct alignment even if the
     .bss section disappears because there are no input sections.
     FIXME: Why do we need it? When there is no .bss section, we don't
     pad the .data section.  */
  . = ALIGN(. != 0 ? 32 / 8 : 1);
 } >ewram
 __bss_end = . ; __bss_end__ = . ;
   _end = . ;
   __end__ = . ;


.dtcm __dtcm_start : AT (__dtcm_lma) { *(.dtcm) *(.dtcm.*) . = ALIGN(4); __dtcm_end = ABSOLUTE(.); } >dtcm


__itcm_lma = __dtcm_lma + SIZEOF(.dtcm);


   .itcm __itcm_start : AT (__itcm_lma)
   {
       *(.itcm)
       *itcm.*(.text)
       . = ALIGN(4);
       __itcm_end = ABSOLUTE(.);
   } >itcm

Dave


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]