This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] program header instability
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: Nathan Sidwell <nathan at codesourcery dot com>, binutils at sources dot redhat dot com
- Date: Thu, 11 Jan 2007 12:25:15 +0000
- Subject: Re: [PATCH] program header instability
- References: <45880944.5070704@codesourcery.com> <20061223134346.GB4484@bubble.grove.modra.org> <4592A68C.2010004@codesourcery.com> <20070101102826.GD4484@bubble.grove.modra.org>
Alan Modra wrote:
On Wed, Dec 27, 2006 at 04:59:56PM +0000, Nathan Sidwell wrote:
* bfd/elf.c (assign_file_positions_for_load_sections): We can
require fewer phdrs than expected.
* ld/emultempl/elf-generic.em (gdl_map_segments): Only allow header
shrinkage for the first few iterations.
OK.
* ld/testsuite/ld-elf/header.d: New.
* ld/testsuite/ld-elf/header.t: New.
* ld/testsuite/ld-elf/header.s: New.
This fails on 64-bit targets. I'll preapprove any necessary tweaks to
make the test pass on at least powerpc64-linux and x86_64-linux.
corrected thusly and tested with powerpc64-linux cross tools
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.369
diff -c -3 -p -r1.369 elf.c
*** bfd/elf.c 19 Dec 2006 08:49:38 -0000 1.369
--- bfd/elf.c 11 Jan 2007 12:19:56 -0000
*************** assign_file_positions_for_load_sections
*** 4275,4281 ****
elf_tdata (abfd)->program_header_size = alloc * bed->s->sizeof_phdr;
else
BFD_ASSERT (elf_tdata (abfd)->program_header_size
! == alloc * bed->s->sizeof_phdr);
if (alloc == 0)
{
--- 4275,4281 ----
elf_tdata (abfd)->program_header_size = alloc * bed->s->sizeof_phdr;
else
BFD_ASSERT (elf_tdata (abfd)->program_header_size
! >= alloc * bed->s->sizeof_phdr);
if (alloc == 0)
{
Index: ld/emultempl/elf-generic.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf-generic.em,v
retrieving revision 1.3
diff -c -3 -p -r1.3 elf-generic.em
*** ld/emultempl/elf-generic.em 26 Jul 2006 12:27:12 -0000 1.3
--- ld/emultempl/elf-generic.em 11 Jan 2007 12:20:02 -0000
*************** gld${EMULATION_NAME}_map_segments (bfd_b
*** 60,66 ****
einfo ("%F%P: map sections to segments failed: %E\n");
if (phdr_size != elf_tdata (output_bfd)->program_header_size)
! need_layout = TRUE;
}
}
while (need_layout && --tries);
--- 60,76 ----
einfo ("%F%P: map sections to segments failed: %E\n");
if (phdr_size != elf_tdata (output_bfd)->program_header_size)
! {
! if (tries > 6)
! /* The first few times we allow any change to
! phdr_size . */
! need_layout = TRUE;
! else if (phdr_size < elf_tdata (output_bfd)->program_header_size)
! /* After that we only allow the size to grow. */
! need_layout = TRUE;
! else
! elf_tdata (output_bfd)->program_header_size = phdr_size;
! }
}
}
while (need_layout && --tries);
Index: ld/testsuite/ld-elf/header.d
===================================================================
RCS file: ld/testsuite/ld-elf/header.d
diff -N ld/testsuite/ld-elf/header.d
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- ld/testsuite/ld-elf/header.d 11 Jan 2007 12:20:03 -0000
***************
*** 0 ****
--- 1,12 ----
+ # ld: -T header.t -z max-page-size=0x10000
+ # objdump: -hpw
+
+ #...
+ Program Header:
+ LOAD off 0x0*0000000 vaddr 0x0*0010000 paddr 0x0*0010000 align 2..16
+ filesz 0x0*001002[48] memsz 0x0*001002[48] flags rwx
+
+ Sections:
+ Idx Name Size VMA *LMA *File off Algn Flags
+ 0 .text 0*000ffac 0*001007[48] 0*001007[48] 0*000007[48] 2... CONTENTS, ALLOC, LOAD, READONLY, CODE
+ 1 .data 0*0000004 0*002002[04] 0*002002[04] 0*001002[04] 2... CONTENTS, ALLOC, LOAD, DATA
Index: ld/testsuite/ld-elf/header.s
===================================================================
RCS file: ld/testsuite/ld-elf/header.s
diff -N ld/testsuite/ld-elf/header.s
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- ld/testsuite/ld-elf/header.s 11 Jan 2007 12:20:03 -0000
***************
*** 0 ****
--- 1,8 ----
+ .text
+ .globl main
+ main:
+ .rept 0x4000 - 0x15
+ .long 0xfedcba98
+ .endr
+ .data
+ .long 0x76543210
Index: ld/testsuite/ld-elf/header.t
===================================================================
RCS file: ld/testsuite/ld-elf/header.t
diff -N ld/testsuite/ld-elf/header.t
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- ld/testsuite/ld-elf/header.t 11 Jan 2007 12:20:03 -0000
***************
*** 0 ****
--- 1,8 ----
+ ENTRY(main)
+
+ SECTIONS
+ {
+ . = 0x10000 + SIZEOF_HEADERS;
+ .text : { *(.text) }
+ .data : { *(.data) }
+ }