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: PR bfd/14207 changes vs *-*-nacl* targets


On Tue, Jul 03, 2012 at 10:43:57AM +0930, Alan Modra wrote:
> My guess is that you'll find the problem is due to SIZEOF_HEADERS
> padding inserted by the nacl linker scripts at the start of rodata
> sections.  That sort of gap is a new thing for the relro segment
> calculations.  The pr14207 changes didn't really change anything for
> your target, except of course the addition of the abort.

Well it wasn't so much the spacing but the fact that the headers sit
at the start of rodata.  Fixed as follows.

	PR ld/14207
	* elf.c (assign_file_positions_for_load_sections): Remove assertions
	that only PT_LOAD headers include file header and section headers.
	(assign_file_positions_for_non_load_sections): Similarly don't
	assert PT_GNU_RELRO header does not include file and section headers.
	Compare first section vma rather than PT_LOAD p_vaddr against
	relro_start when looking for PT_LOAD covering PT_GNU_RELRO.  Replace
	abort with assertion.

Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.564
diff -u -p -r1.564 elf.c
--- bfd/elf.c	1 Jul 2012 08:23:13 -0000	1.564
+++ bfd/elf.c	3 Jul 2012 05:09:39 -0000
@@ -4575,8 +4575,6 @@ assign_file_positions_for_load_sections 
 	  p->p_memsz = bed->s->sizeof_ehdr;
 	  if (m->count > 0)
 	    {
-	      BFD_ASSERT (p->p_type == PT_LOAD);
-
 	      if (p->p_vaddr < (bfd_vma) off)
 		{
 		  (*_bfd_error_handler)
@@ -4603,7 +4601,6 @@ assign_file_positions_for_load_sections 
 
 	      if (m->count > 0)
 		{
-		  BFD_ASSERT (p->p_type == PT_LOAD);
 		  p->p_vaddr -= off - p->p_offset;
 		  if (!m->p_paddr_valid)
 		    p->p_paddr -= off - p->p_offset;
@@ -4965,26 +4962,27 @@ assign_file_positions_for_non_load_secti
       if (p->p_type == PT_GNU_RELRO)
 	{
 	  const Elf_Internal_Phdr *lp;
-
-	  BFD_ASSERT (!m->includes_filehdr && !m->includes_phdrs);
+	  struct elf_segment_map *lm;
 
 	  if (link_info != NULL)
 	    {
 	      /* During linking the range of the RELRO segment is passed
 		 in link_info.  */
-	      for (lp = phdrs; lp < phdrs + count; ++lp)
+	      for (lm = elf_tdata (abfd)->segment_map, lp = phdrs;
+		   lm != NULL;
+		   lm = lm->next, lp++)
 		{
 		  if (lp->p_type == PT_LOAD
-		      && lp->p_vaddr >= link_info->relro_start
 		      && lp->p_vaddr < link_info->relro_end
-		      && lp->p_vaddr + lp->p_filesz >= link_info->relro_end)
+		      && lp->p_vaddr + lp->p_filesz >= link_info->relro_end
+		      && lm->count != 0
+		      && lm->sections[0]->vma >= link_info->relro_start)
 		    break;
 		}
 
 	      /* PR ld/14207.  If the RELRO segment doesn't fit in the
 		 LOAD segment, it should be removed.  */
-	      if (lp == (phdrs + count))
-		abort ();
+	      BFD_ASSERT (lm != NULL);
 	    }
 	  else
 	    {

-- 
Alan Modra
Australia Development Lab, IBM


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