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]

Fix relro strip test for MIPS


There are two unique things about MIPS which conspire to fail the
ld -z relro -shared tests (which test that objcopy and strip do not
change the binary).  One is that .dynamic is writable and there is no
.got.plt section, so a typical shared library has no PT_GNU_RELRO;
it gets added and then converted to PT_NULL.  The other is that it
adds a second PT_NULL program header for prelinker support.
These combine to produce an input file with two PT_NULL segments.
There's a FIXME in copy_elf_program_header above some code which
seems clearly wrong for this case.

Deleting that turns up a second problem.  The input file to strip
has a PT_NULL segment with alignment of zero (I believe this is the
aborted PT_GNU_RELRO segment, but it might have been the MIPS-specific
one; I'm not completely sure).  We were overriding its input alignment
and I don't see any reason to do so.

With this patch two more tests pass on mips-linux.  Unless someone
sees a problem with them, I will apply them in a few days.

-- 
Daniel Jacobowitz
CodeSourcery

2007-09-19  Daniel Jacobowitz  <dan@codesourcery.com>

	* elf.c (assign_file_positions_for_load_sections): Trust
	p_align_valid.
	(copy_elf_program_header): Copy PT_NULL segments.

Index: elf.c
===================================================================
--- elf.c	(revision 181978)
+++ elf.c	(working copy)
@@ -4108,10 +4108,10 @@ assign_file_positions_for_load_sections 
 
 	  p->p_align = maxpagesize;
 	}
-      else if (m->count == 0)
-	p->p_align = 1 << bed->s->log_file_align;
       else if (m->p_align_valid)
 	p->p_align = m->p_align;
+      else if (m->count == 0)
+	p->p_align = 1 << bed->s->log_file_align;
       else
 	p->p_align = 0;
 
@@ -5590,10 +5590,6 @@ copy_elf_program_header (bfd *ibfd, bfd 
       asection *first_section = NULL;
       asection *lowest_section = NULL;
 
-      /* FIXME: Do we need to copy PT_NULL segment?  */
-      if (segment->p_type == PT_NULL)
-	continue;
-
       /* Compute how many sections are in this segment.  */
       for (section = ibfd->sections, section_count = 0;
 	   section != NULL;


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