]> git.pld-linux.org Git - packages/binutils.git/commitdiff
- added bugfixes from upstream auto/th/binutils-2.24.51.0.4-2
authorJan Rękorajski <baggins@pld-linux.org>
Sat, 3 Jan 2015 13:09:38 +0000 (14:09 +0100)
committerJan Rękorajski <baggins@pld-linux.org>
Sat, 3 Jan 2015 13:09:38 +0000 (14:09 +0100)
- rel 2

binutils.spec
pr-17422.patch [new file with mode: 0644]
pr-17440.patch [new file with mode: 0644]
pr-17447.patch [new file with mode: 0644]
pr-17467.patch [new file with mode: 0644]

index dff0711223da9c12858b728edcba8e5bce7a0ec0..0c158855f75cea5222968b5692d3501132c213a3 100644 (file)
@@ -24,7 +24,7 @@ Summary(tr.UTF-8):    GNU geliştirme araçları
 Summary(uk.UTF-8):     Набір інструментів GNU для побудови виконуваних програм
 Name:          binutils
 Version:       2.24.51.0.4
-Release:       1
+Release:       2
 Epoch:         3
 License:       GPL v3+
 Group:         Development/Tools
@@ -47,6 +47,10 @@ Patch8:              %{name}-build-id.patch
 Patch9:                %{name}-tooldir.patch
 Patch10:       %{name}-sanity-check.patch
 Patch11:       %{name}-am.patch
+Patch12:       pr-17422.patch
+Patch13:       pr-17440.patch
+Patch14:       pr-17447.patch
+Patch15:       pr-17467.patch
 URL:           http://sources.redhat.com/binutils/
 BuildRequires: autoconf >= 2.64
 BuildRequires: automake >= 1:1.11
@@ -176,6 +180,10 @@ niektórych pakietów.
 %patch9 -p1
 %patch10 -p1
 %patch11 -p1
+%patch12 -p1
+%patch13 -p1
+%patch14 -p1
+%patch15 -p1
 
 # file contains hacks for ac 2.59 only
 %{__rm} config/override.m4
