From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4312 invoked by alias); 4 Jul 2005 10:28:24 -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 4113 invoked by uid 22791); 4 Jul 2005 10:28:02 -0000 Received: from omta02sl.mx.bigpond.com (HELO omta02sl.mx.bigpond.com) (144.140.93.154) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Mon, 04 Jul 2005 10:28:02 +0000 Received: from grove.modra.org ([144.136.167.90]) by omta02sl.mx.bigpond.com with ESMTP id <20050704102751.ZMUG20351.omta02sl.mx.bigpond.com@grove.modra.org> for ; Mon, 4 Jul 2005 10:27:51 +0000 Received: by bubble.grove.modra.org (Postfix, from userid 500) id A39801902FB; Mon, 4 Jul 2005 19:57:50 +0930 (CST) Date: Mon, 04 Jul 2005 10:28:00 -0000 From: Alan Modra To: binutils@sources.redhat.com Subject: phdrs and excluded sections Message-ID: <20050704102750.GE5308@bubble.grove.modra.org> Mail-Followup-To: binutils@sources.redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i X-SW-Source: 2005-07/txt/msg00036.txt.bz2 When using PHDRS in a linker script, the assignment of sections to segments happens before output sections are stripped. This can result in linker errors that aren't really warranted. PR 1042 * elf.c (assign_file_positions_for_segments): Remove excluded sections from the segment map. Index: bfd/elf.c =================================================================== RCS file: /cvs/src/src/bfd/elf.c,v retrieving revision 1.304 diff -u -p -r1.304 elf.c --- bfd/elf.c 4 Jul 2005 01:53:38 -0000 1.304 +++ bfd/elf.c 4 Jul 2005 09:57:12 -0000 @@ -4044,7 +4044,8 @@ assign_file_positions_for_segments (bfd { /* The placement algorithm assumes that non allocated sections are not in PT_LOAD segments. We ensure this here by removing such - sections from the segment map. */ + sections from the segment map. We also remove excluded + sections. */ for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) @@ -4052,13 +4053,12 @@ assign_file_positions_for_segments (bfd unsigned int new_count; unsigned int i; - if (m->p_type != PT_LOAD) - continue; - new_count = 0; for (i = 0; i < m->count; i ++) { - if ((m->sections[i]->flags & SEC_ALLOC) != 0) + if ((m->sections[i]->flags & SEC_EXCLUDE) == 0 + && ((m->sections[i]->flags & SEC_ALLOC) != 0 + || m->p_type != PT_LOAD)) { if (i != new_count) m->sections[new_count] = m->sections[i]; -- Alan Modra IBM OzLabs - Linux Technology Centre