Abort if PT_GNU_RELRO segment doesn't fit in PT_LOAD segment
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 12 Jun 2012 12:55:11 +0000 (12:55 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 12 Jun 2012 12:55:11 +0000 (12:55 +0000)
bfd/

PR bfd/14207
* elf.c (assign_file_positions_for_non_load_sections): Abort if
PT_GNU_RELRO segment doesn't fit in PT_LOAD segment.

ld/testsuite/

PR ld/14207
* ld-x86-64/x86-64.exp: Run pr14207.

* ld-x86-64/pr14207.d: New file.
* ld-x86-64/pr14207.s: Likewise.

bfd/ChangeLog
bfd/elf.c
ld/testsuite/ChangeLog
ld/testsuite/ld-x86-64/pr14207.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr14207.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/x86-64.exp

index 5c5c07c1b1c0d8f3c296fcd055a7bba18c9e4c75..7386412d11bff40210f7136a99bd1a0a72835005 100644 (file)
@@ -1,3 +1,9 @@
+2012-06-12  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR bfd/14207
+       * elf.c (assign_file_positions_for_non_load_sections): Abort if
+       PT_GNU_RELRO segment doesn't fit in PT_LOAD segment.
+
 2012-06-12  Alan Modra  <amodra@gmail.com>
 
        PR ld/14207
index 6755a4e3090242a3813c8813066151e6681a0be0..0296ef567209caadbaa3049461b2d6c6342e9663 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -4931,6 +4931,11 @@ assign_file_positions_for_non_load_sections (bfd *abfd,
                      && lp->p_vaddr + lp->p_filesz >= link_info->relro_end)
                    break;
                }
+
+             /* PR ld/14207.  If the RELRO segment doesn't fit in the
+                LOAD segment, it should be removed.  */
+             if (lp == (phdrs + count))
+               abort ();
            }
          else
            {
index ba73f8c11b0d5d1f78add81a5a8cfe56ccf55b97..17583d4bb99d5c3070483abaa261cf3939fd751f 100644 (file)
@@ -1,3 +1,11 @@
+2012-06-12  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/14207
+       * ld-x86-64/x86-64.exp: Run pr14207.
+
+       * ld-x86-64/pr14207.d: New file.
+       * ld-x86-64/pr14207.s: Likewise.
+
 2012-06-11  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/14215
diff --git a/ld/testsuite/ld-x86-64/pr14207.d b/ld/testsuite/ld-x86-64/pr14207.d
new file mode 100644 (file)
index 0000000..2362e88
--- /dev/null
@@ -0,0 +1,9 @@
+#name: PR ld/14207
+#as: --64
+#ld: -melf_x86_64 -shared -z relro -z now
+#readelf: -l --wide
+
+#failif
+#...
+  NULL +.*
+#...
diff --git a/ld/testsuite/ld-x86-64/pr14207.s b/ld/testsuite/ld-x86-64/pr14207.s
new file mode 100644 (file)
index 0000000..496e67e
--- /dev/null
@@ -0,0 +1,24 @@
+       
+       .section .ctors, "aw"
+       .space 0x10, 1
+       
+       .section .dtors, "aw"
+       .space 0x10, 2
+
+       .section .jcr, "aw"
+       .space 0x8, 3
+       
+       .section .data.rel.ro
+       .p2align 4
+       .space 0x20, 3
+
+       .section .dynamic
+       .space 0xb0, 2
+
+       .section .got
+       .space 0x2a8, 4
+       
+       .bss
+       .zero 0x840
+
+
index b9af8dea93c53403a7aa4d36f2787fc0551a25bd..1eb1b1c64c8b97b22fd2b73dcde56333a08aab65 100644 (file)
@@ -209,6 +209,7 @@ run_dump_test "pr13947"
 run_dump_test "pr12570a"
 run_dump_test "pr12570b"
 run_dump_test "pr14215"
+run_dump_test "pr14207"
 
 if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} {
     return