diff --git a/pr-17422.patch b/pr-17422.patch
new file mode 100644 (file)
index 0000000..5025321
--- /dev/null
@@ -0,0 +1,197 @@
+From e44f5bef12a54b9c1cc24a5783dedde6f158ad15 Mon Sep 17 00:00:00 2001
+From: Markus Trippelsdorf <markus@trippelsdorf.de>
+Date: Wed, 24 Sep 2014 18:04:53 +0930
+Subject: [PATCH] BFD: Add support for more than one plugin in lib/bfd-plugins
+
+ar, nm and ranlib currently lack the ability to handle more than one
+plugin in lib/bfd-plugins. This patch reshuffles the logic in plugin.c
+to add this functionality. One can now place both llvm and gcc plugins
+in this directory and have them loaded automatically.
+Mixed gcc/llvm archives are also supported (but not very useful until
+ld.bfd and ld.gold also would load multiple plugins and use them to
+claim different object files).
+
+       PR 17422
+       * plugin.c (try_claim): New function. Moved from
+       bfd_plugin_object_p.
+       (try_load_plugin): Pass through bfd. Add test.
+       (load_plugin): Pass through bfd.
+       (bfd_plugin_object_p): Move logic to try_claim.
+---
+ bfd/ChangeLog |    9 +++++
+ bfd/plugin.c  |  106 +++++++++++++++++++++++++++++----------------------------
+ 2 files changed, 63 insertions(+), 52 deletions(-)
+
+diff --git a/bfd/ChangeLog b/bfd/ChangeLog
+index d8559ea..f70cad6 100644
+--- a/bfd/ChangeLog
++++ b/bfd/ChangeLog
+@@ -1,3 +1,12 @@
++2014-09-24  Markus Trippelsdorf  <markus@trippelsdorf.de>
++
++      PR 17422
++      * plugin.c (try_claim): New function. Moved from
++      bfd_plugin_object_p.
++      (try_load_plugin): Pass through bfd. Add test.
++      (load_plugin): Pass through bfd.
++      (bfd_plugin_object_p): Move logic to try_claim.
++
+ 2014-09-23  Sterling Augustine  <augustine.sterling@gmail.com>
+       * elf32-xtensa.c (is_resolvable_asm_expansion): for cross-section
+diff --git a/bfd/plugin.c b/bfd/plugin.c
+index c9d53c8..d336b67 100644
+--- a/bfd/plugin.c
++++ b/bfd/plugin.c
+@@ -156,9 +156,54 @@ bfd_plugin_set_program_name (const char *program_name)
+ }
+ static int
+-try_load_plugin (const char *pname)
++try_claim (bfd *abfd)
+ {
+-  static void *plugin_handle;
++  int claimed = 0;
++  struct ld_plugin_input_file file;
++  bfd *iobfd;
++
++  file.name = abfd->filename;
++
++  if (abfd->my_archive)
++    {
++      iobfd = abfd->my_archive;
++      file.offset = abfd->origin;
++      file.filesize = arelt_size (abfd);
++    }
++  else
++    {
++      iobfd = abfd;
++      file.offset = 0;
++      file.filesize = 0;
++    }
++
++  if (!iobfd->iostream && !bfd_open_file (iobfd))
++    return 0;
++
++  file.fd = fileno ((FILE *) iobfd->iostream);
++
++  if (!abfd->my_archive)
++    {
++      struct stat stat_buf;
++      if (fstat (file.fd, &stat_buf))
++        return 0;
++      file.filesize = stat_buf.st_size;
++    }
++
++  file.handle = abfd;
++  off_t cur_offset = lseek(file.fd, 0, SEEK_CUR);
++  claim_file (&file, &claimed);
++  lseek(file.fd, cur_offset, SEEK_SET);
++  if (!claimed)
++    return 0;
++
++  return 1;
++}
++
++static int
++try_load_plugin (const char *pname, bfd *abfd)
++{
++  void *plugin_handle;
+   int tv_size = 4;
+   struct ld_plugin_tv tv[tv_size];
+   int i;
+@@ -200,6 +245,9 @@ try_load_plugin (const char *pname)
+   if (!claim_file)
+     goto err;
++  if (!try_claim (abfd))
++    goto err;
++
+   return 1;
+  err:
+@@ -216,7 +264,7 @@ bfd_plugin_set_plugin (const char *p)
+ }
+ static int
+-load_plugin (void)
++load_plugin (bfd *abfd)
+ {
+   char *plugin_dir;
+   char *p;
+@@ -225,7 +273,7 @@ load_plugin (void)
+   int found = 0;
+   if (plugin_name)
+-    return try_load_plugin (plugin_name);
++    return try_load_plugin (plugin_name, abfd);
+   if (plugin_program_name == NULL)
+     return 0;
+@@ -248,7 +296,7 @@ load_plugin (void)
+       full_name = concat (p, "/", ent->d_name, NULL);
+       if (stat(full_name, &s) == 0 && S_ISREG (s.st_mode))
+-      found = try_load_plugin (full_name);
++      found = try_load_plugin (full_name, abfd);
+       free (full_name);
+       if (found)
+       break;
+@@ -266,53 +314,7 @@ load_plugin (void)
+ static const bfd_target *
+ bfd_plugin_object_p (bfd *abfd)
+ {
+-  int claimed = 0;
+-  struct ld_plugin_input_file file;
+-  bfd *iobfd;
+-  static int have_loaded = 0;
+-  static int have_plugin = 0;
+-
+-  if (!have_loaded)
+-    {
+-      have_loaded = 1;
+-      have_plugin = load_plugin ();
+-    }
+-  if (!have_plugin)
+-    return NULL;
+-
+-  file.name = abfd->filename;
+-
+-  if (abfd->my_archive)
+-    {
+-      iobfd = abfd->my_archive;
+-      file.offset = abfd->origin;
+-      file.filesize = arelt_size (abfd);
+-    }
+-  else
+-    {
+-      iobfd = abfd;
+-      file.offset = 0;
+-      file.filesize = 0;
+-    }
+-
+-  if (!iobfd->iostream && !bfd_open_file (iobfd))
+-    return NULL;
+-
+-  file.fd = fileno ((FILE *) iobfd->iostream);
+-
+-  if (!abfd->my_archive)
+-    {
+-      struct stat stat_buf;
+-      if (fstat (file.fd, &stat_buf))
+-        return NULL;
+-      file.filesize = stat_buf.st_size;
+-    }
+-
+-  file.handle = abfd;
+-  off_t cur_offset = lseek(file.fd, 0, SEEK_CUR);
+-  claim_file (&file, &claimed);
+-  lseek(file.fd, cur_offset, SEEK_SET);
+-  if (!claimed)
++  if (!load_plugin (abfd))
+     return NULL;
+   return abfd->xvec;
+-- 
+1.7.1
+
diff --git a/pr-17440.patch b/pr-17440.patch
new file mode 100644 (file)
index 0000000..5bbb77d
--- /dev/null
@@ -0,0 +1,48 @@
+From cf7363b42b2fdc9fd108bed8d53b35adf4d52ad5 Mon Sep 17 00:00:00 2001
+From: H.J. Lu <hjl.tools@gmail.com>
+Date: Mon, 29 Sep 2014 08:35:49 -0700
+Subject: [PATCH] Fix build for OLD_FREEBSD_ABI_LABEL
+
+       PR ld/17440
+       * elf32-i386.c (elf_i386_fbsd_post_process_headers): Fix build
+       for OLD_FREEBSD_ABI_LABEL.
+---
+ bfd/ChangeLog    |    6 ++++++
+ bfd/elf32-i386.c |    7 +++++--
+ 2 files changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/bfd/ChangeLog b/bfd/ChangeLog
+index f70cad6..e4445dc 100644
+--- a/bfd/ChangeLog
++++ b/bfd/ChangeLog
+@@ -1,3 +1,9 @@
++2014-09-29  H.J. Lu  <hongjiu.lu@intel.com>
++
++      PR ld/17440
++      * elf32-i386.c (elf_i386_fbsd_post_process_headers): Fix build
++      for OLD_FREEBSD_ABI_LABEL.
++
+ 2014-09-24  Markus Trippelsdorf  <markus@trippelsdorf.de>
+       PR 17422
+diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
+index a00d47c..afa21b5 100644
+--- a/bfd/elf32-i386.c
++++ b/bfd/elf32-i386.c
+@@ -5120,8 +5120,11 @@ elf_i386_fbsd_post_process_headers (bfd *abfd, struct bfd_link_info *info)
+   _bfd_elf_post_process_headers (abfd, info);
+ #ifdef OLD_FREEBSD_ABI_LABEL
+-  /* The ABI label supported by FreeBSD <= 4.0 is quite nonstandard.  */
+-  memcpy (&i_ehdrp->e_ident[EI_ABIVERSION], "FreeBSD", 8);
++  {
++    /* The ABI label supported by FreeBSD <= 4.0 is quite nonstandard.  */
++    Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd);
++    memcpy (&i_ehdrp->e_ident[EI_ABIVERSION], "FreeBSD", 8);
++  }
+ #endif
+ }
+-- 
+1.7.1
+
diff --git a/pr-17447.patch b/pr-17447.patch
new file mode 100644 (file)
index 0000000..0f1c87f
--- /dev/null
@@ -0,0 +1,334 @@
+From c2aaac080c05369f6fb7009d85dcf9bb98a914e6 Mon Sep 17 00:00:00 2001
+From: Alan Modra <amodra@gmail.com>
+Date: Sat, 4 Oct 2014 15:53:58 +0930
+Subject: [PATCH] Discard zero address range eh_frame FDEs
+
+These are useless because they can't match any address.  In fact,
+worse than useless because the .eh_frame_hdr lookup table matching
+addresses to FDEs does not contain information about the FDE range.
+The table is sorted by address;  Range is inferred by the address
+delta from one entry to the next.  So if a zero address range FDE is
+followed by a normal non-zero range FDE for the same address,
+everything is good.  However, the qsort could just as easily sort the
+FDEs in the other order, in which case the normal FDE would
+effectively be seen to have a zero range.
+
+bfd/
+       PR 17447
+       * elf-bfd.h (struct eh_cie_fde): Comment re NULL u.fde.cie_inf.
+       * elf-eh-frame.c (_bfd_elf_parse_eh_frame): Mark zero address
+       range FDEs for discarding.
+       (vma_compare): Sort on range after address.
+       (_bfd_elf_gc_mark_fdes): Test for NULL u.fde.cie_inf.
+       (_bfd_elf_discard_section_eh_frame): Likewise.  Write "FDE" in
+       error message rather than "fde".
+       (_bfd_elf_write_section_eh_frame_hdr): Write "PC" and "FDE" in
+       error message.
+ld/testsuite/
+       * ld-elf/eh1.s: Don't create FDEs with zero address ranges.
+       * ld-elf/eh3.s: Likewise.
+       * ld-elf/eh1.d, * ld-elf/eh2.d, * ld-elf/eh3.d: Adjust.
+       * ld-mips-elf/eh-frame1-n32.d: Warning match update.
+       * ld-mips-elf/eh-frame1-n64.d: Likewise.
+       * ld-mips-elf/eh-frame2-n32.d: Likewise.
+       * ld-mips-elf/eh-frame2-n64.d: Likewise.
+---
+ bfd/ChangeLog                            |   13 +++++++++++++
+ bfd/elf-bfd.h                            |    4 +++-
+ bfd/elf-eh-frame.c                       |   24 +++++++++++++++++++-----
+ ld/testsuite/ChangeLog                   |   12 +++++++++++-
+ ld/testsuite/ld-elf/eh1.d                |    6 +++---
+ ld/testsuite/ld-elf/eh1.s                |    3 +++
+ ld/testsuite/ld-elf/eh2.d                |    6 +++---
+ ld/testsuite/ld-elf/eh3.d                |    6 +++---
+ ld/testsuite/ld-elf/eh3.s                |    3 +++
+ ld/testsuite/ld-mips-elf/eh-frame1-n32.d |    2 +-
+ ld/testsuite/ld-mips-elf/eh-frame1-n64.d |    2 +-
+ ld/testsuite/ld-mips-elf/eh-frame2-n32.d |    2 +-
+ ld/testsuite/ld-mips-elf/eh-frame2-n64.d |    2 +-
+ 13 files changed, 65 insertions(+), 20 deletions(-)
+
+diff --git a/bfd/ChangeLog b/bfd/ChangeLog
+index e4445dc..dd59324 100644
+--- a/bfd/ChangeLog
++++ b/bfd/ChangeLog
+@@ -1,3 +1,16 @@
++2014-10-04  Alan Modra  <amodra@gmail.com>
++
++      PR 17447
++      * elf-bfd.h (struct eh_cie_fde): Comment re NULL u.fde.cie_inf.
++      * elf-eh-frame.c (_bfd_elf_parse_eh_frame): Mark zero address
++      range FDEs for discarding.
++      (vma_compare): Sort on range after address.
++      (_bfd_elf_gc_mark_fdes): Test for NULL u.fde.cie_inf.
++      (_bfd_elf_discard_section_eh_frame): Likewise.  Write "FDE" in
++      error message rather than "fde".
++      (_bfd_elf_write_section_eh_frame_hdr): Write "PC" and "FDE" in
++      error message.
++
+ 2014-09-29  H.J. Lu  <hongjiu.lu@intel.com>
+       PR ld/17440
+diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
+index dc343ec..b2feee3 100644
+--- a/bfd/elf-bfd.h
++++ b/bfd/elf-bfd.h
+@@ -280,7 +280,9 @@ struct eh_cie_fde
+        If REMOVED == 0, this is the CIE that we have chosen to use for
+        the output FDE.  The CIE's REMOVED field is also 0, but the CIE
+-       might belong to a different .eh_frame input section from the FDE.  */
++       might belong to a different .eh_frame input section from the FDE.
++
++       May be NULL to signify that the FDE should be discarded.  */
+       struct eh_cie_fde *cie_inf;
+       struct eh_cie_fde *next_for_section;
+     } fde;
+diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c
+index b32add3..331570a 100644
+--- a/bfd/elf-eh-frame.c
++++ b/bfd/elf-eh-frame.c
+@@ -808,6 +808,16 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info,
+         length = get_DW_EH_PE_width (cie->fde_encoding, ptr_size);
+         REQUIRE (skip_bytes (&buf, end, 2 * length));
++        SKIP_RELOCS (buf - length);
++        if (!GET_RELOC (buf - length)
++            && read_value (abfd, buf - length, length, FALSE) == 0)
++          {
++            (*info->callbacks->minfo)
++              (_("discarding zero address range FDE in %B(%A).\n"),
++               abfd, sec);
++            this_inf->u.fde.cie_inf = NULL;
++          }
++
+         /* Skip the augmentation size, if present.  */
+         if (cie->augmentation[0] == 'z')
+           REQUIRE (read_uleb128 (&buf, end, &length));
+@@ -959,7 +969,7 @@ _bfd_elf_gc_mark_fdes (struct bfd_link_info *info, asection *sec,
+       /* At this stage, all cie_inf fields point to local CIEs, so we
+        can use the same cookie to refer to them.  */
+       cie = fde->u.fde.cie_inf;
+-      if (!cie->u.cie.gc_mark)
++      if (cie != NULL && !cie->u.cie.gc_mark)
+       {
+         cie->u.cie.gc_mark = 1;
+         if (!mark_entry (info, eh_frame, cie, gc_mark_hook, cookie))
+@@ -1137,7 +1147,7 @@ _bfd_elf_discard_section_eh_frame
+       /* There should only be one zero terminator, on the last input
+        file supplying .eh_frame (crtend.o).  Remove any others.  */
+       ent->removed = sec->map_head.s != NULL;
+-    else if (!ent->cie)
++    else if (!ent->cie && ent->u.fde.cie_inf != NULL)
+       {
+       bfd_boolean keep;
+       if ((sec->flags & SEC_LINKER_CREATED) != 0 && cookie->rels == NULL)
+@@ -1170,7 +1180,7 @@ _bfd_elf_discard_section_eh_frame
+                  since it is affected by runtime relocations.  */
+               hdr_info->table = FALSE;
+               (*info->callbacks->einfo)
+-                (_("%P: fde encoding in %B(%A) prevents .eh_frame_hdr"
++                (_("%P: FDE encoding in %B(%A) prevents .eh_frame_hdr"
+                    " table being created.\n"), abfd, sec);
+             }
+           ent->removed = 0;
+@@ -1725,6 +1735,10 @@ vma_compare (const void *a, const void *b)
+     return 1;
+   if (p->initial_loc < q->initial_loc)
+     return -1;
++  if (p->range > q->range)
++    return 1;
++  if (p->range < q->range)
++    return -1;
+   return 0;
+ }
+@@ -1821,7 +1835,7 @@ _bfd_elf_write_section_eh_frame_hdr (bfd *abfd, struct bfd_link_info *info)
+                 && (hdr_info->array[i].initial_loc
+                     != sec->output_section->vma + val))
+               (*info->callbacks->einfo)
+-                (_("%X%P: .eh_frame_hdr table[%u] pc overflow.\n"), i);
++                (_("%X%P: .eh_frame_hdr table[%u] PC overflow.\n"), i);
+             bfd_put_32 (abfd, val, contents + EH_FRAME_HDR_SIZE + i * 8 + 4);
+             val = hdr_info->array[i].fde - sec->output_section->vma;
+@@ -1830,7 +1844,7 @@ _bfd_elf_write_section_eh_frame_hdr (bfd *abfd, struct bfd_link_info *info)
+                 && (hdr_info->array[i].fde
+                     != sec->output_section->vma + val))
+               (*info->callbacks->einfo)
+-                (_("%X%P: .eh_frame_hdr table[%u] fde overflow.\n"), i);
++                (_("%X%P: .eh_frame_hdr table[%u] FDE overflow.\n"), i);
+             bfd_put_32 (abfd, val, contents + EH_FRAME_HDR_SIZE + i * 8 + 8);
+             if (i != 0
+diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
+index a03dd71..fd0c8ba 100644
+--- a/ld/testsuite/ChangeLog
++++ b/ld/testsuite/ChangeLog
+@@ -1,3 +1,13 @@
++2014-10-04  Alan Modra  <amodra@gmail.com>
++
++      * ld-elf/eh1.s: Don't create FDEs with zero address ranges.
++      * ld-elf/eh3.s: Likewise.
++      * ld-elf/eh1.d, * ld-elf/eh2.d, * ld-elf/eh3.d: Adjust.
++      * ld-mips-elf/eh-frame1-n32.d: Warning match update.
++      * ld-mips-elf/eh-frame1-n64.d: Likewise.
++      * ld-mips-elf/eh-frame2-n32.d: Likewise.
++      * ld-mips-elf/eh-frame2-n64.d: Likewise.
++
+ 2014-09-22  Alan Modra  <amodra@gmail.com>
+       * ld-plugin/lto.exp: Use both --print-file-name and --print-prog-name
+@@ -534,7 +544,7 @@
+ 2014-06-09  Ryan Mansfield  <rmansfield@qnx.com>
+-        * config/default.exp (GASP): Remove.
++      * config/default.exp (GASP): Remove.
+ 2014-06-03  Alan Modra  <amodra@gmail.com>
+diff --git a/ld/testsuite/ld-elf/eh1.d b/ld/testsuite/ld-elf/eh1.d
+index bdf84cc..f6841dc 100644
+--- a/ld/testsuite/ld-elf/eh1.d
++++ b/ld/testsuite/ld-elf/eh1.d
+@@ -23,11 +23,11 @@ Contents of the .eh_frame section:
+   DW_CFA_nop
+   DW_CFA_nop
+-0+0018 0+001c 0+001c FDE cie=0+0000 pc=0+400078..0+400078
+-  DW_CFA_advance_loc: 0 to 0+400078
++0+0018 0+001c 0+001c FDE cie=0+0000 pc=0+400078\.\.0+400090
++  DW_CFA_advance_loc: 8 to 0+400080
+   DW_CFA_def_cfa_offset: 16
+   DW_CFA_offset: r6 \(rbp\) at cfa-16
+-  DW_CFA_advance_loc: 0 to 0+400078
++  DW_CFA_advance_loc: 8 to 0+400088
+   DW_CFA_def_cfa_register: r6 \(rbp\)
+ 0+0038 ZERO terminator
+diff --git a/ld/testsuite/ld-elf/eh1.s b/ld/testsuite/ld-elf/eh1.s
+index a605209..73d715f 100644
+--- a/ld/testsuite/ld-elf/eh1.s
++++ b/ld/testsuite/ld-elf/eh1.s
+@@ -3,8 +3,11 @@
+       .type   _start, %function
+ _start:
+ .LFB2:
++      .space  8
+ .LCFI0:
++      .space  8
+ .LCFI1:
++      .space  8
+ .LFE2:
+       .size   _start, .-_start
+       .section        .eh_frame,"a",%progbits
+diff --git a/ld/testsuite/ld-elf/eh2.d b/ld/testsuite/ld-elf/eh2.d
+index 65ad448..cb75a2d 100644
+--- a/ld/testsuite/ld-elf/eh2.d
++++ b/ld/testsuite/ld-elf/eh2.d
+@@ -23,11 +23,11 @@ Contents of the .eh_frame section:
+   DW_CFA_nop
+   DW_CFA_nop
+-0+0018 0+001c 0+001c FDE cie=0+0000 pc=0+400078..0+400078
+-  DW_CFA_advance_loc: 0 to 0+400078
++0+0018 0+001c 0+001c FDE cie=0+0000 pc=0+400078\.\.0+400090
++  DW_CFA_advance_loc: 8 to 0+400080
+   DW_CFA_def_cfa_offset: 16
+   DW_CFA_offset: r6 \(rbp\) at cfa-16
+-  DW_CFA_advance_loc: 0 to 0+400078
++  DW_CFA_advance_loc: 8 to 0+400088
+   DW_CFA_def_cfa_register: r6 \(rbp\)
+ 0+0038 ZERO terminator
+diff --git a/ld/testsuite/ld-elf/eh3.d b/ld/testsuite/ld-elf/eh3.d
+index 2d322dd..6ac584a 100644
+--- a/ld/testsuite/ld-elf/eh3.d
++++ b/ld/testsuite/ld-elf/eh3.d
+@@ -23,11 +23,11 @@ Contents of the .eh_frame section:
+   DW_CFA_nop
+   DW_CFA_nop
+-0+0018 0+001c 0+001c FDE cie=0+0000 pc=0+400078..0+400078
+-  DW_CFA_advance_loc: 0 to 0+400078
++0+0018 0+001c 0+001c FDE cie=0+0000 pc=0+400078\.\.0+400090
++  DW_CFA_advance_loc: 8 to 0+400080
+   DW_CFA_def_cfa_offset: 16
+   DW_CFA_offset: r6 \(rbp\) at cfa-16
+-  DW_CFA_advance_loc: 0 to 0+400078
++  DW_CFA_advance_loc: 8 to 0+400088
+   DW_CFA_def_cfa_register: r6 \(rbp\)
+ 0+0038 ZERO terminator
+diff --git a/ld/testsuite/ld-elf/eh3.s b/ld/testsuite/ld-elf/eh3.s
+index 24bd90d..e293c38 100644
+--- a/ld/testsuite/ld-elf/eh3.s
++++ b/ld/testsuite/ld-elf/eh3.s
+@@ -3,8 +3,11 @@
+       .type   _start, %function
+ _start:
+ .LFB2:
++      .space  8
+ .LCFI0:
++      .space  8
+ .LCFI1:
++      .space  8
+ .LFE2:
+       .size   _start, .-_start
+       .section        .eh_frame,"a",%progbits
+diff --git a/ld/testsuite/ld-mips-elf/eh-frame1-n32.d b/ld/testsuite/ld-mips-elf/eh-frame1-n32.d
+index 0542ebd..eafd022 100644
+--- a/ld/testsuite/ld-mips-elf/eh-frame1-n32.d
++++ b/ld/testsuite/ld-mips-elf/eh-frame1-n32.d
+@@ -4,7 +4,7 @@
+ #as: -march=from-abi -EB -n32 --defsym alignment=2 --defsym fill=0x40
+ #readelf: --relocs -wf
+ #ld: -shared -melf32btsmipn32 -Teh-frame1.ld
+-#warning: fde encoding in.*prevents \.eh_frame_hdr table being created.
++#warning: FDE encoding in.*prevents \.eh_frame_hdr table being created.
+ Relocation section '\.rel\.dyn' .*:
+  *Offset .*
+diff --git a/ld/testsuite/ld-mips-elf/eh-frame1-n64.d b/ld/testsuite/ld-mips-elf/eh-frame1-n64.d
+index 2a7aa30..cdc43bc 100644
+--- a/ld/testsuite/ld-mips-elf/eh-frame1-n64.d
++++ b/ld/testsuite/ld-mips-elf/eh-frame1-n64.d
+@@ -4,7 +4,7 @@
+ #as: -march=from-abi -EB -64 --defsym alignment=3 --defsym fill=0x40
+ #readelf: --relocs -wf
+ #ld: -shared -melf64btsmip -Teh-frame1.ld
+-#warning: fde encoding in.*prevents \.eh_frame_hdr table being created.
++#warning: FDE encoding in.*prevents \.eh_frame_hdr table being created.
+ Relocation section '\.rel\.dyn' .*:
+  *Offset .*
+diff --git a/ld/testsuite/ld-mips-elf/eh-frame2-n32.d b/ld/testsuite/ld-mips-elf/eh-frame2-n32.d
+index cda4409..528be87 100644
+--- a/ld/testsuite/ld-mips-elf/eh-frame2-n32.d
++++ b/ld/testsuite/ld-mips-elf/eh-frame2-n32.d
+@@ -4,7 +4,7 @@
+ #as: -march=from-abi -EB -n32 --defsym alignment=2 --defsym fill=0
+ #readelf: --relocs -wf
+ #ld: -shared -melf32btsmipn32 -Teh-frame1.ld
+-#warning: fde encoding in.*prevents \.eh_frame_hdr table being created.
++#warning: FDE encoding in.*prevents \.eh_frame_hdr table being created.
+ Relocation section '\.rel\.dyn' .*:
+  *Offset .*
+diff --git a/ld/testsuite/ld-mips-elf/eh-frame2-n64.d b/ld/testsuite/ld-mips-elf/eh-frame2-n64.d
+index 05ba94f..add403e 100644
+--- a/ld/testsuite/ld-mips-elf/eh-frame2-n64.d
++++ b/ld/testsuite/ld-mips-elf/eh-frame2-n64.d
+@@ -4,7 +4,7 @@
+ #as: -march=from-abi -EB -64 --defsym alignment=3 --defsym fill=0
+ #readelf: --relocs -wf
+ #ld: -shared -melf64btsmip -Teh-frame1.ld
+-#warning: fde encoding in.*prevents \.eh_frame_hdr table being created.
++#warning: FDE encoding in.*prevents \.eh_frame_hdr table being created.
+ Relocation section '\.rel\.dyn' .*:
+  *Offset .*
+-- 
+1.7.1
+
diff --git a/pr-17467.patch b/pr-17467.patch
new file mode 100644 (file)
index 0000000..ed65940
--- /dev/null
@@ -0,0 +1,188 @@
+From 5b69e3572d1ee8e8e6e1991fd07f87a96c48746d Mon Sep 17 00:00:00 2001
+From: Alan Modra <amodra@gmail.com>
+Date: Mon, 13 Oct 2014 15:18:21 +1030
+Subject: [PATCH] Run eh_frame optimisation for relocatable link
+
+The idea here is to drop .eh_frame FDEs corresponding to dropped
+comdat group sections or linkonce sections, but not perform changes in
+encoding.
+
+bfd/
+       PR 17467
+       * elf-eh-frame.c (ENSURE_NO_RELOCS): Don't stop at first NONE reloc.
+       (_bfd_elf_parse_eh_frame): When relocatable output, don't set
+       flags enabling conversion of CIEs and FDEs to use relative encoding.
+       (find_merged_cie): Similarly.
+       (_bfd_elf_write_section_eh_frame): Don't edit FDEs when
+       relocatable, except for CIE pointer.
+       * elflink.c (bfd_elf_reloc_symbol_deleted_p): Return true for
+       relocs against symbols in dropped comdat group sections.
+       (bfd_elf_discard_info): Do some eh_frame optimisation when
+       relocatable.
+ld/
+       * ldlang.c (lang_add_section): Set up map_head.s and map_tail.s when
+       relocatable.
+---
+ bfd/ChangeLog      |   14 ++++++++++++++
+ bfd/elf-eh-frame.c |   25 +++++++++++++++++--------
+ bfd/elflink.c      |   14 +++++++-------
+ ld/ChangeLog       |    5 +++++
+ ld/ldlang.c        |    3 +--
+ 5 files changed, 44 insertions(+), 17 deletions(-)
+
+diff --git a/bfd/ChangeLog b/bfd/ChangeLog
+index aa2f3ef..be3ae38 100644
+--- a/bfd/ChangeLog
++++ b/bfd/ChangeLog
+@@ -1,3 +1,17 @@
++2014-10-13  Alan Modra  <amodra@gmail.com>
++
++      PR 17467
++      * elf-eh-frame.c (ENSURE_NO_RELOCS): Don't stop at first NONE reloc.
++      (_bfd_elf_parse_eh_frame): When relocatable output, don't set
++      flags enabling conversion of CIEs and FDEs to use relative encoding.
++      (find_merged_cie): Similarly.
++      (_bfd_elf_write_section_eh_frame): Don't edit FDEs when
++      relocatable, except for CIE pointer.
++      * elflink.c (bfd_elf_reloc_symbol_deleted_p): Return true for
++      relocs against symbols in dropped comdat group sections.
++      (bfd_elf_discard_info): Do some eh_frame optimisation when
++      relocatable.
++
+ 2014-10-04  Alan Modra  <amodra@gmail.com>
+       PR 17447
+diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c
+index 331570a..e481f34 100644
+--- a/bfd/elf-eh-frame.c
++++ b/bfd/elf-eh-frame.c
+@@ -556,10 +556,13 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info,
+   /* FIXME: octets_per_byte.  */
+ #define ENSURE_NO_RELOCS(buf)                         \
+-  REQUIRE (!(cookie->rel < cookie->relend             \
+-           && (cookie->rel->r_offset                  \
+-               < (bfd_size_type) ((buf) - ehbuf))     \
+-           && cookie->rel->r_info != 0))
++  while (cookie->rel < cookie->relend                 \
++       && (cookie->rel->r_offset                      \
++           < (bfd_size_type) ((buf) - ehbuf)))        \
++    {                                                 \
++      REQUIRE (cookie->rel->r_info == 0);             \
++      cookie->rel++;                                  \
++    }
+   /* FIXME: octets_per_byte.  */
+ #define SKIP_RELOCS(buf)                              \
+@@ -726,6 +729,7 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info,
+         /* For shared libraries, try to get rid of as many RELATIVE relocs
+            as possible.  */
+         if (info->shared
++            && !info->relocatable
+             && (get_elf_backend_data (abfd)
+                 ->elf_backend_can_make_relative_eh_frame
+                 (abfd, info, sec)))
+@@ -763,10 +767,12 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info,
+         ENSURE_NO_RELOCS (buf);
+         if (!info->relocatable)
+-          /* Keep info for merging cies.  */
+-          this_inf->u.cie.u.full_cie = cie;
+-        this_inf->u.cie.per_encoding_relative
+-          = (cie->per_encoding & 0x70) == DW_EH_PE_pcrel;
++          {
++            /* Keep info for merging cies.  */
++            this_inf->u.cie.u.full_cie = cie;
++            this_inf->u.cie.per_encoding_relative
++              = (cie->per_encoding & 0x70) == DW_EH_PE_pcrel;
++          }
+       }
+       else
+       {
+@@ -1071,6 +1077,7 @@ find_merged_cie (bfd *abfd, struct bfd_link_info *info, asection *sec,
+       if (per_binds_local
+         && info->shared
++        && !info->relocatable
+         && (cie->per_encoding & 0x70) == DW_EH_PE_absptr
+         && (get_elf_backend_data (abfd)
+             ->elf_backend_can_make_relative_eh_frame (abfd, info, sec)))
+@@ -1577,6 +1584,8 @@ _bfd_elf_write_section_eh_frame (bfd *abfd,
+         value = ((ent->new_offset + sec->output_offset + 4)
+                  - (cie->new_offset + cie->u.cie.u.sec->output_offset));
+         bfd_put_32 (abfd, value, buf);
++        if (info->relocatable)
++          continue;
+         buf += 4;
+         width = get_DW_EH_PE_width (ent->fde_encoding, ptr_size);
+         value = read_value (abfd, buf, width,
+diff --git a/bfd/elflink.c b/bfd/elflink.c
+index d33efe0..c8068c0 100644
+--- a/bfd/elflink.c
++++ b/bfd/elflink.c
+@@ -12602,10 +12602,10 @@ bfd_elf_reloc_symbol_deleted_p (bfd_vma offset, void *cookie)
+         if ((h->root.type == bfd_link_hash_defined
+              || h->root.type == bfd_link_hash_defweak)
+-            && discarded_section (h->root.u.def.section))
++            && (h->root.u.def.section->owner != rcookie->abfd
++                || h->root.u.def.section->kept_section != NULL
++                || discarded_section (h->root.u.def.section)))
+           return TRUE;
+-        else
+-          return FALSE;
+       }
+       else
+       {
+@@ -12618,7 +12618,9 @@ bfd_elf_reloc_symbol_deleted_p (bfd_vma offset, void *cookie)
+         /* Need to: get the symbol; get the section.  */
+         isym = &rcookie->locsyms[r_symndx];
+         isec = bfd_section_from_elf_index (rcookie->abfd, isym->st_shndx);
+-        if (isec != NULL && discarded_section (isec))
++        if (isec != NULL
++            && (isec->kept_section != NULL
++                || discarded_section (isec)))
+           return TRUE;
+       }
+       return FALSE;
+@@ -12672,9 +12674,7 @@ bfd_elf_discard_info (bfd *output_bfd, struct bfd_link_info *info)
+       }
+     }
+-  o = NULL;
+-  if (!info->relocatable)
+-    o = bfd_get_section_by_name (output_bfd, ".eh_frame");
++  o = bfd_get_section_by_name (output_bfd, ".eh_frame");
+   if (o != NULL)
+     {
+       asection *i;
+diff --git a/ld/ChangeLog b/ld/ChangeLog
+index ca27cc2..effacb0 100644
+--- a/ld/ChangeLog
++++ b/ld/ChangeLog
+@@ -1,3 +1,8 @@
++2014-10-13  Alan Modra  <amodra@gmail.com>
++
++      * ldlang.c (lang_add_section): Set up map_head.s and map_tail.s when
++      relocatable.
++
+ 2014-09-16  Kuan-Lin Chen  <kuanlinchentw@gmail.com>
+       * emultempl/nds32elf.em (nds32_elf_after_open): Do not keep
+diff --git a/ld/ldlang.c b/ld/ldlang.c
+index 899f710..5960e5c 100644
+--- a/ld/ldlang.c
++++ b/ld/ldlang.c
+@@ -2411,8 +2411,7 @@ lang_add_section (lang_statement_list_type *ptr,
+   section->output_section = output->bfd_section;
+-  if (!link_info.relocatable
+-      && !map_head_is_link_order)
++  if (!map_head_is_link_order)
+     {
+       asection *s = output->bfd_section->map_tail.s;
+       output->bfd_section->map_tail.s = section;
+-- 
+1.7.1
+
This page took 0.244681 seconds and 4 git commands to generate.