public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* phdrs and excluded sections
@ 2005-07-04 10:28 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2005-07-04 10:28 UTC (permalink / raw)
  To: binutils

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-07-04 10:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-04 10:28 phdrs and excluded sections Alan Modra

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).