From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22997 invoked by alias); 24 Apr 2003 15:28:23 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 22990 invoked from network); 24 Apr 2003 15:28:22 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 24 Apr 2003 15:28:22 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id h3OFSMD25701 for ; Thu, 24 Apr 2003 11:28:22 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h3OFSMq03521; Thu, 24 Apr 2003 11:28:22 -0400 Received: from localhost.localdomain.redhat.com (vpn50-2.rdu.redhat.com [172.16.50.2]) by pobox.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h3OFSIk32560; Thu, 24 Apr 2003 11:28:20 -0400 To: David Heine Cc: binutils@sources.redhat.com Subject: Re: Bad behavior with explicit phdrs and loadable orphans References: <3EA5B717.8010904@tensilica.com> From: Nick Clifton In-Reply-To: <3EA5B717.8010904@tensilica.com> User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.2 Date: Thu, 24 Apr 2003 15:28:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-04/txt/msg00490.txt.bz2 Hi David, > When explicit PHDRs and memory regions are used with orphan input > sections, the default placement of these sections can generate either > very large files or a SEEK overflow. Note - your problem could also be overcome by fixing the linker script to provide a better definition for the memory regions. For example in your script if you change: > MEMORY > { > normal_seg : ORIGIN = 0xd0000000, LENGTH = 0x10000 > } To: MEMORY { normal_seg (wax) : ORIGIN = 0xd0000000, LENGTH = 0x10000 } The link will work. But anyway, this is only a workaround, not a full solution. An alternative is the patch below will also work. It "fixes" lang_memory_default() so that if a memory region does not have any flags set, then it will accept any input section. This seems to be a better interpretation of how a memory region without attributes is supposed to behave. > This behavior seems a little extreme for misnaming a loadable > section, but I'm not sure what a good solution would be. The ld > orphan placement algorithm seems to be looking for a good place to > put the section in the emulation statements. Perhaps it just needs > to look for a good memory region while placing an orphan as well. > Alternatively, when explicit PHDRS are used, the linker could do a > better job of placing the default memory section so that it was > reasonably contiguous with an existing PHDR. Or perhaps orphan > loadable sections should generate an error when using explicit PHDRs > before the attempt is made to build a multi-gigabyte file. I think that the linker ought to try to be a little bit better about choosing memory regions for orphan sections. Ideally it ought to attempt to discover if the section it has chosen to inherit the orphan has a memory region associated with it, and if so, use that region. (Assuming that there is room of course). Let me know what you think Cheers Nick 2003-04-24 Nick Clifton * ldlang.c (lang_memory_default): If a region has not attributes do not check for matching section flags. * ld.texinfo: Document that a region without attributes will accept any input section. Index: ld/ldlang.c =================================================================== RCS file: /cvs/src/src/ld/ldlang.c,v retrieving revision 1.111 diff -c -3 -p -w -r1.111 ldlang.c *** ld/ldlang.c 31 Mar 2003 18:12:52 -0000 1.111 --- ld/ldlang.c 24 Apr 2003 14:08:39 -0000 *************** lang_memory_default (section) *** 736,746 **** p != (lang_memory_region_type *) NULL; p = p->next) { ! if ((p->flags & sec_flags) != 0 ! && (p->not_flags & sec_flags) == 0) ! { return p; - } } return lang_memory_region_lookup ("*default*"); } --- 736,746 ---- p != (lang_memory_region_type *) NULL; p = p->next) { ! /* Only check for a positive match if the region has attributes set. */ ! if (p->flags && ((p->flags & sec_flags) == 0)) ! continue; ! if ((p->not_flags & sec_flags) == 0) return p; } return lang_memory_region_lookup ("*default*"); } Index: ld/ld.texinfo =================================================================== RCS file: /cvs/src/src/ld/ld.texinfo,v retrieving revision 1.93 diff -c -3 -p -w -r1.93 ld.texinfo *** ld/ld.texinfo 15 Apr 2003 08:51:54 -0000 1.93 --- ld/ld.texinfo 24 Apr 2003 14:08:56 -0000 *************** If a unmapped section matches any of the *** 3563,3569 **** @samp{!}, it will be placed in the memory region. The @samp{!} attribute reverses this test, so that an unmapped section will be placed in the memory region only if it does not match any of the listed ! attributes. @kindex ORIGIN = @kindex o = --- 3563,3570 ---- @samp{!}, it will be placed in the memory region. The @samp{!} attribute reverses this test, so that an unmapped section will be placed in the memory region only if it does not match any of the listed ! attributes. If not attributes are specified then the region will ! accept any input section. @kindex ORIGIN = @kindex o =