This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix assign_file_positions_for_load_sections() for STRIP_NONDEBUG


On Tue, Oct 07, 2008 at 06:38:44PM +0200, Jan Blunck wrote:
> When objcopy is called with the option --only-keep-debug it might happen that
> the first section in a load segment isn't marked for loading since it is
> stripped. This doesn't mean that all section in a segment are not marked for
> loading.
[snip]

Thanks for the analysis and patch.  I'm committing this simpler version.

	* elf.c (assign_file_positions_for_load_sections): When checking
	a segment for contents, don't assume that a non-TLS nobits section
	must only be followed by nobits sections.

Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.465
diff -u -p -r1.465 elf.c
--- bfd/elf.c	3 Oct 2008 09:40:48 -0000	1.465
+++ bfd/elf.c	8 Oct 2008 07:43:51 -0000
@@ -4288,21 +4288,14 @@ assign_file_positions_for_load_sections 
 	      elf_section_type (m->sections[i]) = SHT_NOBITS;
 
 	  /* Find out whether this segment contains any loadable
-	     sections.  If the first section isn't loadable, the same
-	     holds for any other sections.  */
-	  i = 0;
-	  while (elf_section_type (m->sections[i]) == SHT_NOBITS)
-	    {
-	      /* If a segment starts with .tbss, we need to look
-		 at the next section to decide whether the segment
-		 has any loadable sections.  */
-	      if ((elf_section_flags (m->sections[i]) & SHF_TLS) == 0
-		  || ++i >= m->count)
-		{
-		  no_contents = TRUE;
-		  break;
-		}
-	    }
+	     sections.  */
+	  no_contents = TRUE;
+	  for (i = 0; i < m->count; i++)
+	    if (elf_section_type (m->sections[i]) != SHT_NOBITS)
+	      {
+		no_contents = FALSE;
+		break;
+	      }
 
 	  off_adjust = vma_page_aligned_bias (m->sections[0]->vma, off, align);
 	  off += off_adjust;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]