diff options
-rw-r--r-- | bfd/ChangeLog | 7 | ||||
-rw-r--r-- | bfd/elf.c | 20 | ||||
-rw-r--r-- | ld/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/maxpage5.d | 18 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/maxpage5.s | 8 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/maxpage5.t | 15 |
6 files changed, 75 insertions, 0 deletions
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 <hongjiu.lu@intel.com> + + 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 <mcgrathr@google.com> * elf-nacl.c (segment_nonexecutable_and_has_contents): Renamed to ... @@ -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); } diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index bebb04e..72d8445 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2012-11-21 H.J. Lu <hongjiu.lu@intel.com> + + PR binutils/14493 + * ld-elf/maxpage5.d: New file. + * ld-elf/maxpage5.s: Likewise. + * ld-elf/maxpage5.t: Likewise. + 2012-11-21 Roland McGrath <mcgrathr@google.com> * ld-elf/comm-data.exp: Add XFAIL for arm*-*-* targets, referring diff --git a/ld/testsuite/ld-elf/maxpage5.d b/ld/testsuite/ld-elf/maxpage5.d new file mode 100644 index 0000000..bcbd39c --- /dev/null +++ b/ld/testsuite/ld-elf/maxpage5.d @@ -0,0 +1,18 @@ +#source: maxpage5.s +#as: --32 +#ld: -z max-page-size=0x200000 -T maxpage5.t +#objcopy_linked_file: -R .foo +#readelf: -l --wide +#target: x86_64-*-linux* i?86-*-linux-gnu + +#... +Program Headers: + Type.* + LOAD +0x[0-9a-f]+ .*0x200000 + NOTE +0x[0-9a-f]+ .* + +#... + Segment Sections... + 00[ \t]+.text * + 01[ \t]+.note * +#pass diff --git a/ld/testsuite/ld-elf/maxpage5.s b/ld/testsuite/ld-elf/maxpage5.s new file mode 100644 index 0000000..93d6b36 --- /dev/null +++ b/ld/testsuite/ld-elf/maxpage5.s @@ -0,0 +1,8 @@ + .globl _entry + .text +_entry: + .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + .section .foo,"awx",%progbits + .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + .section .note,"",%note + .byte 0 diff --git a/ld/testsuite/ld-elf/maxpage5.t b/ld/testsuite/ld-elf/maxpage5.t new file mode 100644 index 0000000..7f19343 --- /dev/null +++ b/ld/testsuite/ld-elf/maxpage5.t @@ -0,0 +1,15 @@ +OUTPUT_FORMAT("elf32-i386") +OUTPUT_ARCH(i386) +ENTRY(_entry) +PHDRS +{ + data PT_LOAD; + note PT_NOTE; +} +SECTIONS +{ + .text : { *(.text) } :data + .foo : { *(.foo) } :data + .note : { *(.note) } :note + /DISCARD/ : { *(*) } +} |