From f1d85785136b9335f837775031f4dba0124462db Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Wed, 21 Nov 2012 21:31:18 +0000 Subject: Set output maxpagesize when rewriting program header bfd/ PR binutils/14493 * elf.c (copy_elf_program_header): When rewriting program header, set the output maxpagesize to the maximum alignment of input PT_LOAD segments. 2012-11-21 H.J. Lu PR binutils/14493 * ld-elf/maxpage5.d: New file. * ld-elf/maxpage5.s: Likewise. * ld-elf/maxpage5.t: Likewise. --- bfd/ChangeLog | 7 +++++++ bfd/elf.c | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) (limited to 'bfd') diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 96fdcd4..ff60564 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2012-11-21 H.J. Lu + + PR binutils/14493 + * elf.c (copy_elf_program_header): When rewriting program + header, set the output maxpagesize to the maximum alignment + of input PT_LOAD segments. + 2012-11-21 Roland McGrath * elf-nacl.c (segment_nonexecutable_and_has_contents): Renamed to ... diff --git a/bfd/elf.c b/bfd/elf.c index b8bb6d3..a936636 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -6356,6 +6356,26 @@ copy_private_bfd_data (bfd *ibfd, bfd *obfd) } rewrite: + if (ibfd->xvec == obfd->xvec) + { + /* When rewriting program header, set the output maxpagesize to + the maximum alignment of input PT_LOAD segments. */ + Elf_Internal_Phdr *segment; + unsigned int i; + unsigned int num_segments = elf_elfheader (ibfd)->e_phnum; + bfd_vma maxpagesize = 0; + + for (i = 0, segment = elf_tdata (ibfd)->phdr; + i < num_segments; + i++, segment++) + if (segment->p_type == PT_LOAD + && maxpagesize < segment->p_align) + maxpagesize = segment->p_align; + + if (maxpagesize != get_elf_backend_data (obfd)->maxpagesize) + bfd_emul_set_maxpagesize (bfd_get_target (obfd), maxpagesize); + } + return rewrite_elf_program_header (ibfd, obfd); } -- cgit v1.1