This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: PR binutils/5233: objcopy won't change section flags on zero file-size sections
On Tue, Oct 30, 2007 at 11:55:50AM -0700, H.J. Lu wrote:
> Hi Nathan,
>
> Your patch
>
> http://sourceware.org/ml/binutils/2006-12/msg00165.html
>
> caused this regression:
>
> http://www.sourceware.org/bugzilla/show_bug.cgi?id=5233
>
> Can you take a look at it?
>
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.
H.J.
----
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.
--- ld/testsuite/ld-elf/flags1.d.flags 2007-10-30 14:27:38.000000000 -0700
+++ ld/testsuite/ld-elf/flags1.d 2007-10-30 14:37:04.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
--- ld/testsuite/ld-elf/flags1.ld.flags 2007-10-30 14:27:35.000000000 -0700
+++ ld/testsuite/ld-elf/flags1.ld 2007-10-30 14:13:25.000000000 -0700
@@ -0,0 +1,12 @@
+SECTIONS
+{
+ .text :
+ {
+ *(.text)
+ } =0
+ .post_text_reserve :
+ {
+ . += 0x160;
+ }
+ /DISCARD/ : { *(.*) }
+}
--- ld/testsuite/ld-elf/flags1.s.flags 2007-10-30 14:34:00.000000000 -0700
+++ ld/testsuite/ld-elf/flags1.s 2007-10-30 14:35:24.000000000 -0700
@@ -0,0 +1,5 @@
+ .text
+.globl start
+ .type start, @function
+start:
+ .byte 0