From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8359 invoked by alias); 18 Apr 2007 03:54:17 -0000 Received: (qmail 8350 invoked by uid 22791); 18 Apr 2007 03:54:16 -0000 X-Spam-Check-By: sourceware.org Received: from omta05sl.mx.bigpond.com (HELO omta05sl.mx.bigpond.com) (144.140.93.195) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 18 Apr 2007 04:54:07 +0100 Received: from oaamta07sl.mx.bigpond.com ([144.136.165.71]) by omta05sl.mx.bigpond.com with ESMTP id <20070418035359.RQIL25724.omta05sl.mx.bigpond.com@oaamta07sl.mx.bigpond.com>; Wed, 18 Apr 2007 03:53:59 +0000 Received: from bubble.grove.modra.org ([144.136.165.71]) by oaamta07sl.mx.bigpond.com with ESMTP id <20070418035359.WWLA21236.oaamta07sl.mx.bigpond.com@bubble.grove.modra.org>; Wed, 18 Apr 2007 03:53:59 +0000 Received: by bubble.grove.modra.org (Postfix, from userid 500) id 675B52B5726; Wed, 18 Apr 2007 13:23:58 +0930 (CST) Date: Wed, 18 Apr 2007 04:10:00 -0000 From: Alan Modra To: Deepen Mantri Cc: binutils@sources.redhat.com Subject: Re: No error for Linker Section Overlapping Message-ID: <20070418035357.GB25113@bubble.grove.modra.org> Mail-Followup-To: Deepen Mantri , binutils@sources.redhat.com References: <20070414012736.GP28088@bubble.grove.modra.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.9i X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2007-04/txt/msg00226.txt.bz2 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