public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@bigpond.net.au>
To: Deepen Mantri <Deepen.Mantri@kpitcummins.com>
Cc: binutils@sources.redhat.com
Subject: Re: No error for  Linker Section Overlapping
Date: Wed, 18 Apr 2007 04:10:00 -0000	[thread overview]
Message-ID: <20070418035357.GB25113@bubble.grove.modra.org> (raw)
In-Reply-To: <B9D27836A814694B95A1C294F71457666D64AF@sohm.kpit.com>

On Tue, Apr 17, 2007 at 04:41:48PM +0530, Deepen Mantri wrote:
> >> The changes to lma assignment made using overlays considerably 	
> >> simpler.  In particular, sections following an overlay area now	
> >> don't need their LMAs set.	
> 
> Yes, this is correct. However, it now seems to me that keyword 	
> "OVERLAY" has become redundant.

It always has been redundant.  See the "syntactic sugar" comment in
the ld info doc.

> Even if you do not use or intend 	
> to use it, the sections having overlapped VMAs are going to be 	
> considered as overlay sections.	

Well, yes.  After all, an overlapping VMA is the only difference
between an "overlay" section and a "normal" section as far as the
linker is concerned.  Prior to my change to LMA assignment, you
needed to specify the LMA on all overlay sections (or use the OVERLAY
keyword which did this for you), and all following sections (which the
OVERLAY keyword did not do).  Now you need to specify the LMA as well
if you specify VMA and *don't* want overlays, but see below.

> But can't we add an additional check, whether the sections having 	
> overlapped VMAs are overlay or not, before changing their LMAs?

Hmm, we could, by making the OVERLAY keyword affect the section type.
This should bring back the old behaviour for you but still give most
of the ease of use improvement for overlays.

ld/
	* ldlang.h (enum section_type): Add overlay_section.
	* ldlang.c (lang_add_section): Handle flags for overlay_section
	as per normal_section.
	(lang_size_sections_1): When setting lma, detect overlays by
	os->sectype rather than by looking for overlapping vmas.
	(lang_enter_overlay_section): Use overlay_section type.
	(lang_leave_overlay): Set first overlay section to normal.
ld/testsuite/
	* ld-spu/ovl.lnk: Use OVERLAY keyword.

Index: ld/ldlang.h
===================================================================
RCS file: /cvs/src/src/ld/ldlang.h,v
retrieving revision 1.72
diff -u -p -r1.72 ldlang.h
--- ld/ldlang.h	26 Mar 2007 11:10:44 -0000	1.72
+++ ld/ldlang.h	18 Apr 2007 02:10:00 -0000
@@ -108,6 +108,7 @@ typedef struct lang_output_statement_str
 enum section_type
 {
   normal_section,
+  overlay_section,
   noload_section,
   noalloc_section
 };
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.257
diff -u -p -r1.257 ldlang.c
--- ld/ldlang.c	10 Apr 2007 18:00:26 -0000	1.257
+++ ld/ldlang.c	18 Apr 2007 02:09:59 -0000
@@ -2040,6 +2040,7 @@ lang_add_section (lang_statement_list_ty
       switch (output->sectype)
 	{
 	case normal_section:
+	case overlay_section:
 	  break;
 	case noalloc_section:
 	  flags &= ~SEC_ALLOC;
@@ -4438,14 +4439,9 @@ lang_size_sections_1
 		  }
 		else
 		  {
-		    /* If the current vma overlaps the previous section,
-		       then set the current lma to that at the end of
-		       the previous section.  The previous section was
-		       probably an overlay.  */
-		    if ((dot >= last->vma
-			 && dot < last->vma + last->size)
-			|| (last->vma >= dot
-			    && last->vma < dot + os->bfd_section->size))
+		    /* If this is an overlay, set the current lma to that
+		       at the end of the previous section.  */
+		    if (os->sectype == overlay_section)
 		      lma = last->lma + last->size;
 
 		    /* Otherwise, keep the same lma to vma relationship
@@ -6392,7 +6388,7 @@ lang_enter_overlay_section (const char *
   struct overlay_list *n;
   etree_type *size;
 
-  lang_enter_output_section_statement (name, overlay_vma, normal_section,
+  lang_enter_output_section_statement (name, overlay_vma, overlay_section,
 				       0, overlay_subalign, 0, 0);
 
   /* If this is the first section, then base the VMA of future
@@ -6506,7 +6502,10 @@ lang_leave_overlay (etree_type *lma_expr
 	 The base address is not needed (and should be null) if
 	 an LMA region was specified.  */
       if (l->next == 0)
-	l->os->load_base = lma_expr;
+	{
+	  l->os->load_base = lma_expr;
+	  l->os->sectype = normal_section;
+	}
       if (phdrs != NULL && l->os->phdrs == NULL)
 	l->os->phdrs = phdrs;
 
Index: ld/testsuite/ld-spu/ovl.lnk
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-spu/ovl.lnk,v
retrieving revision 1.1
diff -u -p -r1.1 ovl.lnk
--- ld/testsuite/ld-spu/ovl.lnk	25 Oct 2006 06:49:21 -0000	1.1
+++ ld/testsuite/ld-spu/ovl.lnk	18 Apr 2007 02:10:03 -0000
@@ -3,10 +3,11 @@ SECTIONS
   . = SIZEOF_HEADERS;
   .text : { *(.text) *(.stub) }
 
-  . = 0x400;
-  .ov_a1 : { *(.ov_a1) }
-  .ov_a2 ADDR (.ov_a1) : { *(.ov_a2) }
-  . = ADDR (.ov_a1) + MAX (SIZEOF (.ov_a1), SIZEOF (.ov_a2));
+  OVERLAY 0x400 :
+  {
+    .ov_a1 { *(.ov_a1) }
+    .ov_a2 { *(.ov_a2) }
+  }
 
   .data : { *(.data) *(.ovtab) }
   .bss : { *(.bss) }

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

  reply	other threads:[~2007-04-18  3:54 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 [this message]
2007-04-19 17:05       ` Deepen Mantri
2007-04-21  5:01         ` Alan Modra
2007-04-23 15:08           ` Deepen Mantri
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=20070418035357.GB25113@bubble.grove.modra.org \
    --to=amodra@bigpond.net.au \
    --cc=Deepen.Mantri@kpitcummins.com \
    --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).