From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10522 invoked by alias); 22 Apr 2010 01:53:36 -0000 Received: (qmail 10306 invoked by uid 22791); 22 Apr 2010 01:53:21 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM X-Spam-Check-By: sourceware.org Received: from mail-gw0-f41.google.com (HELO mail-gw0-f41.google.com) (74.125.83.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 22 Apr 2010 01:53:13 +0000 Received: by gwj15 with SMTP id 15so1918785gwj.0 for ; Wed, 21 Apr 2010 18:53:10 -0700 (PDT) Received: by 10.101.170.34 with SMTP id x34mr71700ano.228.1271901190142; Wed, 21 Apr 2010 18:53:10 -0700 (PDT) Received: from bubble.grove.modra.org ([115.187.252.19]) by mx.google.com with ESMTPS id 30sm3043542anp.11.2010.04.21.18.53.07 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 21 Apr 2010 18:53:09 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 145C8170C2B5; Thu, 22 Apr 2010 11:23:03 +0930 (CST) Date: Thu, 22 Apr 2010 01:53:00 -0000 From: Alan Modra To: David Stubbs , binutils@sourceware.org Subject: Re: VMA section overlap warnings for overlays Message-ID: <20100422015303.GK3510@bubble.grove.modra.org> Mail-Followup-To: David Stubbs , binutils@sourceware.org References: <4D60B0700D1DB54A8C0C6E9BE69163700E67DFD1@EXCHANGEVS.IceraSemi.local> <20100421082441.GG3510@bubble.grove.modra.org> <4D60B0700D1DB54A8C0C6E9BE69163700E7815C7@EXCHANGEVS.IceraSemi.local> <20100422011106.GI3510@bubble.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100422011106.GI3510@bubble.grove.modra.org> User-Agent: Mutt/1.5.20 (2009-06-14) 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: 2010-04/txt/msg00305.txt.bz2 On Thu, Apr 22, 2010 at 10:41:06AM +0930, Alan Modra wrote: > Now we have a problem. If we put .overlay1 in imem at p_offset+1 then > the execution model lma (calculated from p_paddr+p_offset+1) for > .overlay1 will be correct, but the vma (from p_vaddr+p_offset+1 > ie. 0x2001) will be wrong. Of course, with multiple overlays packed > into one header you can't possibly get the execution model vma correct > for all the overlays, so you probably don't care. However, the > ELF_IS_SECTION_IN_SEGMENT_FILE test in > elf.c:assign_file_positions_for_load_sections fails, which is why you > get a linker error. > > Conversely, putting .overlay1 at p_offset+0x2000 will give the correct > vma but the wrong lma, and of course insert a whole lot of padding. > This is what Jan's patch did, and is quite wrong for overlays.. Committed. I didn't see any occurrence of the problem Jan originally reported in http://sourceware.org/ml/binutils/2008-05/msg00235.html on i386 or powerpc using recent compilers so perhaps some other change cured it. bfd/ * elf.c (assign_file_positions_for_load_sections): Revert 2008-05-29 change. Tidy. Don't error on sections not allocated in segment. ld/testsuite/ * ld-elf/extract-symbol-1sec.d: Update lma. * ld-i386/alloc.d: Expect a warning, not an error. Index: bfd/elf.c =================================================================== RCS file: /cvs/src/src/bfd/elf.c,v retrieving revision 1.508 diff -u -p -r1.508 elf.c --- bfd/elf.c 10 Apr 2010 22:21:31 -0000 1.508 +++ bfd/elf.c 22 Apr 2010 01:10:22 -0000 @@ -4453,32 +4453,17 @@ assign_file_positions_for_load_sections && ((this_hdr->sh_flags & SHF_TLS) == 0 || p->p_type == PT_TLS)))) { - bfd_signed_vma adjust = sec->vma - (p->p_vaddr + p->p_memsz); + bfd_vma adjust = sec->lma - (p->p_paddr + p->p_memsz); - if (sec->vma < p->p_vaddr + p->p_memsz) + if (sec->lma < p->p_paddr + p->p_memsz) { (*_bfd_error_handler) - (_("%B: section %A vma 0x%lx overlaps previous sections"), - abfd, sec, (unsigned long) sec->vma); + (_("%B: section %A lma 0x%lx overlaps previous sections"), + abfd, sec, (unsigned long) sec->lma); adjust = 0; - } - p->p_memsz += adjust; - - if (p->p_paddr + p->p_memsz != sec->lma) - { - /* This behavior is a compromise--ld has long - silently changed the lma of sections when - lma - vma is not equal for every section in a - pheader--but only in the internal elf structures. - Silently changing the lma is probably a bug, but - changing it would have subtle and unknown - consequences for existing scripts. - - Instead modify the bfd data structure to reflect - what happened. This at least fixes the values - for the lma in the mapfile. */ sec->lma = p->p_paddr + p->p_memsz; } + p->p_memsz += adjust; if (this_hdr->sh_type != SHT_NOBITS) { @@ -4581,8 +4566,6 @@ assign_file_positions_for_load_sections (_("%B: section `%A' can't be allocated in segment %d"), abfd, sec, j); print_segment_map (m); - bfd_set_error (bfd_error_bad_value); - return FALSE; } } } Index: ld/testsuite/ld-elf/extract-symbol-1sec.d =================================================================== RCS file: /cvs/src/src/ld/testsuite/ld-elf/extract-symbol-1sec.d,v retrieving revision 1.5 diff -u -p -r1.5 extract-symbol-1sec.d --- ld/testsuite/ld-elf/extract-symbol-1sec.d 18 Nov 2009 16:37:55 -0000 1.5 +++ ld/testsuite/ld-elf/extract-symbol-1sec.d 22 Apr 2010 01:10:22 -0000 @@ -8,7 +8,7 @@ #... Sections: *Idx +Name +Size +VMA +LMA .* - *0 +\.foo +0+ +0+10000 +0+ .* + *0 +\.foo +0+ +0+10000 +0+10000 .* *CONTENTS, ALLOC, LOAD, CODE *1 +\.bar +0+ +0+20000 +0+10000 .* *ALLOC, READONLY, CODE Index: ld/testsuite/ld-i386/alloc.d =================================================================== RCS file: /cvs/src/src/ld/testsuite/ld-i386/alloc.d,v retrieving revision 1.1 diff -u -p -r1.1 alloc.d --- ld/testsuite/ld-i386/alloc.d 22 Mar 2007 15:50:38 -0000 1.1 +++ ld/testsuite/ld-i386/alloc.d 22 Apr 2010 01:33:24 -0000 @@ -1,4 +1,4 @@ #name: Invalid allocated section #as: --32 #ld: -melf_i386 -T alloc.t -#error: .*section `.foo' can't be allocated in segment 0.* +#warning: .*section `.foo' can't be allocated in segment 0.* -- Alan Modra Australia Development Lab, IBM