public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "Deepen Mantri" <Deepen.Mantri@kpitcummins.com>
To: "Alan Modra" <amodra@bigpond.net.au>
Cc: <binutils@sources.redhat.com>
Subject: RE: No error for  Linker Section Overlapping
Date: Mon, 23 Apr 2007 15:08:00 -0000	[thread overview]
Message-ID: <B9D27836A814694B95A1C294F714576684F791@sohm.kpit.com> (raw)
In-Reply-To: <20070421010118.GL6840@bubble.grove.modra.org>


On Sat, 21st April 2007 at 10:31:18 +0930 Alan Modra wrote:	

> >>  Also the allocation of the LMA address to non-loadable sections

> >>  (such as ".bss" section) is not prevented.		
> Why is this a problem?	 	 

I faced the problem while linking one of my project because of LMA

assignment to .bss section.		

Following is the relevant part from the linker script used in that
project:
////////////////////////////////////////////////////////////////////////
///
.
.
.data 0x3f00: AT(_mdata)  --> _mdata is some Load address from ROM
region
{
  _data = .;
  *(.data) 
  _edata = .; 
}>ram 

.bss 
{
    _bss = . ;
    *(.bss)
    *(COMMON)
     _ebss = . ;
     _end = . ;
} > ram
.
.
////////////////////////////////////////////////////////////////////////
//

The .bss section was assigned the LMA which was the end LMA of .data	
section. So .bss section consumed the space in ROM even though being the

non-loadable section.		
While linking the code, due to large size, the .bss section surpassed
the
end boundary of ROM region (In this case ROM size was 4K bytes). If the

.bss section had not been assigned the LMA, this error would not have
been
generated.		

> Changing this as you have done will break other code in the linker,	
> eg. _bfd_elf_map_sections_to_segments.	

I did the regression after applying the patch, and did not find any
unexpected failures. I checked the behaviour of
"_bfd_elf_map_sections_to_segments"	function also. As per my
understanding the behavior is same as in case of binutils 2.16.92.	

Using binutils 2.16.92 following segments got generated in which various

sections are mapped respectively. 
////////////////////////////////////////////////////////////////////////
/
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg
Align
  LOAD           0x0000b4 0x00000000 0x00000000 0x001a8 0x001a8 R E 0x1
  LOAD           0x00025c 0x000001a8 0x000001a8 0x00010 0x00010 RW  0x1
  LOAD           0x00026c 0x00040000 0x000001b8 0x00008 0x00008 RW  0x1
  LOAD           0x000274 0x00040008 0x00040008 0x00000 0x00004 RW  0x1

 Section to Segment mapping:
  Segment Sections...
   00     .vects .text .rodata 
   01     .tors 
   02     .data 
   03     .bss 
////////////////////////////////////////////////////////////////////////
//   

In binutils 2.17 .bss section got mapped in the segment in which .data
is
placed. This is because .bss was assigned the LMA following the .data
section.
////////////////////////////////////////////////////////////////////////
//
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg
Align
  LOAD           0x000094 0x00000000 0x00000000 0x001a8 0x001a8 R E 0x1
  LOAD           0x00023c 0x000001a8 0x000001a8 0x00010 0x00010 RW  0x1
  LOAD           0x00024c 0x00040000 0x000001b8 0x00008 0x0000c RW  0x1

 Section to Segment mapping:
  Segment Sections...
   00     .vects .text .rodata 
   01     .tors 
   02     .data .bss 
////////////////////////////////////////////////////////////////////////
//

By not allocating the LMA to .bss, the behaviour as in the case of
previous
binutils version is achieved.
////////////////////////////////////////////////////////////////////////
//
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg
Align
  LOAD           0x0000b4 0x00000000 0x00000000 0x001a8 0x001a8 R E 0x1
  LOAD           0x00025c 0x000001a8 0x000001a8 0x00010 0x00010 RW  0x1
  LOAD           0x00026c 0x00040000 0x000001b8 0x00008 0x00008 RW  0x1
  LOAD           0x000274 0x00040008 0x00040008 0x00000 0x00004 RW  0x1

 Section to Segment mapping:
  Segment Sections...
   00     .vects .text .rodata 
   01     .tors 
   02     .data 
   03     .bss 
////////////////////////////////////////////////////////////////////////
//

Isn't this the expected behaviour? 

> Changing this as you have done will break other code in the linker,	

Could you please explain me in detail, what could be the other
consequences
of the modifications done? 
This will help me to investigate the problem further.

Regards,		
Deepen Mantri		

KPIT Cummins InfoSystems Ltd.		
Pune, India		
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Free download of GNU based tool-chains for Renesas' SH, H8, R8C, M16C

and M32C Series. The following site also offers free technical support

to its users. Visit http://www.kpitgnutools.com for details.

Latest versions of KPIT GNU tools were released on February 6, 2007.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~	

  reply	other threads:[~2007-04-23 14:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-12 13:50 Deepen Mantri
2007-04-14  1:42 ` Alan Modra
2007-04-17 13:17   ` Deepen Mantri
2007-04-18  4:10     ` Alan Modra
2007-04-19 17:05       ` Deepen Mantri
2007-04-21  5:01         ` Alan Modra
2007-04-23 15:08           ` Deepen Mantri [this message]
2007-04-23 15:32             ` Alan Modra
2007-04-24 10:59               ` Deepen Mantri

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B9D27836A814694B95A1C294F714576684F791@sohm.kpit.com \
    --to=deepen.mantri@kpitcummins.com \
    --cc=amodra@bigpond.net.au \
    --cc=binutils@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).