Always create PLT eh_frame section for i386/x86-64
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 22 May 2012 14:05:21 +0000 (14:05 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 22 May 2012 14:05:21 +0000 (14:05 +0000)
bfd/

2012-05-22  H.J. Lu  <hongjiu.lu@intel.com>

PR ld/14105
* elf32-i386.c (elf_i386_create_dynamic_sections): Always
create PLT eh_frame section with SEC_LINKER_CREATED.
* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Likewise.

ld/testsuite/

2012-05-20  H.J. Lu  <hongjiu.lu@intel.com>

PR ld/14105
* ld-elf/eh4.d: Add PLT eh_frame.

* ld-i386/i386.exp: Run pr12570a and pr12570b.
* ld-x86-64/x86-64.exp: Likewise.

* ld-i386/pr12570a.d: New file.
* ld-i386/pr12570a.s: Likewise.
* ld-i386/pr12570b.s: Likewise.
* ld-i386/pr12570b.s: Likewise.
* ld-x86-64/pr12570a.d: Likewise.
* ld-x86-64/pr12570a.s: Likewise.
* ld-x86-64/pr12570b.d: Likewise.
* ld-x86-64/pr12570b.s: Likewise.

15 files changed:
bfd/ChangeLog
bfd/elf32-i386.c
bfd/elf64-x86-64.c
ld/testsuite/ChangeLog
ld/testsuite/ld-elf/eh4.d
ld/testsuite/ld-i386/i386.exp
ld/testsuite/ld-i386/pr12570a.d [new file with mode: 0644]
ld/testsuite/ld-i386/pr12570a.s [new file with mode: 0644]
ld/testsuite/ld-i386/pr12570b.d [new file with mode: 0644]
ld/testsuite/ld-i386/pr12570b.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr12570a.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr12570a.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr12570b.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr12570b.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/x86-64.exp

index 270b83a73dd5d9915ddd20c7c8a4d1ea9feff621..cfdcaa36916b331ef368df446e6af2675551b1e9 100644 (file)
@@ -1,3 +1,10 @@
+2012-05-22  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/14105
+       * elf32-i386.c (elf_i386_create_dynamic_sections): Always
+       create PLT eh_frame section with SEC_LINKER_CREATED.
+       * elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Likewise.
+
 2012-05-22  Alan Modra  <amodra@gmail.com>
 
        * elflink.c (bfd_elf_discard_info): Handle multiple .eh_frame
index dd49486533063f2396be2dbbdb0ec33ed144a4db..84299ceb9e925a9d0ca0a70a6cccf32a3101dffd 100644 (file)
@@ -1015,13 +1015,15 @@ elf_i386_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info)
     return FALSE;
 
   if (!info->no_ld_generated_unwind_info
-      && bfd_get_section_by_name (dynobj, ".eh_frame") == NULL
+      && htab->plt_eh_frame == NULL
       && htab->elf.splt != NULL)
     {
       flagword flags = get_elf_backend_data (dynobj)->dynamic_sec_flags;
       htab->plt_eh_frame
-       = bfd_make_section_with_flags (dynobj, ".eh_frame",
-                                      flags | SEC_READONLY);
+       = bfd_make_section_anyway_with_flags (dynobj, ".eh_frame",
+                                             (flags
+                                              | SEC_LINKER_CREATED
+                                              | SEC_READONLY));
       if (htab->plt_eh_frame == NULL
          || !bfd_set_section_alignment (dynobj, htab->plt_eh_frame, 2))
        return FALSE;
index 335356024757e033f92a21c1a564de133204ae47..1f490d41cb71c982a7a59b4a8dc1e467e483057e 100644 (file)
@@ -979,15 +979,17 @@ elf_x86_64_create_dynamic_sections (bfd *dynobj,
     abort ();
 
   if (!info->no_ld_generated_unwind_info
-      && bfd_get_section_by_name (dynobj, ".eh_frame") == NULL
+      && htab->plt_eh_frame == NULL
       && htab->elf.splt != NULL)
     {
       const struct elf_x86_64_backend_data *const abed
        = get_elf_x86_64_backend_data (dynobj);
       flagword flags = get_elf_backend_data (dynobj)->dynamic_sec_flags;
       htab->plt_eh_frame
-       = bfd_make_section_with_flags (dynobj, ".eh_frame",
-                                      flags | SEC_READONLY);
+       = bfd_make_section_anyway_with_flags (dynobj, ".eh_frame",
+                                             (flags
+                                              | SEC_LINKER_CREATED
+                                              | SEC_READONLY));
       if (htab->plt_eh_frame == NULL
          || !bfd_set_section_alignment (dynobj, htab->plt_eh_frame, 3))
        return FALSE;
index 12366505363d3be45352193c6f8ec567f4895622..e0d072f579a65fcd2a52225a0cb9676d876a966c 100644 (file)
@@ -1,3 +1,20 @@
+2012-05-20  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/14105
+       * ld-elf/eh4.d: Add PLT eh_frame.
+
+       * ld-i386/i386.exp: Run pr12570a and pr12570b.
+       * ld-x86-64/x86-64.exp: Likewise.
+
+       * ld-i386/pr12570a.d: New file.
+       * ld-i386/pr12570a.s: Likewise.
+       * ld-i386/pr12570b.s: Likewise.
+       * ld-i386/pr12570b.s: Likewise.
+       * ld-x86-64/pr12570a.d: Likewise.
+       * ld-x86-64/pr12570a.s: Likewise.
+       * ld-x86-64/pr12570b.d: Likewise.
+       * ld-x86-64/pr12570b.s: Likewise.
+
 2012-05-19  Alan Modra  <amodra@gmail.com>
 
        * ld-elf/elf.exp (note-3.so): xfail tic6x due to non-pic warnings.
index b482d038fd1a098ecd69a2a2ef997c708a630bac..34ce70e41fee5e15b56306dfda7a6a87ef3443e3 100644 (file)
@@ -29,6 +29,17 @@ Contents of the .eh_frame section:
   DW_CFA_set_loc: 00000417
   DW_CFA_def_cfa_offset: 80
 
-00000048 ZERO terminator
+00000048 00000024 0000004c FDE cie=00000000 pc=00000240..00000260
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_advance_loc: 6 to 00000246
+  DW_CFA_def_cfa_offset: 24
+  DW_CFA_advance_loc: 10 to 00000250
+  DW_CFA_def_cfa_expression \(DW_OP_breg7 \(rsp\): 8; DW_OP_breg16 \(rip\): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit11; DW_OP_ge; DW_OP_lit3; DW_OP_shl; DW_OP_plus\)
+  DW_CFA_nop
+  DW_CFA_nop
+  DW_CFA_nop
+  DW_CFA_nop
+
+00000070 ZERO terminator
 #pass
 
index d1031c5a83aca1d692bab7b8a8bd6056304c0c61..47f918fa187fafcbffe5508a36b971474c1623d2 100644 (file)
@@ -231,6 +231,8 @@ run_dump_test "nogot2"
 run_dump_test "discarded1"
 run_dump_test "pr12718"
 run_dump_test "pr12921"
+run_dump_test "pr12570a"
+run_dump_test "pr12570b"
 
 if { !([istarget "i?86-*-linux*"]
        || [istarget "i?86-*-gnu*"]
diff --git a/ld/testsuite/ld-i386/pr12570a.d b/ld/testsuite/ld-i386/pr12570a.d
new file mode 100644 (file)
index 0000000..03aeb7b
--- /dev/null
@@ -0,0 +1,8 @@
+#name: PR ld/12570
+#as: --32
+#ld: -melf_i386 -shared
+#readelf: -wf --wide
+
+#...
+  DW_CFA_def_cfa_expression \(DW_OP_breg4 \(esp\): 4; DW_OP_breg8 \(eip\): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit11; DW_OP_ge; DW_OP_lit2; DW_OP_shl; DW_OP_plus\)
+#...
diff --git a/ld/testsuite/ld-i386/pr12570a.s b/ld/testsuite/ld-i386/pr12570a.s
new file mode 100644 (file)
index 0000000..38e0593
--- /dev/null
@@ -0,0 +1,8 @@
+       .text
+       .globl foo
+       .type foo, @function
+foo:
+       .cfi_startproc
+       jmp      bar@PLT
+       .cfi_endproc
+       .size   foo, .-foo
diff --git a/ld/testsuite/ld-i386/pr12570b.d b/ld/testsuite/ld-i386/pr12570b.d
new file mode 100644 (file)
index 0000000..0532aac
--- /dev/null
@@ -0,0 +1,9 @@
+#name: PR ld/12570
+#as: --32
+#ld: -melf_i386 -shared
+#readelf: -wf --wide
+
+#failif
+#...
+  DW_CFA_def_cfa_expression \(DW_OP_breg4 \(esp\): 4; DW_OP_breg8 \(eip\): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit11; DW_OP_ge; DW_OP_lit2; DW_OP_shl; DW_OP_plus\)
+#...
diff --git a/ld/testsuite/ld-i386/pr12570b.s b/ld/testsuite/ld-i386/pr12570b.s
new file mode 100644 (file)
index 0000000..e76b9f1
--- /dev/null
@@ -0,0 +1,8 @@
+       .text
+       .globl foo
+       .type foo, @function
+foo:
+       .cfi_startproc
+       ret
+       .cfi_endproc
+       .size   foo, .-foo
diff --git a/ld/testsuite/ld-x86-64/pr12570a.d b/ld/testsuite/ld-x86-64/pr12570a.d
new file mode 100644 (file)
index 0000000..6105a74
--- /dev/null
@@ -0,0 +1,8 @@
+#name: PR ld/12570
+#as: --64
+#ld: -melf_x86_64 -shared
+#readelf: -wf --wide
+
+#...
+  DW_CFA_def_cfa_expression \(DW_OP_breg7 \(rsp\): 8; DW_OP_breg16 \(rip\): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit11; DW_OP_ge; DW_OP_lit3; DW_OP_shl; DW_OP_plus\)
+#...
diff --git a/ld/testsuite/ld-x86-64/pr12570a.s b/ld/testsuite/ld-x86-64/pr12570a.s
new file mode 100644 (file)
index 0000000..38e0593
--- /dev/null
@@ -0,0 +1,8 @@
+       .text
+       .globl foo
+       .type foo, @function
+foo:
+       .cfi_startproc
+       jmp      bar@PLT
+       .cfi_endproc
+       .size   foo, .-foo
diff --git a/ld/testsuite/ld-x86-64/pr12570b.d b/ld/testsuite/ld-x86-64/pr12570b.d
new file mode 100644 (file)
index 0000000..d65f8da
--- /dev/null
@@ -0,0 +1,9 @@
+#name: PR ld/12570
+#as: --64
+#ld: -melf_x86_64 -shared
+#readelf: -wf --wide
+
+#failif
+#...
+  DW_CFA_def_cfa_expression \(DW_OP_breg7 \(rsp\): 8; DW_OP_breg16 \(rip\): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit11; DW_OP_ge; DW_OP_lit3; DW_OP_shl; DW_OP_plus\)
+#...
diff --git a/ld/testsuite/ld-x86-64/pr12570b.s b/ld/testsuite/ld-x86-64/pr12570b.s
new file mode 100644 (file)
index 0000000..e76b9f1
--- /dev/null
@@ -0,0 +1,8 @@
+       .text
+       .globl foo
+       .type foo, @function
+foo:
+       .cfi_startproc
+       ret
+       .cfi_endproc
+       .size   foo, .-foo
index e8afbc291f427c56e97db832682a43fde5f1ec24..7d2934f9b5213a53f0b8c11d33056e36430ae54e 100644 (file)
@@ -206,6 +206,8 @@ run_dump_test "discarded1"
 run_dump_test "pr12718"
 run_dump_test "pr12921"
 run_dump_test "pr13947"
+run_dump_test "pr12570a"
+run_dump_test "pr12570b"
 
 if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} {
     return