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: PR binutils/5233: objcopy won't change section flags on zero file-size sections


On Thu, Nov 01, 2007 at 02:14:43PM +0000, Andrew STUBBS wrote:
> H.J. Lu wrote:
> >Here is the patch for testcase. This change:
> >
> >--- elf.c.flags 2007-10-30 10:51:02.000000000 -0700
> >+++ elf.c       2007-10-30 14:10:46.000000000 -0700
> >@@ -5557,12 +5557,14 @@ rewrite_elf_program_header (bfd *ibfd, b
> >          *pointer_to_map = map;
> >          pointer_to_map = &map->next;
> > 
> >+#if 0
> >          if (matching_lma != map->p_paddr
> >              && !map->includes_filehdr && !map->includes_phdrs)
> >            /* There is some padding before the first section in the
> >               segment.  So, we must account for that in the output
> >               segment's vma.  */
> >            map->p_vaddr_offset = matching_lma - map->p_paddr;
> >+#endif
> > 
> >          free (sections);
> >          continue;
> >
> >will fix this regression.
> 
> Are there any unpleasant side-effects from removing this code?
> 

It may break strip executables generated by other tools. Since
there is no testcase, I can't verify it.

BTW, this patch will be in the next Linux binutils.


H.J.
----
bfd/

2007-10-30  H.J. Lu  <hongjiu.lu@intel.com>

	PR binutils/5233
	* elf.c (rewrite_elf_program_header): Don't adjust p_vaddr_offset.

ld/testsuite/

2007-10-30  H.J. Lu  <hongjiu.lu@intel.com>

	PR binutils/5233
	* ld-elf/flags1.d: New.
	* ld-elf/flags1.ld: Likewise.
	* ld-elf/flags1.s: Likewise.

--- binutils/bfd/elf.c.flags	2007-10-30 16:42:05.000000000 -0700
+++ binutils/bfd/elf.c	2007-10-31 05:43:35.000000000 -0700
@@ -5557,12 +5557,16 @@ rewrite_elf_program_header (bfd *ibfd, b
 	  *pointer_to_map = map;
 	  pointer_to_map = &map->next;
 
+#if 0
+	  /* FIXME: It is wrong when section flags are changed.  See
+	     PR binutils/5233.  */
 	  if (matching_lma != map->p_paddr
 	      && !map->includes_filehdr && !map->includes_phdrs)
 	    /* There is some padding before the first section in the
 	       segment.  So, we must account for that in the output
 	       segment's vma.  */
 	    map->p_vaddr_offset = matching_lma - map->p_paddr;
+#endif
 
 	  free (sections);
 	  continue;
--- binutils/ld/testsuite/ld-elf/flags1.d.flags	2007-10-30 16:42:05.000000000 -0700
+++ binutils/ld/testsuite/ld-elf/flags1.d	2007-10-30 16:42:05.000000000 -0700
@@ -0,0 +1,14 @@
+#name: --set-section-flags test 1 (sections)
+#ld: -Tflags1.ld
+#objcopy_linked_file: --set-section-flags .post_text_reserve=contents,alloc,load,readonly,code 
+#readelf: -l --wide
+
+#...
+Program Headers:
+  Type.*
+  LOAD +0x[0-9a-f]+ 0x0*0 0x0*0 0x0*0161 0x0*0161 RWE 0x[0-9a-f]+
+
+#...
+  Segment Sections...
+   00[ \t]+.text .post_text_reserve[ \t]*
+#pass
--- binutils/ld/testsuite/ld-elf/flags1.ld.flags	2007-10-30 16:42:05.000000000 -0700
+++ binutils/ld/testsuite/ld-elf/flags1.ld	2007-10-30 16:42:05.000000000 -0700
@@ -0,0 +1,12 @@
+SECTIONS
+{
+  .text :
+  {
+    *(.text)
+  } =0
+  .post_text_reserve :
+  {
+    . += 0x160;
+  }
+  /DISCARD/ : { *(.*) }
+}
--- binutils/ld/testsuite/ld-elf/flags1.s.flags	2007-10-30 16:42:05.000000000 -0700
+++ binutils/ld/testsuite/ld-elf/flags1.s	2007-10-30 16:42:05.000000000 -0700
@@ -0,0 +1,5 @@
+	.text
+.globl start
+	.type	start, @function
+start:
+	.byte 0


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