]> git.ipfire.org Git - people/ms/ipfire-3.x.git/commitdiff
binutils: Update to 2.24
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 16 Sep 2014 14:38:20 +0000 (16:38 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 16 Sep 2014 14:38:20 +0000 (16:38 +0200)
24 files changed:
binutils/binutils.nm
binutils/patches/binutils-2.22.52.0.1-relro-on-by-default.patch [deleted file]
binutils/patches/binutils-2.23.2-aarch64-em.patch0 [new file with mode: 0644]
binutils/patches/binutils-2.23.2-kernel-ld-r.patch0 [new file with mode: 0644]
binutils/patches/binutils-2.23.52.0.1-addr2line-dynsymtab.patch0 [new file with mode: 0644]
binutils/patches/binutils-2.23.52.0.1-as-doc-texinfo-fixes.patch0 [deleted file]
binutils/patches/binutils-2.24-DW_FORM_ref_addr.patch0 [new file with mode: 0644]
binutils/patches/binutils-2.24-aarch64-fix-final_link_relocate.patch [new file with mode: 0644]
binutils/patches/binutils-2.24-aarch64-fix-gotplt-offset-ifunc.patch [new file with mode: 0644]
binutils/patches/binutils-2.24-aarch64-fix-ie-relax.patch [new file with mode: 0644]
binutils/patches/binutils-2.24-aarch64-fix-static-ifunc.patch [new file with mode: 0644]
binutils/patches/binutils-2.24-aarch64-ld-shared-non-PIC-xfail.patch [new file with mode: 0644]
binutils/patches/binutils-2.24-arm-static-tls.patch [new file with mode: 0644]
binutils/patches/binutils-2.24-elfnn-aarch64.patch0 [new file with mode: 0644]
binutils/patches/binutils-2.24-fake-zlib-sections.patch0 [new file with mode: 0644]
binutils/patches/binutils-2.24-fat-lto-objects.patch [new file with mode: 0644]
binutils/patches/binutils-2.24-indirect-chain.patch0 [new file with mode: 0644]
binutils/patches/binutils-2.24-ldforcele.patch0 [new file with mode: 0644]
binutils/patches/binutils-2.24-pt-pax-flags-20131231.patch [moved from binutils/patches/binutils-2.23.52.0.1-pt-pax-flags-20130326.patch with 81% similarity]
binutils/patches/binutils-2.24-set-section-macros.patch0 [new file with mode: 0644]
binutils/patches/binutils-2.24-symbol-warning.patch [new file with mode: 0644]
binutils/patches/binutils-2.24-use-relro.patch [new file with mode: 0644]
binutils/patches/binutils-2.24-weak-sym-merge.patch0 [new file with mode: 0644]
binutils/patches/binutils-HEAD-change-ld-notice-interface.patch [new file with mode: 0644]

index ecde05136055be2f77c694a32e17b0740275eb5f..451e434d12e78bcd9015f6eec4323a7242aea686 100644 (file)
@@ -4,7 +4,7 @@
 ###############################################################################
 
 name       = binutils
-version    = 2.23.52.0.1
+version    = 2.24
 release    = 1
 
 maintainer = Michael Tremer <michael.tremer@ipfire.org>
@@ -30,6 +30,7 @@ build
                flex
                gcc-c++
                pakfire-builder >= 0.9.23-5
+               perl
                texinfo
                zlib-devel
        end
@@ -37,12 +38,24 @@ build
        prepare_cmds
                mkdir -pv %{DIR_SRC}/binutils-build
 
+               # On aarch64 we might use 64KiB pages
+               sed -i -e '/#define.*ELF_COMMONPAGESIZE/s/0x1000$/0x10000/' bfd/elf*aarch64.c
+
                # Suppress the installation of an outdated standards.info file as a newer
                # one is installed later on in the Autoconf instructions:
                rm -fv etc/standards.info
                sed -e '/^INFO/s/standards.info //' -i etc/Makefile.in
 
+               perl -pi -e 's/i\[3-7\]86/i[34567]86/g' */conf*
                sed -i -e 's/%''{release}/%{release}/g' bfd/Makefile{.am,.in}
+               sed -i -e '/^libopcodes_la_\(DEPENDENCIES\|LIBADD\)/s,$, ../bfd/libbfd.la,' opcodes/Makefile.{am,in}
+
+               # Build libbfd.so and libopcodes.so with -Bsymbolic-functions if possible.
+               if gcc %{CFLAGS} -v --help 2>&1 | grep -q -- -Bsymbolic-functions; then
+                       sed -i -e 's/^libbfd_la_LDFLAGS = /&-Wl,-Bsymbolic-functions /' bfd/Makefile.{am,in}
+                       sed -i -e 's/^libopcodes_la_LDFLAGS = /&-Wl,-Bsymbolic-functions /' opcodes/Makefile.{am,in}
+               fi
+               touch */configure
        end
 
        configure_options += \
diff --git a/binutils/patches/binutils-2.22.52.0.1-relro-on-by-default.patch b/binutils/patches/binutils-2.22.52.0.1-relro-on-by-default.patch
deleted file mode 100644 (file)
index 65a6c97..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-diff -Nur binutils-2.22.52.0.4-vanilla/ld/emultempl/armelf.em binutils-2.22.52.0.4/ld/emultempl/armelf.em
---- binutils-2.22.52.0.4-vanilla/ld/emultempl/armelf.em        2012-06-05 18:44:10.000000000 +0200
-+++ binutils-2.22.52.0.4/ld/emultempl/armelf.em        2012-06-08 13:34:30.578427241 +0200
-@@ -52,6 +52,7 @@
-   input_flags.dynamic = ${DYNAMIC_LINK-TRUE};
-   config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
-   config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
-+  link_info.relro = TRUE;
- }
- static void
-diff -Nur binutils-2.22.52.0.4-vanilla/ld/emultempl/elf32.em binutils-2.22.52.0.4/ld/emultempl/elf32.em
---- binutils-2.22.52.0.4-vanilla/ld/emultempl/elf32.em 2012-06-05 18:44:10.000000000 +0200
-+++ binutils-2.22.52.0.4/ld/emultempl/elf32.em 2012-06-08 13:33:07.090612102 +0200
-@@ -106,6 +106,7 @@
-   input_flags.dynamic = ${DYNAMIC_LINK-TRUE};
-   config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
-   link_info.sharable_sections = `if test "$SHARABLE_SECTIONS" = "yes" ; then echo TRUE ; else echo FALSE ; fi`;
-+  link_info.relro = TRUE;
- }
- EOF
-diff -Nur binutils-2.22.52.0.4-vanilla/ld/testsuite/config/default.exp binutils-2.22.52.0.4/ld/testsuite/config/default.exp
---- binutils-2.22.52.0.4-vanilla/ld/testsuite/config/default.exp       2012-06-05 18:44:10.000000000 +0200
-+++ binutils-2.22.52.0.4/ld/testsuite/config/default.exp       2012-06-08 13:33:07.085612052 +0200
-@@ -23,7 +23,7 @@
- #
- if ![info exists ld] then {
--    set ld [findfile $base_dir/ld-new $base_dir/ld-new [transform ld]]
-+    set ld "[findfile $base_dir/ld-new $base_dir/ld-new [transform ld]] -znorelro"
- }
- if ![info exists as] then {
-@@ -69,7 +69,7 @@
-     catch "exec ln -s ../../ld-new tmpdir/ld/ld" status
-     catch "exec ln -s ld tmpdir/ld/collect-ld" status
- }
--set gcc_ld_flag "-B[pwd]/tmpdir/ld/"
-+set gcc_ld_flag "-B[pwd]/tmpdir/ld/ -Wl,-z,norelro"
- # load the linker path
- if {[file exists tmpdir/libpath.exp]} {
-@@ -279,7 +279,7 @@
- }
- if ![info exists LD] then {
--    set LD [findfile $base_dir/ld-new ./ld-new [transform ld]]
-+    set LD "[findfile $base_dir/ld-new ./ld-new [transform ld]] -znorelro"
- }
- if ![info exists LDFLAGS] then {
-diff -Nur binutils-2.22.52.0.4-vanilla/ld/testsuite/ld-bootstrap/bootstrap.exp binutils-2.22.52.0.4/ld/testsuite/ld-bootstrap/bootstrap.exp
---- binutils-2.22.52.0.4-vanilla/ld/testsuite/ld-bootstrap/bootstrap.exp       2012-06-05 18:44:10.000000000 +0200
-+++ binutils-2.22.52.0.4/ld/testsuite/ld-bootstrap/bootstrap.exp       2012-06-08 13:33:07.086612062 +0200
-@@ -71,7 +71,13 @@
-     # This test can only be run if we have the ld build directory,
-     # since we need the object files.
--    if {$ld != "$objdir/ld-new"} {
-+    set ldexe $ld
-+    set ldparm [string first " " $ld]
-+    if { $ldparm > 0 } then {
-+      set ldparm [expr $ldparm - 1]
-+      set ldexe [string range $ld 0 $ldparm]
-+    }
-+    if {$ldexe != "$objdir/ld-new"} {
-       untested $testname
-       continue
-     }
diff --git a/binutils/patches/binutils-2.23.2-aarch64-em.patch0 b/binutils/patches/binutils-2.23.2-aarch64-em.patch0
new file mode 100644 (file)
index 0000000..f4aae4c
--- /dev/null
@@ -0,0 +1,47 @@
+*** ../binutils-2.23.2.orig/ld/emultempl/aarch64elf.em 2013-06-05 09:46:17.499278813 +0100
+--- ld/emultempl/aarch64elf.em 2013-06-05 09:54:36.981292659 +0100
+*************** gld${EMULATION_NAME}_after_allocation (v
+*** 264,270 ****
+  }
+  
+  static void
+! gld${EMULATION_NAME}_finish (void)
+  {
+    if (! link_info.relocatable)
+      {
+--- 264,270 ----
+  }
+  
+  static void
+! gld${EMULATION_NAME}_local_finish (void)
+  {
+    if (! link_info.relocatable)
+      {
+*************** gld${EMULATION_NAME}_finish (void)
+*** 276,282 ****
+       }
+      }
+  
+!   finish_default ();
+  }
+  
+  /* This is a convenient point to tell BFD about target specific flags.
+--- 276,282 ----
+       }
+      }
+  
+!   gld${EMULATION_NAME}_finish ();
+  }
+  
+  /* This is a convenient point to tell BFD about target specific flags.
+*************** LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=
+*** 413,416 ****
+  LDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME}"_before_parse
+  
+  # Call the extra arm-elf function
+! LDEMUL_FINISH=gld${EMULATION_NAME}_finish
+--- 413,416 ----
+  LDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME}"_before_parse
+  
+  # Call the extra arm-elf function
+! LDEMUL_FINISH=gld${EMULATION_NAME}_local_finish
diff --git a/binutils/patches/binutils-2.23.2-kernel-ld-r.patch0 b/binutils/patches/binutils-2.23.2-kernel-ld-r.patch0
new file mode 100644 (file)
index 0000000..2ba70c5
--- /dev/null
@@ -0,0 +1,2734 @@
+diff -cpr ../binutils-2.23.2.orig/bfd/bfd.c bfd/bfd.c
+*** ../binutils-2.23.2.orig/bfd/bfd.c  2013-05-14 16:39:24.681717759 +0100
+--- bfd/bfd.c  2013-05-14 16:40:06.988718932 +0100
+*************** CODE_FRAGMENT
+*** 43,48 ****
+--- 43,56 ----
+  .    both_direction = 3
+  .  };
+  .
++ .enum bfd_lto_object_type
++ .  {
++ .    lto_non_object,
++ .    lto_non_ir_object,
++ .    lto_ir_object,
++ .    lto_mixed_object
++ .  };
++ .
+  .struct bfd
+  .{
+  .  {* A unique identifier of the BFD  *}
+*************** CODE_FRAGMENT
+*** 190,195 ****
+--- 198,206 ----
+  .  {* The last section on the section list.  *}
+  .  struct bfd_section *section_last;
+  .
++ .  {* The object-only section on the section list.  *}
++ .  struct bfd_section *object_only_section;
++ .
+  .  {* The number of sections.  *}
+  .  unsigned int section_count;
+  .
+*************** CODE_FRAGMENT
+*** 308,313 ****
+--- 319,327 ----
+  .  {* Set if only required symbols should be added in the link hash table for
+  .     this object.  Used by VMS linkers.  *}
+  .  unsigned int selective_search : 1;
++ .
++ .  {* LTO object type.  *}
++ .  unsigned int lto_type : 2;
+  .};
+  .
+  */
+*************** bfd_demangle (bfd *abfd, const char *nam
+*** 2026,2028 ****
+--- 2040,2075 ----
+  
+    return res;
+  }
++ 
++ /*
++ FUNCTION
++      bfd_group_signature
++ 
++ SYNOPSIS
++      asymbol *bfd_group_signature (asection *group, asymbol **isympp);
++ 
++ DESCRIPTION
++      Return a pointer to the symbol used as a signature for GROUP.
++ */
++ 
++ asymbol *
++ bfd_group_signature (asection *group, asymbol **isympp)
++ {
++   bfd *abfd = group->owner;
++   Elf_Internal_Shdr *ghdr;
++ 
++   if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
++     return NULL;
++ 
++   ghdr = &elf_section_data (group)->this_hdr;
++   if (ghdr->sh_link < elf_numsections (abfd))
++     {
++       const struct elf_backend_data *bed = get_elf_backend_data (abfd);
++       Elf_Internal_Shdr *symhdr = elf_elfsections (abfd) [ghdr->sh_link];
++ 
++       if (symhdr->sh_type == SHT_SYMTAB
++        && ghdr->sh_info < symhdr->sh_size / bed->s->sizeof_sym)
++      return isympp[ghdr->sh_info - 1];
++     }
++   return NULL;
++ }
+diff -cpr ../binutils-2.23.2.orig/bfd/bfd-in2.h bfd/bfd-in2.h
+*** ../binutils-2.23.2.orig/bfd/bfd-in2.h      2013-05-14 16:39:24.640717758 +0100
+--- bfd/bfd-in2.h      2013-05-14 16:42:03.217722154 +0100
+*************** struct bfd_section *bfd_create_gnu_debug
+*** 1050,1055 ****
+--- 1050,1058 ----
+  bfd_boolean bfd_fill_in_gnu_debuglink_section
+     (bfd *abfd, struct bfd_section *sect, const char *filename);
+  
++ const char *bfd_extract_object_only_section
++    (bfd *abfd);
++ 
+  /* Extracted from libbfd.c.  */
+  
+  /* Byte swapping macros for user section data.  */
+*************** extern asection std_section[4];
+*** 1594,1599 ****
+--- 1597,1605 ----
+    || ((SEC) == bfd_com_section_ptr)            \
+    || ((SEC) == bfd_ind_section_ptr))
+  
++ /* GNU object-only section name.  */
++ #define GNU_OBJECT_ONLY_SECTION_NAME ".gnu_object_only"
++ 
+  /* Macros to handle insertion and deletion of a bfd's sections.  These
+     only handle the list pointers, ie. do not adjust section_count,
+     target_index etc.  */
+*************** enum bfd_direction
+*** 5681,5686 ****
+--- 5687,5700 ----
+      both_direction = 3
+    };
+  
++ enum bfd_lto_object_type
++   {
++     lto_non_object,
++     lto_non_ir_object,
++     lto_ir_object,
++     lto_mixed_object
++   };
++ 
+  struct bfd
+  {
+    /* A unique identifier of the BFD  */
+*************** struct bfd
+*** 5828,5833 ****
+--- 5842,5850 ----
+    /* The last section on the section list.  */
+    struct bfd_section *section_last;
+  
++   /* The object-only section on the section list.  */
++   struct bfd_section *object_only_section;
++ 
+    /* The number of sections.  */
+    unsigned int section_count;
+  
+*************** struct bfd
+*** 5946,5951 ****
+--- 5963,5971 ----
+    /* Set if only required symbols should be added in the link hash table for
+       this object.  Used by VMS linkers.  */
+    unsigned int selective_search : 1;
++ 
++   /* LTO object type.  */
++   unsigned int lto_type : 2;
+  };
+  
+  typedef enum bfd_error
+*************** void bfd_emul_set_commonpagesize (const
+*** 6167,6172 ****
+--- 6187,6194 ----
+  
+  char *bfd_demangle (bfd *, const char *, int);
+  
++ asymbol *bfd_group_signature (asection *group, asymbol **isympp);
++ 
+  /* Extracted from archive.c.  */
+  symindex bfd_get_next_mapent
+     (bfd *abfd, symindex previous, carsym **sym);
+diff -cpr ../binutils-2.23.2.orig/bfd/elf.c bfd/elf.c
+*** ../binutils-2.23.2.orig/bfd/elf.c  2013-05-14 16:39:25.317717777 +0100
+--- bfd/elf.c  2013-05-14 16:40:06.993718932 +0100
+*************** static const struct bfd_elf_special_sect
+*** 2092,2097 ****
+--- 2092,2098 ----
+    { STRING_COMMA_LEN (".gnu.linkonce.b"), -2, SHT_NOBITS,      SHF_ALLOC + SHF_WRITE },
+    { STRING_COMMA_LEN (".gnu.lto_"),       -1, SHT_PROGBITS,    SHF_EXCLUDE },
+    { STRING_COMMA_LEN (".got"),             0, SHT_PROGBITS,    SHF_ALLOC + SHF_WRITE },
++   { STRING_COMMA_LEN (".gnu_object_only"), 0, SHT_GNU_OBJECT_ONLY, SHF_EXCLUDE },
+    { STRING_COMMA_LEN (".gnu.version"),     0, SHT_GNU_versym,  0 },
+    { STRING_COMMA_LEN (".gnu.version_d"),   0, SHT_GNU_verdef,  0 },
+    { STRING_COMMA_LEN (".gnu.version_r"),   0, SHT_GNU_verneed, 0 },
+diff -cpr ../binutils-2.23.2.orig/bfd/elflink.c bfd/elflink.c
+*** ../binutils-2.23.2.orig/bfd/elflink.c      2013-05-14 16:39:25.280717776 +0100
+--- bfd/elflink.c      2013-05-14 16:40:06.997718932 +0100
+*************** elf_link_add_archive_symbols (bfd *abfd,
+*** 5127,5132 ****
+--- 5127,5135 ----
+            something wrong with the archive.  */
+         if (element->archive_pass != 0)
+           {
++            /* Don't load the IR archive member twice.  */
++            if (element->lto_type == lto_ir_object)
++              continue;
+             bfd_set_error (bfd_error_bad_value);
+             goto error_return;
+           }
+diff -cpr ../binutils-2.23.2.orig/bfd/format.c bfd/format.c
+*** ../binutils-2.23.2.orig/bfd/format.c       2013-05-14 16:39:24.265717748 +0100
+--- bfd/format.c       2013-05-14 16:40:07.006718933 +0100
+*************** bfd_check_format (bfd *abfd, bfd_format
+*** 95,100 ****
+--- 95,127 ----
+    return bfd_check_format_matches (abfd, format, NULL);
+  }
+  
++ /* Set lto_type in ABFD.  */
++ 
++ static void
++ bfd_set_lto_type (bfd *abfd)
++ {
++   if (abfd->format == bfd_object
++       && abfd->lto_type == lto_non_object
++       && (abfd->flags & (DYNAMIC | EXEC_P)) == 0)
++     {
++       asection *sec;
++       enum bfd_lto_object_type type = lto_non_ir_object;
++       for (sec = abfd->sections; sec != NULL; sec = sec->next)
++      {
++        if (strcmp (sec->name, GNU_OBJECT_ONLY_SECTION_NAME) == 0)
++          {
++            type = lto_mixed_object;
++            abfd->object_only_section = sec;
++            break;
++          }
++        else if (type != lto_ir_object
++                 && strncmp (sec->name, ".gnu.lto_", 9) == 0)
++          type = lto_ir_object;
++      }
++       abfd->lto_type = type;
++     }
++ }
++ 
+  struct bfd_preserve
+  {
+    void *marker;
+*************** bfd_check_format_matches (bfd *abfd, bfd
+*** 136,142 ****
+      }
+  
+    if (abfd->format != bfd_unknown)
+!     return abfd->format == format;
+  
+    if (matching != NULL || *bfd_associated_vector != NULL)
+      {
+--- 163,172 ----
+      }
+  
+    if (abfd->format != bfd_unknown)
+!     {
+!       bfd_set_lto_type (abfd);
+!       return abfd->format == format;
+!     }
+  
+    if (matching != NULL || *bfd_associated_vector != NULL)
+      {
+*************** bfd_check_format_matches (bfd *abfd, bfd
+*** 322,327 ****
+--- 352,360 ----
+  
+        if (matching_vector)
+       free (matching_vector);
++ 
++       bfd_set_lto_type (abfd);
++ 
+  
+        /* File position has moved, BTW.  */
+        return TRUE;
+diff -cpr ../binutils-2.23.2.orig/bfd/opncls.c bfd/opncls.c
+*** ../binutils-2.23.2.orig/bfd/opncls.c       2013-05-14 16:39:23.701717732 +0100
+--- bfd/opncls.c       2013-05-14 16:40:07.008718933 +0100
+*************** bfd_fill_in_gnu_debuglink_section (bfd *
+*** 1569,1571 ****
+--- 1569,1637 ----
+  
+    return TRUE;
+  }
++ 
++ /*
++ FUNCTION
++      bfd_extract_object_only_section
++ 
++ SYNOPSIS
++      const char *bfd_extract_object_only_section
++        (bfd *abfd);
++ 
++ DESCRIPTION
++ 
++      Takes a @var{ABFD} and extract the .gnu_object_only section into
++      a temporary file.
++ 
++ RETURNS
++      The name of the temporary file is returned if all is ok.
++      Otherwise <<NULL>> is returned and bfd_error is set.
++ */
++ 
++ const char *
++ bfd_extract_object_only_section (bfd *abfd)
++ {
++   asection *sec = abfd->object_only_section;
++   const char *name;
++   FILE *file;
++   bfd_byte *memhunk = NULL;
++   size_t off, size;
++   bfd_error_type err;
++ 
++   /* Get a temporary object-only file.  */
++   name = make_temp_file (".obj-only.o");
++ 
++   /* Open the object-only file.  */
++   file = real_fopen (name, FOPEN_WB);
++   if (!bfd_get_full_section_contents (abfd, sec, &memhunk))
++     {
++       err = bfd_get_error ();
++ 
++ loser:
++       free (memhunk);
++       fclose (file);
++       unlink (name);
++       bfd_set_error (err);
++       return NULL;
++     }
++ 
++   off = 0;
++   size = sec->size;
++   while (off != size)
++     {
++       size_t written, nwrite = size - off;
++ 
++       written = fwrite (memhunk + off, 1, nwrite, file);
++       if (written < nwrite && ferror (file))
++      {
++        err = bfd_error_system_call;
++        goto loser;
++      }
++ 
++       off += written;
++     }
++ 
++   free (memhunk);
++   fclose (file);
++   return name;
++ }
+diff -cpr ../binutils-2.23.2.orig/bfd/plugin.c bfd/plugin.c
+*** ../binutils-2.23.2.orig/bfd/plugin.c       2013-05-14 16:39:25.137717772 +0100
+--- bfd/plugin.c       2013-05-14 16:40:07.010718933 +0100
+*************** register_claim_file (ld_plugin_claim_fil
+*** 130,135 ****
+--- 130,268 ----
+    return LDPS_OK;
+  }
+  
++ static asection bfd_plugin_fake_text_section
++   = BFD_FAKE_SECTION (bfd_plugin_fake_text_section, 0, 0, ".text", 0);
++ static asection bfd_plugin_fake_common_section
++   = BFD_FAKE_SECTION (bfd_plugin_fake_common_section, SEC_IS_COMMON, 0,
++                    NULL, 0);
++ 
++ /* Get symbols from object only section.  */
++ 
++ static void
++ bfd_plugin_get_symbols_in_object_only (bfd *abfd)
++ {
++   struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data;
++   const char *object_only_file;
++   bfd *nbfd;
++   long storage;
++   long object_only_nsyms, added_nsyms, i;
++   asymbol **object_only_syms, **added_syms;
++ 
++   plugin_data->object_only_syms = NULL;
++   plugin_data->object_only_nsyms = 0;
++ 
++   if (abfd->sections == NULL && abfd->my_archive == NULL)
++     {
++       nbfd = bfd_openr (abfd->filename, NULL);
++       if (nbfd == NULL || !bfd_check_format (nbfd, bfd_object))
++      {
++        (*_bfd_error_handler)
++          (_("%s: failed to open to extract object only section: %s"),
++           abfd->filename, bfd_errmsg (bfd_get_error ()));
++        bfd_close (nbfd);
++        return;
++      }
++     }
++   else
++     {
++       if (!bfd_check_format (abfd, bfd_object))
++      {
++        (*_bfd_error_handler)
++          (_("%B: invalid file to extract object only section: %s"),
++           abfd, bfd_errmsg (bfd_get_error ()));
++        return;
++      }
++       nbfd = abfd;
++     }
++ 
++   if (nbfd->lto_type == lto_mixed_object
++       && (nbfd->flags & HAS_SYMS) != 0)
++     {
++       object_only_file = bfd_extract_object_only_section (nbfd);
++       if (object_only_file == NULL)
++      (*_bfd_error_handler)
++        (_("%B: failed to extract object only section: %s"),
++         abfd, bfd_errmsg (bfd_get_error ()));
++     }
++   else
++     object_only_file = NULL;
++ 
++   /* Close the new bfd we just opened.  */
++   if (nbfd != abfd)
++     bfd_close (nbfd);
++ 
++   /* Return if there is no object only section or there is no
++      symbol in object only section.  */
++   if (!object_only_file)
++     return;
++ 
++   /* Open the file containing object only section.  */
++   nbfd = bfd_openr (object_only_file, NULL);
++   if (!bfd_check_format (nbfd, bfd_object))
++     {
++       (*_bfd_error_handler)
++      (_("%B: failed to open object only section: %s"),
++       abfd, bfd_errmsg (bfd_get_error ()));
++       goto quit;
++     }
++ 
++   storage = bfd_get_symtab_upper_bound (nbfd);
++   if (storage <= 0)
++     {
++       if (storage < 0)
++      (*_bfd_error_handler)
++        (_("%B: failed to get symbol table in object only section: %s"),
++         abfd, bfd_errmsg (bfd_get_error ()));
++ 
++       goto quit;
++     }
++ 
++   object_only_syms = (asymbol **) bfd_malloc (storage);
++   object_only_nsyms = bfd_canonicalize_symtab (nbfd, object_only_syms);
++ 
++   /* FIXME: We waste some spaces if not all symbols are copied.  */
++   added_syms = (asymbol **) bfd_alloc (abfd, storage);
++   added_nsyms = 0;
++ 
++   /* Copy only global symbols from object only section.  */
++   for (i = 0; i < object_only_nsyms; i++)
++     {
++       asection *sec = object_only_syms[i]->section;
++       flagword flags = object_only_syms[i]->flags;
++       asymbol *s;
++ 
++       if (bfd_is_com_section (sec))
++      sec = &bfd_plugin_fake_common_section;
++       else if (bfd_is_und_section (sec))
++      ;
++       else if ((flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0)
++      sec = &bfd_plugin_fake_text_section;
++       else
++      continue;
++ 
++       s = bfd_alloc (abfd, sizeof (asymbol)); 
++       BFD_ASSERT (s);
++       added_syms[added_nsyms++] = s;
++ 
++       s->section = sec;
++       s->the_bfd = abfd;
++       s->name = xstrdup (object_only_syms[i]->name);
++       s->value = 0;
++       s->flags = flags;
++       s->udata.p = NULL;
++     }
++ 
++   plugin_data->object_only_syms = added_syms;
++   plugin_data->object_only_nsyms = added_nsyms;
++ 
++   free (object_only_syms);
++ 
++ quit:
++   /* Close and remove the object only section file.  */
++   bfd_close (nbfd);
++   unlink (object_only_file);
++ }
++ 
+  static enum ld_plugin_status
+  add_symbols (void * handle,
+            int nsyms,
+*************** add_symbols (void * handle,
+*** 142,148 ****
+    plugin_data->nsyms = nsyms;
+    plugin_data->syms = syms;
+  
+!   if (nsyms != 0)
+      abfd->flags |= HAS_SYMS;
+  
+    abfd->tdata.plugin_data = plugin_data;
+--- 275,283 ----
+    plugin_data->nsyms = nsyms;
+    plugin_data->syms = syms;
+  
+!   bfd_plugin_get_symbols_in_object_only (abfd);
+! 
+!   if ((nsyms + plugin_data->object_only_nsyms) != 0)
+      abfd->flags |= HAS_SYMS;
+  
+    abfd->tdata.plugin_data = plugin_data;
+*************** static long
+*** 389,395 ****
+  bfd_plugin_get_symtab_upper_bound (bfd *abfd)
+  {
+    struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data;
+!   long nsyms = plugin_data->nsyms;
+  
+    BFD_ASSERT (nsyms >= 0);
+  
+--- 524,531 ----
+  bfd_plugin_get_symtab_upper_bound (bfd *abfd)
+  {
+    struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data;
+!   /* Add symbols from object only section.  */
+!   long nsyms = plugin_data->nsyms + plugin_data->object_only_nsyms;
+  
+    BFD_ASSERT (nsyms >= 0);
+  
+*************** bfd_plugin_canonicalize_symtab (bfd *abf
+*** 423,434 ****
+    struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data;
+    long nsyms = plugin_data->nsyms;
+    const struct ld_plugin_symbol *syms = plugin_data->syms;
+!   static asection fake_section;
+!   static asection fake_common_section;
+!   int i;
+! 
+!   fake_section.name = ".text";
+!   fake_common_section.flags = SEC_IS_COMMON;
+  
+    for (i = 0; i < nsyms; i++)
+      {
+--- 559,565 ----
+    struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data;
+    long nsyms = plugin_data->nsyms;
+    const struct ld_plugin_symbol *syms = plugin_data->syms;
+!   int i, j;
+  
+    for (i = 0; i < nsyms; i++)
+      {
+*************** bfd_plugin_canonicalize_symtab (bfd *abf
+*** 441,450 ****
+        s->name = syms[i].name;
+        s->value = 0;
+        s->flags = convert_flags (&syms[i]);
+        switch (syms[i].def)
+       {
+       case LDPK_COMMON:
+!        s->section = &fake_common_section;
+         break;
+       case LDPK_UNDEF:
+       case LDPK_WEAKUNDEF:
+--- 572,582 ----
+        s->name = syms[i].name;
+        s->value = 0;
+        s->flags = convert_flags (&syms[i]);
++       s->udata.p = NULL;
+        switch (syms[i].def)
+       {
+       case LDPK_COMMON:
+!        s->section = &bfd_plugin_fake_common_section;
+         break;
+       case LDPK_UNDEF:
+       case LDPK_WEAKUNDEF:
+*************** bfd_plugin_canonicalize_symtab (bfd *abf
+*** 452,466 ****
+         break;
+       case LDPK_DEF:
+       case LDPK_WEAKDEF:
+!        s->section = &fake_section;
+         break;
+       default:
+         BFD_ASSERT (0);
+       }
+- 
+-       s->udata.p = (void *) &syms[i];
+      }
+  
+    return nsyms;
+  }
+  
+--- 584,601 ----
+         break;
+       case LDPK_DEF:
+       case LDPK_WEAKDEF:
+!        s->section = &bfd_plugin_fake_text_section;
+         break;
+       default:
+         BFD_ASSERT (0);
+       }
+      }
+  
++   /* Copy symbols from object only section.  */
++   nsyms += plugin_data->object_only_nsyms;
++   for (j = 0; j < plugin_data->object_only_nsyms; j++, i++)
++     alocation[i] = plugin_data->object_only_syms[j];
++ 
+    return nsyms;
+  }
+  
+diff -cpr ../binutils-2.23.2.orig/bfd/plugin.h bfd/plugin.h
+*** ../binutils-2.23.2.orig/bfd/plugin.h       2013-05-14 16:39:25.481717782 +0100
+--- bfd/plugin.h       2013-05-14 16:40:07.010718933 +0100
+*************** typedef struct plugin_data_struct
+*** 30,35 ****
+--- 30,37 ----
+  {
+    int nsyms;
+    const struct ld_plugin_symbol *syms;
++   int object_only_nsyms;
++   asymbol **object_only_syms;
+  }
+  plugin_data_struct;
+  
+diff -cpr ../binutils-2.23.2.orig/bfd/section.c bfd/section.c
+*** ../binutils-2.23.2.orig/bfd/section.c      2013-05-14 16:39:26.180717801 +0100
+--- bfd/section.c      2013-05-14 16:43:06.082723897 +0100
+*************** CODE_FRAGMENT
+*** 571,576 ****
+--- 571,579 ----
+  .  || ((SEC) == bfd_com_section_ptr)         \
+  .  || ((SEC) == bfd_ind_section_ptr))
+  .
++ .{* GNU object-only section name.  *}
++ .#define GNU_OBJECT_ONLY_SECTION_NAME ".gnu_object_only"
++ .
+  .{* Macros to handle insertion and deletion of a bfd's sections.  These
+  .   only handle the list pointers, ie. do not adjust section_count,
+  .   target_index etc.  *}
+diff -cpr ../binutils-2.23.2.orig/binutils/objcopy.c binutils/objcopy.c
+*** ../binutils-2.23.2.orig/binutils/objcopy.c 2013-05-14 16:39:36.214718079 +0100
+--- binutils/objcopy.c 2013-05-14 16:45:04.631727183 +0100
+*************** is_specified_symbol (const char *name, h
+*** 943,972 ****
+    return htab_find (htab, name) != NULL;
+  }
+  
+- /* Return a pointer to the symbol used as a signature for GROUP.  */
+- 
+- static asymbol *
+- group_signature (asection *group)
+- {
+-   bfd *abfd = group->owner;
+-   Elf_Internal_Shdr *ghdr;
+- 
+-   if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
+-     return NULL;
+- 
+-   ghdr = &elf_section_data (group)->this_hdr;
+-   if (ghdr->sh_link < elf_numsections (abfd))
+-     {
+-       const struct elf_backend_data *bed = get_elf_backend_data (abfd);
+-       Elf_Internal_Shdr *symhdr = elf_elfsections (abfd) [ghdr->sh_link];
+- 
+-       if (symhdr->sh_type == SHT_SYMTAB
+-        && ghdr->sh_info < symhdr->sh_size / bed->s->sizeof_sym)
+-      return isympp[ghdr->sh_info - 1];
+-     }
+-   return NULL;
+- }
+- 
+  /* Return TRUE if the section is a DWO section.  */
+  
+  static bfd_boolean
+--- 943,948 ----
+*************** is_strip_section (bfd *abfd ATTRIBUTE_UN
+*** 1034,1040 ****
+        /* PR binutils/3181
+        If we are going to strip the group signature symbol, then
+        strip the group section too.  */
+!       gsym = group_signature (sec);
+        if (gsym != NULL)
+       gname = gsym->name;
+        else
+--- 1010,1016 ----
+        /* PR binutils/3181
+        If we are going to strip the group signature symbol, then
+        strip the group section too.  */
+!       gsym = bfd_group_signature (sec, isympp);
+        if (gsym != NULL)
+       gname = gsym->name;
+        else
+*************** setup_section (bfd *ibfd, sec_ptr isecti
+*** 2633,2639 ****
+  
+    if ((isection->flags & SEC_GROUP) != 0)
+      {
+!       asymbol *gsym = group_signature (isection);
+  
+        if (gsym != NULL)
+       {
+--- 2609,2615 ----
+  
+    if ((isection->flags & SEC_GROUP) != 0)
+      {
+!       asymbol *gsym = bfd_group_signature (isection, isympp);
+  
+        if (gsym != NULL)
+       {
+diff -cpr ../binutils-2.23.2.orig/binutils/readelf.c binutils/readelf.c
+*** ../binutils-2.23.2.orig/binutils/readelf.c 2013-05-14 16:39:35.668718064 +0100
+--- binutils/readelf.c 2013-05-14 16:40:07.022718933 +0100
+*************** get_section_type_name (unsigned int sh_t
+*** 3101,3106 ****
+--- 3101,3107 ----
+      case 0x7ffffffd:         return "AUXILIARY";
+      case 0x7fffffff:         return "FILTER";
+      case SHT_GNU_LIBLIST:    return "GNU_LIBLIST";
++     case SHT_GNU_OBJECT_ONLY:        return "GNU_OBJECT_ONLY";
+  
+      default:
+        if ((sh_type >= SHT_LOPROC) && (sh_type <= SHT_HIPROC))
+diff -cpr ../binutils-2.23.2.orig/include/bfdlink.h include/bfdlink.h
+*** ../binutils-2.23.2.orig/include/bfdlink.h  2013-05-14 16:39:19.745717623 +0100
+--- include/bfdlink.h  2013-05-14 16:40:07.023718933 +0100
+*************** struct bfd_link_info
+*** 380,385 ****
+--- 380,391 ----
+    /* TRUE if ok to have multiple definition.  */
+    unsigned int allow_multiple_definition: 1;
+  
++   /* TRUE if .gnu_object_only section should be created.  */
++   unsigned int emit_gnu_object_only: 1;
++ 
++   /* TRUE if .gnu_object_only section is being created.  */
++   unsigned int emitting_gnu_object_only: 1;
++ 
+    /* TRUE if ok to have version with no definition.  */
+    unsigned int allow_undefined_version: 1;
+  
+diff -cpr ../binutils-2.23.2.orig/include/elf/common.h include/elf/common.h
+*** ../binutils-2.23.2.orig/include/elf/common.h       2013-05-14 16:39:19.628717619 +0100
+--- include/elf/common.h       2013-05-14 16:40:07.023718933 +0100
+***************
+*** 472,477 ****
+--- 472,478 ----
+  #define SHT_GNU_ATTRIBUTES 0x6ffffff5        /* Object attributes */
+  #define SHT_GNU_HASH 0x6ffffff6      /* GNU style symbol hash table */
+  #define SHT_GNU_LIBLIST      0x6ffffff7      /* List of prelink dependencies */
++ #define SHT_GNU_OBJECT_ONLY 0x6ffffff8       /* Object only */
+  
+  /* The next three section types are defined by Solaris, and are named
+     SHT_SUNW*.  We use them in GNU code, so we also define SHT_GNU*
+diff -cpr ../binutils-2.23.2.orig/ld/emultempl/alphaelf.em ld/emultempl/alphaelf.em
+*** ../binutils-2.23.2.orig/ld/emultempl/alphaelf.em   2013-05-14 16:39:37.461718114 +0100
+--- ld/emultempl/alphaelf.em   2013-05-14 16:40:07.030718933 +0100
+*************** alpha_finish (void)
+*** 100,106 ****
+    if (limit_32bit)
+      elf_elfheader (link_info.output_bfd)->e_flags |= EF_ALPHA_32BIT;
+  
+!   finish_default ();
+  }
+  EOF
+  
+--- 100,106 ----
+    if (limit_32bit)
+      elf_elfheader (link_info.output_bfd)->e_flags |= EF_ALPHA_32BIT;
+  
+!   gld${EMULATION_NAME}_finish ();
+  }
+  EOF
+  
+diff -cpr ../binutils-2.23.2.orig/ld/emultempl/armelf.em ld/emultempl/armelf.em
+*** ../binutils-2.23.2.orig/ld/emultempl/armelf.em     2013-05-14 16:39:37.458718114 +0100
+--- ld/emultempl/armelf.em     2013-05-14 16:40:07.033718933 +0100
+*************** gld${EMULATION_NAME}_after_allocation (v
+*** 366,372 ****
+  }
+  
+  static void
+! gld${EMULATION_NAME}_finish (void)
+  {
+    struct bfd_link_hash_entry * h;
+  
+--- 366,372 ----
+  }
+  
+  static void
+! arm_finish (void)
+  {
+    struct bfd_link_hash_entry * h;
+  
+*************** gld${EMULATION_NAME}_finish (void)
+*** 389,395 ****
+       }
+      }
+  
+!   finish_default ();
+  
+    if (thumb_entry_symbol)
+      {
+--- 389,395 ----
+       }
+      }
+  
+!   gld${EMULATION_NAME}_finish ();
+  
+    if (thumb_entry_symbol)
+      {
+*************** LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=
+*** 690,693 ****
+  LDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME}"_before_parse
+  
+  # Call the extra arm-elf function
+! LDEMUL_FINISH=gld${EMULATION_NAME}_finish
+--- 690,693 ----
+  LDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME}"_before_parse
+  
+  # Call the extra arm-elf function
+! LDEMUL_FINISH=arm_finish
+diff -cpr ../binutils-2.23.2.orig/ld/emultempl/elf32.em ld/emultempl/elf32.em
+*** ../binutils-2.23.2.orig/ld/emultempl/elf32.em      2013-05-14 16:39:37.465718114 +0100
+--- ld/emultempl/elf32.em      2013-05-14 16:40:07.035718933 +0100
+*************** static void gld${EMULATION_NAME}_before_
+*** 68,73 ****
+--- 68,74 ----
+  static void gld${EMULATION_NAME}_after_allocation (void);
+  static lang_output_section_statement_type *gld${EMULATION_NAME}_place_orphan
+    (asection *, const char *, int);
++ static void gld${EMULATION_NAME}_finish (void);
+  EOF
+  
+  if [ "x${USE_LIBPATH}" = xyes ] ; then
+*************** output_rel_find (asection *sec, int isdy
+*** 1764,1769 ****
+--- 1765,1772 ----
+    return last;
+  }
+  
++ static int orphan_init_done = 0;
++ 
+  /* Place an orphan section.  We use this to put random SHF_ALLOC
+     sections in the right segment.  */
+  
+*************** gld${EMULATION_NAME}_place_orphan (asect
+*** 1772,1778 ****
+                                  const char *secname,
+                                  int constraint)
+  {
+!   static struct orphan_save hold[] =
+      {
+        { ".text",
+       SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE,
+--- 1775,1781 ----
+                                  const char *secname,
+                                  int constraint)
+  {
+!   static struct orphan_save orig_hold[] =
+      {
+        { ".text",
+       SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE,
+*************** gld${EMULATION_NAME}_place_orphan (asect
+*** 1799,1804 ****
+--- 1802,1808 ----
+       SEC_HAS_CONTENTS,
+       0, 0, 0, 0 },
+      };
++   static struct orphan_save hold[ARRAY_SIZE (orig_hold)];
+    enum orphan_save_index
+      {
+        orphan_text = 0,
+*************** gld${EMULATION_NAME}_place_orphan (asect
+*** 1810,1816 ****
+        orphan_sdata,
+        orphan_nonalloc
+      };
+-   static int orphan_init_done = 0;
+    struct orphan_save *place;
+    lang_output_section_statement_type *after;
+    lang_output_section_statement_type *os;
+--- 1814,1819 ----
+*************** gld${EMULATION_NAME}_place_orphan (asect
+*** 1887,1901 ****
+  
+    if (!orphan_init_done)
+      {
+!       struct orphan_save *ho;
+  
+        for (ho = hold; ho < hold + sizeof (hold) / sizeof (hold[0]); ++ho)
+       if (ho->name != NULL)
+         {
+           ho->os = lang_output_section_find (ho->name);
+           if (ho->os != NULL && ho->os->flags == 0)
+             ho->os->flags = ho->flags;
+         }
+        orphan_init_done = 1;
+      }
+  
+--- 1890,1911 ----
+  
+    if (!orphan_init_done)
+      {
+!       struct orphan_save *ho, *horig;
+  
+        for (ho = hold; ho < hold + sizeof (hold) / sizeof (hold[0]); ++ho)
++       for (ho = hold, horig = orig_hold;
++         ho < hold + ARRAY_SIZE (hold);
++         ++ho, ++horig)
++      {
++        *ho = *horig;
++        if (ho->name != NULL)
+       if (ho->name != NULL)
+         {
+           ho->os = lang_output_section_find (ho->name);
+           if (ho->os != NULL && ho->os->flags == 0)
+             ho->os->flags = ho->flags;
+         }
++      }
+        orphan_init_done = 1;
+      }
+  
+*************** gld${EMULATION_NAME}_place_orphan (asect
+*** 1965,1970 ****
+--- 1975,2001 ----
+  EOF
+  fi
+  
++ fragment <<EOF
++ 
++ /* Final emulation specific call.  */
++ 
++ static void
++ gld${EMULATION_NAME}_finish (void)
++ {
++ EOF
++ if test x"$LDEMUL_PLACE_ORPHAN" != xgld"$EMULATION_NAME"_place_orphan; then
++ fragment <<EOF
++   /* Support the object-only output.  */
++   if (link_info.emit_gnu_object_only)
++     orphan_init_done = 0;
++ 
++ EOF
++ fi
++ fragment <<EOF
++   finish_default ();
++ }
++ EOF
++ 
+  if test x"$LDEMUL_AFTER_ALLOCATION" != xgld"$EMULATION_NAME"_after_allocation; then
+  fragment <<EOF
+  
+*************** struct ld_emulation_xfer_struct ld_${EMU
+*** 2497,2503 ****
+    ${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
+    "${EMULATION_NAME}",
+    "${OUTPUT_FORMAT}",
+!   ${LDEMUL_FINISH-finish_default},
+    ${LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS-NULL},
+    ${LDEMUL_OPEN_DYNAMIC_ARCHIVE-gld${EMULATION_NAME}_open_dynamic_archive},
+    ${LDEMUL_PLACE_ORPHAN-gld${EMULATION_NAME}_place_orphan},
+--- 2528,2534 ----
+    ${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
+    "${EMULATION_NAME}",
+    "${OUTPUT_FORMAT}",
+!   ${LDEMUL_FINISH-gld${EMULATION_NAME}_finish},
+    ${LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS-NULL},
+    ${LDEMUL_OPEN_DYNAMIC_ARCHIVE-gld${EMULATION_NAME}_open_dynamic_archive},
+    ${LDEMUL_PLACE_ORPHAN-gld${EMULATION_NAME}_place_orphan},
+diff -cpr ../binutils-2.23.2.orig/ld/emultempl/ppc64elf.em ld/emultempl/ppc64elf.em
+*** ../binutils-2.23.2.orig/ld/emultempl/ppc64elf.em   2013-05-14 16:39:37.454718113 +0100
+--- ld/emultempl/ppc64elf.em   2013-05-14 16:40:07.044718934 +0100
+*************** gld${EMULATION_NAME}_after_allocation (v
+*** 533,539 ****
+  /* Final emulation specific call.  */
+  
+  static void
+! gld${EMULATION_NAME}_finish (void)
+  {
+    /* e_entry on PowerPC64 points to the function descriptor for
+       _start.  If _start is missing, default to the first function
+--- 533,539 ----
+  /* Final emulation specific call.  */
+  
+  static void
+! ppc_finish (void)
+  {
+    /* e_entry on PowerPC64 points to the function descriptor for
+       _start.  If _start is missing, default to the first function
+*************** gld${EMULATION_NAME}_finish (void)
+*** 565,571 ****
+      }
+  
+    ppc64_elf_restore_symbols (&link_info);
+!   finish_default ();
+  }
+  
+  
+--- 565,571 ----
+      }
+  
+    ppc64_elf_restore_symbols (&link_info);
+!   gld${EMULATION_NAME}_finish ();
+  }
+  
+  
+*************** PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LI
+*** 867,872 ****
+  #
+  LDEMUL_BEFORE_ALLOCATION=ppc_before_allocation
+  LDEMUL_AFTER_ALLOCATION=gld${EMULATION_NAME}_after_allocation
+! LDEMUL_FINISH=gld${EMULATION_NAME}_finish
+  LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=ppc_create_output_section_statements
+  LDEMUL_NEW_VERS_PATTERN=gld${EMULATION_NAME}_new_vers_pattern
+--- 867,872 ----
+  #
+  LDEMUL_BEFORE_ALLOCATION=ppc_before_allocation
+  LDEMUL_AFTER_ALLOCATION=gld${EMULATION_NAME}_after_allocation
+! LDEMUL_FINISH=ppc_finish
+  LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=ppc_create_output_section_statements
+  LDEMUL_NEW_VERS_PATTERN=gld${EMULATION_NAME}_new_vers_pattern
+diff -cpr ../binutils-2.23.2.orig/ld/emultempl/spuelf.em ld/emultempl/spuelf.em
+*** ../binutils-2.23.2.orig/ld/emultempl/spuelf.em     2013-05-14 16:39:37.453718113 +0100
+--- ld/emultempl/spuelf.em     2013-05-14 16:40:07.045718934 +0100
+*************** spu_elf_relink (void)
+*** 416,422 ****
+  /* Final emulation specific call.  */
+  
+  static void
+! gld${EMULATION_NAME}_finish (void)
+  {
+    if (is_spu_target ())
+      {
+--- 416,422 ----
+  /* Final emulation specific call.  */
+  
+  static void
+! spu_finish (void)
+  {
+    if (is_spu_target ())
+      {
+*************** gld${EMULATION_NAME}_finish (void)
+*** 432,438 ****
+       einfo ("%P: --auto-overlay ignored with zero local store range\n");
+      }
+  
+!   finish_default ();
+  }
+  
+  static char *
+--- 432,438 ----
+       einfo ("%P: --auto-overlay ignored with zero local store range\n");
+      }
+  
+!   gld${EMULATION_NAME}_finish ();
+  }
+  
+  static char *
+*************** PARSE_AND_LIST_ARGS_CASES='
+*** 832,836 ****
+  
+  LDEMUL_AFTER_OPEN=spu_after_open
+  LDEMUL_BEFORE_ALLOCATION=spu_before_allocation
+! LDEMUL_FINISH=gld${EMULATION_NAME}_finish
+  LDEMUL_CHOOSE_TARGET=gld${EMULATION_NAME}_choose_target
+--- 832,836 ----
+  
+  LDEMUL_AFTER_OPEN=spu_after_open
+  LDEMUL_BEFORE_ALLOCATION=spu_before_allocation
+! LDEMUL_FINISH=spu_finish
+  LDEMUL_CHOOSE_TARGET=gld${EMULATION_NAME}_choose_target
+diff -cpr ../binutils-2.23.2.orig/ld/ldfile.c ld/ldfile.c
+*** ../binutils-2.23.2.orig/ld/ldfile.c        2013-05-14 16:39:37.164718105 +0100
+--- ld/ldfile.c        2013-05-14 16:40:07.046718934 +0100
+*************** success:
+*** 319,325 ****
+--- 319,327 ----
+         plugin_maybe_claim (&file, entry);
+       }
+      }
++   else
+  #endif /* ENABLE_PLUGINS */
++     cmdline_check_object_only_section (entry->the_bfd, FALSE);
+  
+    /* It opened OK, the format checked out, and the plugins have had
+       their chance to claim it, so this is success.  */
+diff -cpr ../binutils-2.23.2.orig/ld/ldlang.c ld/ldlang.c
+*** ../binutils-2.23.2.orig/ld/ldlang.c        2013-05-14 16:39:39.704718176 +0100
+--- ld/ldlang.c        2013-05-14 17:03:54.030758491 +0100
+***************
+*** 38,43 ****
+--- 38,44 ----
+  #include "ldctor.h"
+  #include "ldfile.h"
+  #include "ldemul.h"
++ #include "ldwrite.h"
+  #include "fnmatch.h"
+  #include "demangle.h"
+  #include "hashtab.h"
+***************
+*** 46,51 ****
+--- 47,55 ----
+  #include "plugin.h"
+  #endif /* ENABLE_PLUGINS */
+  
++ /* FIXME: Put it here to avoid NAME conflict from ldgram.h.  */
++ #include "elf-bfd.h"
++ 
+  #ifndef offsetof
+  #define offsetof(TYPE, MEMBER) ((size_t) & (((TYPE*) 0)->MEMBER))
+  #endif
+*************** static struct bfd_hash_table lang_define
+*** 69,74 ****
+--- 73,81 ----
+  static lang_statement_list_type *stat_save[10];
+  static lang_statement_list_type **stat_save_ptr = &stat_save[0];
+  static struct unique_sections *unique_section_list;
++ static cmdline_list_type cmdline_object_only_file_list;
++ static cmdline_list_type cmdline_object_only_archive_list;
++ static cmdline_list_type cmdline_temp_object_only_list;
+  
+  /* Forward declarations.  */
+  static void exp_init_os (etree_type *);
+*************** static void lang_record_phdrs (void);
+*** 89,94 ****
+--- 96,105 ----
+  static void lang_do_version_exports_section (void);
+  static void lang_finalize_version_expr_head
+    (struct bfd_elf_version_expr_head *);
++ static void cmdline_lists_init (void);
++ static void cmdline_get_object_only_input_files (void);
++ static void print_cmdline_list (cmdline_union_type *);
++ static bfd_boolean cmdline_on_object_only_archive_list_p (bfd *);
+  
+  /* Exported variables.  */
+  const char *output_target;
+*************** output_section_statement_table_free (voi
+*** 1204,1217 ****
+  /* Build enough state so that the parser can build its tree.  */
+  
+  void
+! lang_init (void)
+  {
+!   obstack_begin (&stat_obstack, 1000);
+  
+    stat_ptr = &statement_list;
+  
+    output_section_statement_table_init ();
+  
+    lang_list_init (stat_ptr);
+  
+    lang_list_init (&input_file_chain);
+--- 1215,1231 ----
+  /* Build enough state so that the parser can build its tree.  */
+  
+  void
+! lang_init (bfd_boolean object_only)
+  {
+!   if (!object_only)
+!     obstack_begin (&stat_obstack, 1000);
+  
+    stat_ptr = &statement_list;
+  
+    output_section_statement_table_init ();
+  
++   cmdline_lists_init ();
++ 
+    lang_list_init (stat_ptr);
+  
+    lang_list_init (&input_file_chain);
+*************** lang_init (void)
+*** 1230,1239 ****
+       simpler to re-use working machinery than using a linked list in terms
+       of code-complexity here in ld, besides the initialization which just
+       looks like other code here.  */
+!   if (!bfd_hash_table_init_n (&lang_definedness_table,
+!                            lang_definedness_newfunc,
+!                            sizeof (struct lang_definedness_hash_entry),
+!                            3))
+      einfo (_("%P%F: can not create hash table: %E\n"));
+  }
+  
+--- 1244,1254 ----
+       simpler to re-use working machinery than using a linked list in terms
+       of code-complexity here in ld, besides the initialization which just
+       looks like other code here.  */
+!   if (!object_only
+!       && !bfd_hash_table_init_n (&lang_definedness_table,
+!                               lang_definedness_newfunc,
+!                               sizeof (struct lang_definedness_hash_entry),
+!                               3))
+      einfo (_("%P%F: can not create hash table: %E\n"));
+  }
+  
+*************** load_symbols (lang_input_statement_type
+*** 2769,2774 ****
+--- 2784,2795 ----
+                 loaded = FALSE;
+               }
+  
++            if (link_info.emitting_gnu_object_only)
++              {
++                if (!cmdline_on_object_only_archive_list_p (member))
++                  continue;
++              }
++ 
+             subsbfd = member;
+             if (!(*link_info.callbacks
+                   ->add_archive_element) (&link_info, member,
+*************** lang_process (void)
+*** 6659,6665 ****
+--- 6680,6716 ----
+         open_input_bfds (statement_list.head, OPEN_BFD_RESCAN);
+       }
+      }
++   else
+  #endif /* ENABLE_PLUGINS */
++     if (link_info.relocatable)
++     {
++       /* Check if .gnu_object_only section should be created.  */
++       bfd *p;
++       int object_type;
++ 
++       object_type = 0;
++       for (p = link_info.input_bfds; p != (bfd *) NULL; p = p->link_next)
++      {
++        object_type |= 1 << p->lto_type;
++        if ((object_type & (1 << lto_mixed_object)) != 0
++            || ((object_type
++                 & (1 << lto_non_ir_object
++                    | 1 << lto_ir_object))
++                == (1 << lto_non_ir_object | 1 << lto_ir_object)))
++          {
++            link_info.emit_gnu_object_only = TRUE;
++            break;
++          }
++      }
++ 
++       if (trace_files
++        && (cmdline_object_only_file_list.head
++            || cmdline_object_only_archive_list.head))
++      {
++        print_cmdline_list (cmdline_object_only_file_list.head);
++        print_cmdline_list (cmdline_object_only_archive_list.head);
++      }
++     }
+  
+    link_info.gc_sym_list = &entry_symbol;
+    if (entry_symbol.name == NULL)
+*************** lang_ld_feature (char *str)
+*** 8059,8061 ****
+--- 8111,9071 ----
+        p = q;
+      }
+  }
++ 
++ static void
++ cmdline_lists_init (void)
++ {
++   cmdline_object_only_file_list.tail
++     = &cmdline_object_only_file_list.head;
++   cmdline_object_only_archive_list.tail
++     = &cmdline_object_only_archive_list.head;
++   cmdline_temp_object_only_list.tail
++     = &cmdline_temp_object_only_list.head;
++ }
++ 
++ /* Allocate an item with TYPE and DATA.  */
++ 
++ static cmdline_union_type *
++ cmdline_list_new (cmdline_enum_type type, void *data)
++ {
++   cmdline_union_type *new_opt;
++ 
++   new_opt = (cmdline_union_type *) stat_alloc (sizeof (*new_opt));
++   new_opt->header.type = type;
++   switch (type)
++     {
++     default:
++       break;
++     case cmdline_is_file_enum:
++       new_opt->file.filename = (const char *) data;
++       break;
++     case cmdline_is_bfd_enum:
++       new_opt->abfd.abfd = (bfd *) data;
++       break;
++     }
++   return new_opt;
++ }
++ 
++ /* Append an item with TYPE and DATA to LIST.  */
++ 
++ static void
++ cmdline_list_append (cmdline_list_type *list, cmdline_enum_type type,
++                   void *data)
++ {
++   cmdline_union_type *new_opt = cmdline_list_new (type, data);
++   new_opt->header.next = NULL;
++   *list->tail = new_opt;
++   list->tail = &new_opt->header.next;
++ }
++ 
++ static void
++ print_cmdline_list (cmdline_union_type *c)
++ {
++   for (; c != NULL; c = c->header.next)
++     switch (c->header.type)
++       {
++       default:
++      abort ();
++       case cmdline_is_file_enum:
++      info_msg (" %s", c->file.filename);
++      break;
++       case cmdline_is_bfd_enum:
++      info_msg (" [%B]", c->abfd.abfd);
++      break;
++       }
++ 
++   info_msg ("\n");
++ }
++ 
++ /* Return TRUE if ABFD is on cmdline_object_only_archive_list.  */
++ 
++ static bfd_boolean
++ cmdline_on_object_only_archive_list_p (bfd *abfd)
++ {
++   cmdline_union_type *c, *next;
++   bfd *archive, *obfd, *oarchive;
++   ufile_ptr origin = abfd->origin;
++ 
++   archive = bfd_my_archive (abfd);
++   for (c = cmdline_object_only_archive_list.head; c != NULL; c = next)
++     {
++       if (c->header.type != cmdline_is_bfd_enum)
++      abort ();
++ 
++       next = c->header.next;
++       obfd = c->abfd.abfd;
++       oarchive = bfd_my_archive (obfd);
++ 
++       /* The list is grouped by archive file name and sorted by member
++       origin.  */
++       if (strcmp (archive->filename, oarchive->filename) != 0)
++      continue;
++ 
++       if (origin == obfd->origin)
++      return TRUE;
++       else if (origin < obfd->origin)
++      return FALSE;
++     }
++ 
++   return FALSE;
++ }
++ 
++ /* Append an item with TYPE and DATA to cmdline_object_only_file_list
++    or cmdline_object_only_archive_list if needed.  */
++ 
++ static void
++ cmdline_object_only_list_append (cmdline_enum_type type, void *data)
++ {
++   cmdline_union_type *c;
++   cmdline_union_type *new_opt, *next, **prev;
++   bfd *abfd, *archive;
++   bfd *obfd, *oarchive;
++   bfd *nbfd, *narchive;
++   ufile_ptr origin, norigin;
++ 
++   /* Put it on cmdline_object_only_file_list if it isn't an archive
++      member.  */
++   switch (type)
++     {
++     default:
++       abort ();
++     case cmdline_is_bfd_enum:
++       abfd = (bfd *) data;
++       archive = bfd_my_archive (abfd);
++       if (archive)
++      break;
++     case cmdline_is_file_enum:
++       cmdline_list_append (&cmdline_object_only_file_list, type, data);
++       return;
++     }
++ 
++   /* Put archive member on cmdline_object_only_archive_list and sort
++      the list by archive name and archive member origin.  */
++   new_opt = (cmdline_union_type *) stat_alloc (sizeof (*new_opt));
++   new_opt->header.type = cmdline_is_bfd_enum;
++   new_opt->header.next = NULL;
++   new_opt->abfd.abfd = (bfd *) data;
++ 
++   c = cmdline_object_only_archive_list.head;
++   if (c == NULL)
++     {
++       cmdline_object_only_archive_list.head = new_opt;
++       cmdline_object_only_archive_list.tail = &new_opt->header.next;
++       return;
++     }
++ 
++   prev = NULL;
++   origin = abfd->origin;
++   for (; c != NULL; c = next)
++     {
++       if (c->header.type != cmdline_is_bfd_enum)
++      abort ();
++ 
++       next = c->header.next;
++ 
++       obfd = c->abfd.abfd;
++       oarchive = bfd_my_archive (obfd);
++ 
++       if (strcmp (archive->filename, oarchive->filename) == 0)
++      {
++        bfd_boolean after;
++ 
++        if (origin < obfd->origin)
++          {
++            /* Insert it before the current.  */
++            new_opt->header.next = c;
++            if (prev)
++              *prev = new_opt;
++            else
++              cmdline_object_only_archive_list.head = new_opt;
++            return;
++          }
++ 
++        after = TRUE;
++ 
++        /* Check origin.  */
++        while (next)
++          {
++            if (next->header.type != cmdline_is_bfd_enum)
++              abort ();
++ 
++            nbfd = next->abfd.abfd;
++            norigin = nbfd->origin;
++            if (origin > norigin)
++              {
++                /* Insert it after NEXT.  */
++                break;
++              }
++ 
++            narchive = bfd_my_archive (nbfd);
++            if (strcmp (archive->filename, narchive->filename) != 0)
++              {
++                /* Insert it befor NEXT.  */
++                after = FALSE;
++                break;
++              }
++ 
++            c = next;
++            next = next->header.next;
++          }
++ 
++        if (after && next)
++          {
++            c = next;
++            next = next->header.next;
++          }
++ 
++        if (*cmdline_object_only_archive_list.tail == c->header.next)
++          cmdline_object_only_archive_list.tail
++            = &new_opt->header.next;
++ 
++        prev = &c->header.next;
++        new_opt->header.next = next;
++        *prev = new_opt;
++        return;
++      }
++ 
++       prev = &c->header.next;
++     }
++ 
++   *cmdline_object_only_archive_list.tail = new_opt;
++   cmdline_object_only_archive_list.tail = &new_opt->header.next;
++ }
++ 
++ 
++ static void
++ cmdline_get_object_only_input_files (void)
++ {
++   cmdline_union_type *c, *next;
++   bfd *abfd, *archive;
++   bfd *nbfd, *narchive;
++ 
++   /* Add files first.  */
++   for (c = cmdline_object_only_file_list.head;
++        c != NULL; c = c->header.next)
++     switch (c->header.type)
++       {
++       default:
++      abort ();
++       case cmdline_is_file_enum:
++      lang_add_input_file (c->file.filename,
++                           lang_input_file_is_file_enum, NULL);
++      break;
++       case cmdline_is_bfd_enum:
++      abfd = c->abfd.abfd;
++      if (bfd_my_archive (abfd))
++        abort ();
++      lang_add_input_file (abfd->filename,
++                           lang_input_file_is_file_enum, NULL);
++      break;
++       }
++ 
++   /* Add archive members next.  */
++   for (c = cmdline_object_only_archive_list.head; c != NULL; c = next)
++     {
++       if (c->header.type != cmdline_is_bfd_enum)
++      abort ();
++ 
++       next = c->header.next;
++ 
++       abfd = c->abfd.abfd;
++       archive = bfd_my_archive (abfd);
++    
++       /* Add the first archive of the archive member group.  */
++       lang_add_input_file (archive->filename,
++                         lang_input_file_is_file_enum, NULL);
++ 
++       /* Skip the rest members in the archive member group.  */
++       do
++      {
++        if (!next)
++          break;
++ 
++        if (next->header.type != cmdline_is_bfd_enum)
++          abort ();
++ 
++        next = next->header.next;
++        if (!next)
++          break;
++        nbfd = next->abfd.abfd;
++        narchive = bfd_my_archive (nbfd);
++      }
++       while (strcmp (archive->filename, narchive->filename) == 0);
++     }
++ }
++ 
++ struct cmdline_arg
++ {
++   bfd *obfd;
++   asymbol **isympp;
++   int status;
++ };
++ 
++ /* Create a section in OBFD with the same
++    name and attributes as ISECTION in IBFD.  */
++ 
++ static void
++ setup_section (bfd *ibfd, sec_ptr isection, void *p)
++ {
++   struct cmdline_arg *arg = (struct cmdline_arg *) p;
++   bfd *obfd = arg->obfd;
++   asymbol **isympp = arg->isympp;
++   const char *name = isection->name;
++   sec_ptr osection;
++   const char *err;
++ 
++   /* Skip the object-only section.  */
++   if (ibfd->object_only_section == isection)
++     return;
++ 
++   /* If we have already failed earlier on, do not keep on generating
++      complaints now.  */
++   if (arg->status)
++     return;
++ 
++   osection = bfd_make_section_anyway_with_flags (obfd, name,
++                                               isection->flags);
++ 
++   if (osection == NULL)
++     {
++       err = _("failed to create output section");
++       goto loser;
++     }
++ 
++   osection->size = isection->size;
++   osection->vma = isection->vma;
++   osection->lma = isection->lma;
++   osection->alignment_power = isection->alignment_power;
++ 
++   /* Copy merge entity size.  */
++   osection->entsize = isection->entsize;
++ 
++   /* This used to be mangle_section; we do here to avoid using
++      bfd_get_section_by_name since some formats allow multiple
++      sections with the same name.  */
++   isection->output_section = osection;
++   isection->output_offset = 0;
++ 
++   if ((isection->flags & SEC_GROUP) != 0)
++     {
++       asymbol *gsym = bfd_group_signature (isection, isympp);
++ 
++       if (gsym != NULL)
++      {
++        gsym->flags |= BSF_KEEP;
++        if (ibfd->xvec->flavour == bfd_target_elf_flavour)
++          elf_group_id (isection) = gsym;
++      }
++     }
++ 
++   /* Allow the BFD backend to copy any private data it understands
++      from the input section to the output section.  */
++   if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection))
++     {
++       err = _("failed to copy private data");
++       goto loser;
++     }
++ 
++   /* All went well.  */
++   return;
++ 
++ loser:
++   arg->status = 1;
++   einfo (_("%P%F: setup_section: %s: %s\n"), err, name);
++ }
++ 
++ /* Copy the data of input section ISECTION of IBFD
++    to an output section with the same name in OBFD.
++    If stripping then don't copy any relocation info.  */
++ 
++ static void
++ copy_section (bfd *ibfd, sec_ptr isection, void *p)
++ {
++   struct cmdline_arg *arg = (struct cmdline_arg *) p;
++   bfd *obfd = arg->obfd;
++   asymbol **isympp = arg->isympp;
++   arelent **relpp;
++   long relcount;
++   sec_ptr osection;
++   bfd_size_type size;
++   long relsize;
++   flagword flags;
++   const char *err;
++ 
++   /* Skip the object-only section.  */
++   if (ibfd->object_only_section == isection)
++     return;
++ 
++   /* If we have already failed earlier on, do not keep on generating
++      complaints now.  */
++   if (arg->status)
++     return;
++ 
++   flags = bfd_get_section_flags (ibfd, isection);
++   if ((flags & SEC_GROUP) != 0)
++     return;
++ 
++   osection = isection->output_section;
++   size = bfd_get_section_size (isection);
++ 
++   if (size == 0 || osection == 0)
++     return;
++ 
++   relsize = bfd_get_reloc_upper_bound (ibfd, isection);
++ 
++   if (relsize < 0)
++     {
++       /* Do not complain if the target does not support relocations.  */
++       if (relsize == -1
++        && bfd_get_error () == bfd_error_invalid_operation)
++      relsize = 0;
++       else
++      {
++        err = bfd_errmsg (bfd_get_error ());
++        goto loser;
++      }
++     }
++ 
++   if (relsize == 0)
++     bfd_set_reloc (obfd, osection, NULL, 0);
++   else
++     {
++       relpp = (arelent **) xmalloc (relsize);
++       relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, isympp);
++       if (relcount < 0)
++      {
++        err = _("relocation count is negative");
++        goto loser;
++      }
++ 
++       bfd_set_reloc (obfd, osection,
++                   relcount == 0 ? NULL : relpp, relcount);
++       if (relcount == 0)
++      free (relpp);
++     }
++ 
++   if (bfd_get_section_flags (ibfd, isection) & SEC_HAS_CONTENTS)
++     {
++       bfd_byte *memhunk = NULL;
++ 
++       if (!bfd_get_full_section_contents (ibfd, isection, &memhunk))
++      {
++        err = bfd_errmsg (bfd_get_error ());
++        goto loser;
++      }
++ 
++       if (!bfd_set_section_contents (obfd, osection, memhunk, 0, size))
++      {
++        err = bfd_errmsg (bfd_get_error ());
++        goto loser;
++      }
++       free (memhunk);
++     }
++ 
++   /* All went well.  */
++   return;
++ 
++ loser:
++   einfo (_("%P%F: copy_section: %s: %s\n"), err, isection->name);
++ }
++ /* Open the temporary bfd created in the same directory as PATH.  */
++ 
++ static bfd *
++ cmdline_fopen_temp (const char *path, const char *target,
++                  const char *mode)
++ {
++ #define template "ldXXXXXX"
++   const char *slash = strrchr (path, '/');
++   char *tmpname;
++   size_t len;
++   int fd;
++ 
++ #ifdef HAVE_DOS_BASED_FILE_SYSTEM
++   {
++     /* We could have foo/bar\\baz, or foo\\bar, or d:bar.  */
++     char *bslash = strrchr (path, '\\');
++ 
++     if (slash == NULL || (bslash != NULL && bslash > slash))
++       slash = bslash;
++     if (slash == NULL && path[0] != '\0' && path[1] == ':')
++       slash = path + 1;
++   }
++ #endif
++ 
++   if (slash != (char *) NULL)
++     {
++       len = slash - path;
++       tmpname = (char *) xmalloc (len + sizeof (template) + 2);
++       memcpy (tmpname, path, len);
++ 
++ #ifdef HAVE_DOS_BASED_FILE_SYSTEM
++       /* If tmpname is "X:", appending a slash will make it a root
++       directory on drive X, which is NOT the same as the current
++       directory on drive X.  */
++       if (len == 2 && tmpname[1] == ':')
++      tmpname[len++] = '.';
++ #endif
++       tmpname[len++] = '/';
++     }
++   else
++     {
++       tmpname = (char *) xmalloc (sizeof (template));
++       len = 0;
++     }
++ 
++   memcpy (tmpname + len, template, sizeof (template));
++ #undef template
++ 
++ #ifdef HAVE_MKSTEMP
++   fd = mkstemp (tmpname);
++ #else
++   tmpname = mktemp (tmpname);
++   if (tmpname == NULL)
++     return NULL;
++   fd = open (tmpname, O_RDWR | O_CREAT | O_EXCL, 0600);
++ #endif
++   if (fd == -1)
++     return NULL;
++   return bfd_fopen (tmpname, target, mode, fd);
++ }
++ 
++ /* Add the object-only section.  */
++ 
++ static void
++ cmdline_add_object_only_section (bfd_byte *contents, size_t size)
++ {
++   bfd_vma start;
++   flagword flags;
++   enum bfd_architecture iarch;
++   unsigned int imach;
++   long symcount;
++   long symsize;
++   asymbol **isympp = NULL;
++   asymbol **osympp = NULL;
++   bfd *obfd = NULL, *ibfd;
++   const char *err;
++   struct arg
++     {
++       bfd *obfd;
++       asymbol **isympp;
++       int status;
++     } arg;
++   char **matching;
++   const char *ofilename = NULL;
++   asection *sec;
++ 
++   ibfd = bfd_openr (output_filename, output_target);
++   if (!ibfd)
++     {
++       err = bfd_errmsg (bfd_get_error ());
++       goto loser;
++     }
++ 
++   if (!bfd_check_format_matches (ibfd, bfd_object, &matching))
++     {
++       err = bfd_errmsg (bfd_get_error ());
++       goto loser;
++     }
++ 
++   obfd = cmdline_fopen_temp (output_filename, output_target, "w");
++   if (!obfd)
++     {
++       err = bfd_errmsg (bfd_get_error ());
++       goto loser;
++     }
++   ofilename = bfd_get_filename (obfd);
++ 
++   if (!bfd_set_format (obfd, bfd_object))
++     {
++       err = bfd_errmsg (bfd_get_error ());
++       goto loser;
++     }
++ 
++   /* Copy the start address, flags and architecture of input file to
++      output file.  */
++   flags = bfd_get_file_flags (ibfd);
++   start = bfd_get_start_address (ibfd);
++   iarch = bfd_get_arch (ibfd);
++   imach = bfd_get_mach (ibfd);
++   if (!bfd_set_start_address (obfd, start)
++       || !bfd_set_file_flags (obfd, flags)
++       || !bfd_set_arch_mach (obfd, iarch, imach))
++     {
++       err = bfd_errmsg (bfd_get_error ());
++       goto loser;
++     }
++      
++   symsize = bfd_get_symtab_upper_bound (ibfd);
++   if (symsize < 0)
++     {
++       err = bfd_errmsg (bfd_get_error ());
++       goto loser;
++     }
++ 
++   isympp = (asymbol **) xmalloc (symsize);
++   symcount = bfd_canonicalize_symtab (ibfd, isympp);
++   if (symcount < 0)
++     {
++       err = bfd_errmsg (bfd_get_error ());
++       goto loser;
++     }
++ 
++   arg.obfd = obfd;
++   arg.isympp = isympp;
++   arg.status = 0;
++ 
++   /* BFD mandates that all output sections be created and sizes set before
++      any output is done.  Thus, we traverse all sections multiple times.  */
++   bfd_map_over_sections (ibfd, setup_section, &arg);
++ 
++   if (arg.status)
++     {
++       err = _("error setting up sections");
++       goto loser;
++     }
++ 
++   /* Allow the BFD backend to copy any private data it understands
++      from the input section to the output section.  */
++   if (! bfd_copy_private_header_data (ibfd, obfd))
++     {
++       err = _("error copying private header data");
++       goto loser;
++     }
++ 
++   /* Create the object-only section.  */
++   sec = bfd_make_section_with_flags (obfd,
++                                   GNU_OBJECT_ONLY_SECTION_NAME,
++                                   (SEC_HAS_CONTENTS
++                                    | SEC_READONLY
++                                    | SEC_DATA
++                                    | SEC_LINKER_CREATED));
++   if (sec == NULL)
++     {
++       err = _("can't create object-only section");
++       goto loser;
++     }
++ 
++   if (! bfd_set_section_size (obfd, sec, size))
++     {
++       err = _("can't set object-only section size");
++       goto loser;
++     }
++ 
++   if (ibfd->object_only_section)
++     {
++       /* Filter out the object-only section symbol.  */
++       long src_count = 0, dst_count = 0;
++       asymbol **from, **to;
++ 
++       osympp = (asymbol **) xmalloc (symcount * sizeof (asymbol *));
++       from = isympp;
++       to = osympp;
++       for (; src_count < symcount; src_count++)
++      {
++        asymbol *sym = from[src_count];
++        if (bfd_get_section (sym) != ibfd->object_only_section)
++          to[dst_count++] = sym;
++      }
++       to[dst_count] = NULL;
++       symcount = dst_count;
++       bfd_set_symtab (obfd, osympp, symcount);
++     }
++   else
++     bfd_set_symtab (obfd, isympp, symcount);
++ 
++   /* This has to happen after the symbol table has been set.  */
++   bfd_map_over_sections (ibfd, copy_section, &arg);
++ 
++   if (arg.status)
++     {
++       err = _("error copying sections");
++       goto loser;
++     }
++ 
++   /* Copy the object-only section to the output.  */
++   if (! bfd_set_section_contents (obfd, sec, contents, 0, size))
++     {
++       err = _("error adding object-only section");
++       goto loser;
++     }
++ 
++   /* Allow the BFD backend to copy any private data it understands
++      from the input BFD to the output BFD.  This is done last to
++      permit the routine to look at the filtered symbol table, which is
++      important for the ECOFF code at least.  */
++   if (! bfd_copy_private_bfd_data (ibfd, obfd))
++     {
++       err = _("error copying private BFD data");
++       goto loser;
++     }
++ 
++   if (!bfd_close (obfd))
++     {
++       unlink (ofilename);
++       einfo (_("%P%F: failed to finish output with object-only section\n"));
++     }
++ 
++   /* Must be freed after bfd_close ().  */
++   free (isympp);
++   if (osympp)
++     free (osympp);
++ 
++   if (rename (ofilename, output_filename))
++     {
++       unlink (ofilename);
++       einfo (_("%P%F: failed to rename output with object-only section\n"));
++     }
++ 
++   return;
++ 
++ loser:
++   if (isympp)
++     free (isympp);
++   if (osympp)
++     free (osympp);
++   if (obfd)
++     bfd_close (obfd);
++   if (ofilename)
++     unlink (ofilename);
++   einfo (_("%P%F: failed to add object-only section: %s\n"), err);
++ }
++ 
++ /* Emit the final output with object-only section.  */
++ 
++ void
++ cmdline_emit_object_only_section (void)
++ {
++   const char *saved_output_filename = output_filename;
++   int fd;
++   size_t size, off;
++   bfd_byte *contents;
++   struct stat st;
++ 
++   /* Get a temporary object-only file.  */
++   output_filename = make_temp_file (".obj-only.o");
++ 
++   had_output_filename = FALSE;
++   link_info.input_bfds = NULL;
++   link_info.input_bfds_tail = &link_info.input_bfds;
++ 
++   lang_init (TRUE);
++ 
++   ld_parse_linker_script ();
++ 
++   /* Set up the object-only output. */
++   lang_final ();
++ 
++   /* Open the object-only file for output.  */
++   lang_for_each_statement (ldlang_open_output);
++ 
++   ldemul_create_output_section_statements ();
++ 
++   if (!bfd_section_already_linked_table_init ())
++     einfo (_("%P%F: Failed to create hash table\n"));
++ 
++   /* Call cmdline_on_object_only_archive_list_p to check which member
++      should be loaded.  */
++   input_flags.whole_archive = TRUE;
++ 
++   /* Set it to avoid adding more to cmdline lists.  */
++   link_info.emitting_gnu_object_only = TRUE;
++ 
++   cmdline_get_object_only_input_files ();
++ 
++   open_input_bfds (statement_list.head, FALSE);
++ 
++   ldemul_after_open ();
++ 
++   bfd_section_already_linked_table_free ();
++ 
++   /* Make sure that we're not mixing architectures.  We call this
++      after all the input files have been opened, but before we do any
++      other processing, so that any operations merge_private_bfd_data
++      does on the output file will be known during the rest of the
++      link.  */
++   lang_check ();
++ 
++   /* Size up the common data.  */
++   lang_common ();
++ 
++   /* Update wild statements.  */
++   update_wild_statements (statement_list.head);
++ 
++   /* Run through the contours of the script and attach input sections
++      to the correct output sections.  */
++   map_input_to_output_sections (statement_list.head, NULL, NULL);
++ 
++   /* Find any sections not attached explicitly and handle them.  */
++   lang_place_orphans ();
++ 
++   /* Do anything special before sizing sections.  This is where ELF
++      and other back-ends size dynamic sections.  */
++   ldemul_before_allocation ();
++ 
++   /* Size up the sections.  */
++   lang_size_sections (NULL, ! RELAXATION_ENABLED);
++ 
++   /* See if anything special should be done now we know how big
++      everything is.  This is where relaxation is done.  */
++   ldemul_after_allocation ();
++ 
++   ldemul_finish ();
++ 
++   /* Make sure that the section addresses make sense.  */
++   if (command_line.check_section_addresses)
++     lang_check_section_addresses ();
++ 
++   lang_end ();
++   
++   ldwrite ();
++ 
++   lang_finish ();
++ 
++   if (! bfd_close (link_info.output_bfd))
++     einfo (_("%P%F:%s: final close failed on object-only output: %E\n"),
++         output_filename);
++ 
++   /* Read in the object-only file.  */
++   fd = open (output_filename, O_RDONLY | O_BINARY);
++   if (fd < 0)
++     {
++       bfd_set_error (bfd_error_system_call);
++       einfo (_("%P%F:%s: cannot open object-only output: %E"),
++           output_filename);
++     }
++ 
++   /* Get the object-only file size.  */
++   if (fstat (fd, &st) != 0)
++     {
++       bfd_set_error (bfd_error_system_call);
++       einfo (_("%P%F:%s: cannot stat object-only output: %E"),
++           output_filename);
++     }
++ 
++   size = st.st_size;
++   off = 0;
++   contents = (bfd_byte *) xmalloc (size);
++   while (off != size)
++     {
++       ssize_t got;
++ 
++       got = read (fd, contents + off, size - off);
++       if (got < 0)
++      {
++        bfd_set_error (bfd_error_system_call);
++        einfo (_("%P%F:%s: read failed on object-only output: %E"),
++               output_filename);
++      }
++ 
++       off += got;
++     }
++ 
++   close (fd);
++ 
++   /* Remove the temporary object-only file.  */ 
++   unlink (output_filename);
++ 
++   output_filename = saved_output_filename;
++ 
++   cmdline_add_object_only_section (contents, size);
++ 
++   free (contents);
++ }
++ 
++ /* Extract the object-only section.  */
++ 
++ static const char *
++ cmdline_extract_object_only_section (bfd *abfd)
++ {
++   const char *name = bfd_extract_object_only_section (abfd);
++ 
++   if (name == NULL)
++     einfo (_("%P%F: cannot extract object-only section from %B: %E"),
++         abfd);
++ 
++   /* It should be removed after it is done.  */
++   cmdline_list_append (&cmdline_temp_object_only_list,
++                     cmdline_is_file_enum, (void *) name);
++ 
++   return name;
++ }
++ 
++ /* Check and handle the object-only section.   */
++ 
++ void
++ cmdline_check_object_only_section (bfd *abfd, bfd_boolean lto)
++ {
++   const char *filename;
++ 
++   if (link_info.emitting_gnu_object_only
++       || abfd->format != bfd_object)
++     return;
++ 
++   if (lto)
++     {
++       /* For LTO link, we only need to extract object-only section
++       from the mixed object, add it to input, and put it on LTO
++       claimed output.  */
++       switch (abfd->lto_type)
++      {
++      default:
++        abort ();
++      case lto_mixed_object:
++        filename = cmdline_extract_object_only_section (abfd);
++        lang_add_input_file (filename,
++                             lang_input_file_is_file_enum, NULL);
++        break;
++      case lto_non_ir_object:
++      case lto_ir_object:
++        break;
++      }
++     }
++   else if (link_info.relocatable)
++     {
++       /* For non-LTO relocatable link, we need to append non-IR object
++       file and the object file in object-only section to the object
++       only list.  */
++       switch (abfd->lto_type)
++      {
++      default:
++        abort ();
++      case lto_mixed_object:
++        filename = cmdline_extract_object_only_section (abfd);
++        cmdline_object_only_list_append (cmdline_is_file_enum,
++                                        (void *) filename);
++        break;
++      case lto_non_ir_object:
++        cmdline_object_only_list_append (cmdline_is_bfd_enum, abfd);
++        break;
++      case lto_ir_object:
++        break;
++      }
++     }
++ }
++ 
++ /* Remove temporary object-only files.  */
++ 
++ void
++ cmdline_remove_object_only_files (void)
++ {
++   cmdline_union_type *c;
++ 
++ #ifdef ENABLE_PLUGINS
++   if (plugin_save_temps)
++     return;
++ #endif
++ 
++   c = cmdline_temp_object_only_list.head;
++   for (; c != NULL; c = c->header.next)
++     switch (c->header.type)
++       {
++       default:
++      abort ();
++       case cmdline_is_file_enum:
++      unlink (c->file.filename);
++      break;
++       }
++ }
++
++
++ 
+diff -cpr ../binutils-2.23.2.orig/ld/ldlang.h ld/ldlang.h
+*** ../binutils-2.23.2.orig/ld/ldlang.h        2013-05-14 16:39:36.861718097 +0100
+--- ld/ldlang.h        2013-05-14 16:40:07.053718934 +0100
+*************** extern lang_statement_list_type input_fi
+*** 488,494 ****
+  extern int lang_statement_iteration;
+  
+  extern void lang_init
+!   (void);
+  extern void lang_finish
+    (void);
+  extern lang_memory_region_type * lang_memory_region_lookup
+--- 488,494 ----
+  extern int lang_statement_iteration;
+  
+  extern void lang_init
+!   (bfd_boolean);
+  extern void lang_finish
+    (void);
+  extern lang_memory_region_type * lang_memory_region_lookup
+*************** ldlang_override_segment_assignment
+*** 664,667 ****
+--- 664,708 ----
+  extern void
+  lang_ld_feature (char *);
+  
++ typedef enum
++ {
++   cmdline_is_file_enum,
++   cmdline_is_bfd_enum
++ } cmdline_enum_type;
++ 
++ typedef struct cmdline_header_struct
++ {
++   union cmdline_union *next;
++   cmdline_enum_type type;
++ } cmdline_header_type;
++ 
++ typedef struct cmdline_file_struct
++ {
++   cmdline_header_type header;
++   const char *filename;
++ } cmdline_file_type;
++ 
++ typedef struct cmdline_bfd_struct
++ {
++   cmdline_header_type header;
++   bfd *abfd;
++ } cmdline_bfd_type;
++ 
++ typedef union cmdline_union
++ {
++   cmdline_header_type header;
++   cmdline_file_type file;
++   cmdline_bfd_type abfd;
++ } cmdline_union_type;
++ 
++ typedef struct cmdline_list
++ {
++   cmdline_union_type *head;
++   cmdline_union_type **tail;
++ } cmdline_list_type;
++ 
++ extern void cmdline_emit_object_only_section (void);
++ extern void cmdline_check_object_only_section (bfd *, bfd_boolean);
++ extern void cmdline_remove_object_only_files (void);
++ 
+  #endif
+diff -cpr ../binutils-2.23.2.orig/ld/ldlex.h ld/ldlex.h
+*** ../binutils-2.23.2.orig/ld/ldlex.h 2013-05-14 16:39:39.789718178 +0100
+--- ld/ldlex.h 2013-05-14 16:47:18.651730898 +0100
+*************** enum option_values
+*** 133,138 ****
+--- 133,139 ----
+  #ifdef ENABLE_PLUGINS
+    OPTION_PLUGIN,
+    OPTION_PLUGIN_OPT,
++   OPTION_PLUGIN_SAVE_TEMPS,
+  #endif /* ENABLE_PLUGINS */
+    OPTION_DEFAULT_SCRIPT,
+    OPTION_PRINT_OUTPUT_FORMAT,
+diff -cpr ../binutils-2.23.2.orig/ld/ldmain.c ld/ldmain.c
+*** ../binutils-2.23.2.orig/ld/ldmain.c        2013-05-14 16:39:36.862718097 +0100
+--- ld/ldmain.c        2013-05-14 16:40:07.055718934 +0100
+*************** main (int argc, char **argv)
+*** 219,224 ****
+--- 219,227 ----
+  
+    xatexit (ld_cleanup);
+  
++   /* Remove temporary object-only files.  */
++   xatexit (cmdline_remove_object_only_files);
++ 
+    /* Set up the sysroot directory.  */
+    ld_sysroot = get_sysroot (argc, argv);
+    if (*ld_sysroot)
+*************** main (int argc, char **argv)
+*** 295,301 ****
+    default_target = ldemul_choose_target (argc, argv);
+    config.maxpagesize = bfd_emul_get_maxpagesize (default_target);
+    config.commonpagesize = bfd_emul_get_commonpagesize (default_target);
+!   lang_init ();
+    ldemul_before_parse ();
+    lang_has_input_file = FALSE;
+    parse_args (argc, argv);
+--- 298,304 ----
+    default_target = ldemul_choose_target (argc, argv);
+    config.maxpagesize = bfd_emul_get_maxpagesize (default_target);
+    config.commonpagesize = bfd_emul_get_commonpagesize (default_target);
+!   lang_init (FALSE);
+    ldemul_before_parse ();
+    lang_has_input_file = FALSE;
+    parse_args (argc, argv);
+*************** main (int argc, char **argv)
+*** 310,343 ****
+  
+    ldemul_set_symbols ();
+  
+!   /* If we have not already opened and parsed a linker script,
+!      try the default script from command line first.  */
+!   if (saved_script_handle == NULL
+!       && command_line.default_script != NULL)
+!     {
+!       ldfile_open_command_file (command_line.default_script);
+!       parser_input = input_script;
+!       yyparse ();
+!     }
+! 
+!   /* If we have not already opened and parsed a linker script
+!      read the emulation's appropriate default script.  */
+!   if (saved_script_handle == NULL)
+!     {
+!       int isfile;
+!       char *s = ldemul_get_script (&isfile);
+! 
+!       if (isfile)
+!      ldfile_open_default_command_file (s);
+!       else
+!      {
+!        lex_string = s;
+!        lex_redirect (s, _("built in linker script"), 1);
+!      }
+!       parser_input = input_script;
+!       yyparse ();
+!       lex_string = NULL;
+!     }
+  
+    if (verbose)
+      {
+--- 313,319 ----
+  
+    ldemul_set_symbols ();
+  
+!   ld_parse_linker_script ();
+  
+    if (verbose)
+      {
+*************** main (int argc, char **argv)
+*** 444,449 ****
+--- 420,427 ----
+        if (! bfd_close (link_info.output_bfd))
+       einfo (_("%F%B: final close failed: %E\n"), link_info.output_bfd);
+  
++       link_info.output_bfd = NULL;
++ 
+        /* If the --force-exe-suffix is enabled, and we're making an
+        executable file and it doesn't end in .exe, copy it to one
+        which does.  */
+*************** main (int argc, char **argv)
+*** 490,495 ****
+--- 468,476 ----
+       }
+      }
+  
++   if (link_info.emit_gnu_object_only)
++     cmdline_emit_object_only_section ();
++ 
+    END_PROGRESS (program_name);
+  
+    if (config.stats)
+*************** add_archive_element (struct bfd_link_inf
+*** 779,785 ****
+--- 760,768 ----
+           }
+       }
+      }
++   else
+  #endif /* ENABLE_PLUGINS */
++     cmdline_check_object_only_section (input->the_bfd, FALSE);
+  
+    ldlang_add_file (input);
+  
+*************** warning_callback (struct bfd_link_info *
+*** 1152,1158 ****
+      einfo ("%P: %s%s\n", _("warning: "), warning);
+    else if (symbol == NULL)
+      einfo ("%B: %s%s\n", abfd, _("warning: "), warning);
+!   else
+      {
+        struct warning_callback_info cinfo;
+  
+--- 1135,1141 ----
+      einfo ("%P: %s%s\n", _("warning: "), warning);
+    else if (symbol == NULL)
+      einfo ("%B: %s%s\n", abfd, _("warning: "), warning);
+!   else if ((abfd->flags & BFD_PLUGIN) == 0)
+      {
+        struct warning_callback_info cinfo;
+  
+*************** notice (struct bfd_link_info *info,
+*** 1459,1461 ****
+--- 1442,1479 ----
+  
+    return TRUE;
+  }
++ 
++ /* Parse the linker script.   */
++ 
++ void
++ ld_parse_linker_script ()
++ {
++   /* If we have not already opened and parsed a linker script,
++      try the default script from command line first.  */
++   if (saved_script_handle == NULL
++       && command_line.default_script != NULL)
++     {
++       ldfile_open_command_file (command_line.default_script);
++       parser_input = input_script;
++       yyparse ();
++     }
++ 
++   /* If we have not already opened and parsed a linker script
++      read the emulation's appropriate default script.  */
++   if (saved_script_handle == NULL)
++     {
++       int isfile;
++       char *s = ldemul_get_script (&isfile);
++ 
++       if (isfile)
++      ldfile_open_default_command_file (s);
++       else
++      {
++        lex_string = s;
++        lex_redirect (s, _("built in linker script"), 1);
++      }
++       parser_input = input_script;
++       yyparse ();
++       lex_string = NULL;
++     }
++ }
+diff -cpr ../binutils-2.23.2.orig/ld/ldmain.h ld/ldmain.h
+*** ../binutils-2.23.2.orig/ld/ldmain.h        2013-05-14 16:39:39.810718179 +0100
+--- ld/ldmain.h        2013-05-14 16:40:07.055718934 +0100
+*************** extern void add_ysym (const char *);
+*** 43,46 ****
+--- 43,48 ----
+  extern void add_ignoresym (struct bfd_link_info *, const char *);
+  extern void add_keepsyms_file (const char *);
+  
++ extern void ld_parse_linker_script (void);
++ 
+  #endif
+diff -cpr ../binutils-2.23.2.orig/ld/lexsup.c ld/lexsup.c
+*** ../binutils-2.23.2.orig/ld/lexsup.c        2013-05-14 16:39:36.709718093 +0100
+--- ld/lexsup.c        2013-05-14 16:40:07.058718934 +0100
+*************** static const struct ld_option ld_options
+*** 168,173 ****
+--- 168,176 ----
+      '\0', N_("PLUGIN"), N_("Load named plugin"), ONE_DASH },
+    { {"plugin-opt", required_argument, NULL, OPTION_PLUGIN_OPT},
+      '\0', N_("ARG"), N_("Send arg to last-loaded plugin"), ONE_DASH },
++   { {"plugin-save-temps", no_argument, NULL, OPTION_PLUGIN_SAVE_TEMPS},
++     '\0', NULL, N_("Store plugin intermediate files permanently"),
++     ONE_DASH },
+    { {"flto", optional_argument, NULL, OPTION_IGNORE},
+      '\0', NULL, N_("Ignored for GCC LTO option compatibility"),
+      ONE_DASH },
+*************** parse_args (unsigned argc, char **argv)
+*** 958,963 ****
+--- 961,969 ----
+         if (plugin_opt_plugin_arg (optarg))
+           einfo(_("%P%F: bad -plugin-opt option\n"));
+         break;
++      case OPTION_PLUGIN_SAVE_TEMPS:
++        plugin_save_temps = TRUE;
++        break;
+  #endif /* ENABLE_PLUGINS */
+       case 'q':
+         link_info.emitrelocations = TRUE;
+diff -cpr ../binutils-2.23.2.orig/ld/plugin.c ld/plugin.c
+*** ../binutils-2.23.2.orig/ld/plugin.c        2013-05-14 16:39:37.435718113 +0100
+--- ld/plugin.c        2013-05-14 16:48:59.039733681 +0100
+***************
+*** 39,44 ****
+--- 39,47 ----
+  /* Report plugin symbols.  */
+  bfd_boolean report_plugin_symbols;
+  
++ /* Store plugin intermediate files permanently.  */
++ bfd_boolean plugin_save_temps;
++ 
+  /* The suffix to append to the name of the real (claimed) object file
+     when generating a dummy BFD to hold the IR symbols sent from the
+     plugin.  For cosmetic use only; appears in maps, crefs etc.  */
+*************** plugin_opt_plugin_arg (const char *arg)
+*** 217,222 ****
+--- 220,236 ----
+    if (!last_plugin)
+      return set_plugin_error (_("<no plugin>"));
+  
++   /* Ignore -pass-through= from GCC driver.  */
++   if (*arg == '-')
++     {
++       const char *p;
++       for (p = arg + 1; p; p++)
++      if (*p != '-')
++        break;
++       if (strncmp (p, "pass-through=", 13) == 0)
++      return 0;
++     }
++ 
+    newarg = xmalloc (sizeof *newarg);
+    newarg->arg = arg;
+    newarg->next = NULL;
+*************** plugin_maybe_claim (struct ld_plugin_inp
+*** 876,881 ****
+--- 890,898 ----
+    close (file->fd);
+    if (claimed)
+      {
++       /* Check object only section.  */
++       cmdline_check_object_only_section (entry->the_bfd, TRUE);
++ 
+        /* Discard the real file's BFD and substitute the dummy one.  */
+  
+        /* BFD archive handling caches elements so we can't call
+*************** plugin_call_cleanup (void)
+*** 929,942 ****
+      {
+        if (curplug->cleanup_handler && !curplug->cleanup_done)
+       {
+!        enum ld_plugin_status rv;
+!        curplug->cleanup_done = TRUE;
+!        called_plugin = curplug;
+!        rv = (*curplug->cleanup_handler) ();
+!        called_plugin = NULL;
+!        if (rv != LDPS_OK)
+!          info_msg (_("%P: %s: error in plugin cleanup: %d (ignored)\n"),
+!                    curplug->name, rv);
+         dlclose (curplug->dlhandle);
+       }
+        curplug = curplug->next;
+--- 946,962 ----
+      {
+        if (curplug->cleanup_handler && !curplug->cleanup_done)
+       {
+!        if (!plugin_save_temps)
+!          {
+!            enum ld_plugin_status rv;
+!            curplug->cleanup_done = TRUE;
+!            called_plugin = curplug;
+!            rv = (*curplug->cleanup_handler) ();
+!            called_plugin = NULL;
+!            if (rv != LDPS_OK)
+!              info_msg (_("%P: %s: error in plugin cleanup: %d (ignored)\n"),
+!                        curplug->name, rv);
+!          }
+         dlclose (curplug->dlhandle);
+       }
+        curplug = curplug->next;
+diff -cpr ../binutils-2.23.2.orig/ld/plugin.h ld/plugin.h
+*** ../binutils-2.23.2.orig/ld/plugin.h        2013-05-14 16:39:39.705718176 +0100
+--- ld/plugin.h        2013-05-14 16:40:07.059718934 +0100
+***************
+*** 24,29 ****
+--- 24,32 ----
+  /* Report plugin symbols.  */
+  extern bfd_boolean report_plugin_symbols;
+  
++ /* Store plugin intermediate files permanently.  */
++ extern bfd_boolean plugin_save_temps;
++ 
+  /* Set at all symbols read time, to avoid recursively offering the plugin
+     its own newly-added input files and libs to claim.  */
+  extern bfd_boolean no_more_claiming;
+diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/armbpabi.sc ld/scripttempl/armbpabi.sc
+*** ../binutils-2.23.2.orig/ld/scripttempl/armbpabi.sc 2013-05-14 16:39:39.758718177 +0100
+--- ld/scripttempl/armbpabi.sc 2013-05-14 16:54:15.657742458 +0100
+*************** INTERP=".interp       0 : { *(.interp) }
+*** 30,36 ****
+  PLT=".plt          ${RELOCATING-0} : { *(.plt) }"
+  RODATA=".rodata       ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
+  DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro .data.rel.ro.*) }"
+! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink)  *(.gnu.lto_*) }"
+  if test -z "${NO_SMALL_DATA}"; then
+    SBSS=".sbss         ${RELOCATING-0} :
+    {
+--- 30,36 ----
+  PLT=".plt          ${RELOCATING-0} : { *(.plt) }"
+  RODATA=".rodata       ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
+  DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro .data.rel.ro.*) }"
+! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }"
+  if test -z "${NO_SMALL_DATA}"; then
+    SBSS=".sbss         ${RELOCATING-0} :
+    {
+diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/elf32sh-symbian.sc ld/scripttempl/elf32sh-symbian.sc
+*** ../binutils-2.23.2.orig/ld/scripttempl/elf32sh-symbian.sc  2013-05-14 16:39:39.759718177 +0100
+--- ld/scripttempl/elf32sh-symbian.sc  2013-05-14 16:40:07.062718934 +0100
+*************** fi
+*** 83,89 ****
+      PLT=".plt            : { *(.plt) } :dynamic :dyn"
+  DYNAMIC=".dynamic        : { *(.dynamic) } :dynamic :dyn"
+   RODATA=".rodata    ALIGN(4) : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
+! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.directive)  *(.gnu.lto_*) }"
+  test -z "$GOT" && GOT=".got          ${RELOCATING-0} : { *(.got.plt) *(.got) } :dynamic :dyn"
+  INIT_ARRAY=".init_array   ${RELOCATING-0} :
+    {
+--- 83,89 ----
+      PLT=".plt            : { *(.plt) } :dynamic :dyn"
+  DYNAMIC=".dynamic        : { *(.dynamic) } :dynamic :dyn"
+   RODATA=".rodata    ALIGN(4) : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
+! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.directive)  *(.gnu.lto_*) *(.gnu_object_only) }"
+  test -z "$GOT" && GOT=".got          ${RELOCATING-0} : { *(.got.plt) *(.got) } :dynamic :dyn"
+  INIT_ARRAY=".init_array   ${RELOCATING-0} :
+    {
+diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/elf64hppa.sc ld/scripttempl/elf64hppa.sc
+*** ../binutils-2.23.2.orig/ld/scripttempl/elf64hppa.sc        2013-05-14 16:39:39.733718177 +0100
+--- ld/scripttempl/elf64hppa.sc        2013-05-14 16:55:16.076744133 +0100
+*************** fi
+*** 127,133 ****
+  DYNAMIC=".dynamic      ${RELOCATING-0} : { *(.dynamic) }"
+  RODATA=".rodata       ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
+  DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }"
+! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink)  *(.gnu.lto_*) }"
+  if test -z "${NO_SMALL_DATA}"; then
+    SBSS=".sbss         ${RELOCATING-0} :
+    {
+--- 127,133 ----
+  DYNAMIC=".dynamic      ${RELOCATING-0} : { *(.dynamic) }"
+  RODATA=".rodata       ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
+  DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }"
+! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }"
+  if test -z "${NO_SMALL_DATA}"; then
+    SBSS=".sbss         ${RELOCATING-0} :
+    {
+diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/elf.sc ld/scripttempl/elf.sc
+*** ../binutils-2.23.2.orig/ld/scripttempl/elf.sc      2013-05-14 16:39:39.755718177 +0100
+--- ld/scripttempl/elf.sc      2013-05-14 16:54:44.618743261 +0100
+*************** RELA_IPLT=".rela.iplt    ${RELOCATING-0}
+*** 158,164 ****
+  DYNAMIC=".dynamic      ${RELOCATING-0} : { *(.dynamic) }"
+  RODATA=".${RODATA_NAME}       ${RELOCATING-0} : { *(.${RODATA_NAME}${RELOCATING+ .${RODATA_NAME}.* .gnu.linkonce.r.*}) }"
+  DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }"
+! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }"
+  if test -z "${NO_SMALL_DATA}"; then
+    SBSS=".${SBSS_NAME}         ${RELOCATING-0} :
+    {
+--- 158,164 ----
+  DYNAMIC=".dynamic      ${RELOCATING-0} : { *(.dynamic) }"
+  RODATA=".${RODATA_NAME}       ${RELOCATING-0} : { *(.${RODATA_NAME}${RELOCATING+ .${RODATA_NAME}.* .gnu.linkonce.r.*}) }"
+  DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }"
+! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }"
+  if test -z "${NO_SMALL_DATA}"; then
+    SBSS=".${SBSS_NAME}         ${RELOCATING-0} :
+    {
+diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/elfxtensa.sc ld/scripttempl/elfxtensa.sc
+*** ../binutils-2.23.2.orig/ld/scripttempl/elfxtensa.sc        2013-05-14 16:39:39.754718177 +0100
+--- ld/scripttempl/elfxtensa.sc        2013-05-14 16:55:44.908744932 +0100
+*************** fi
+*** 140,146 ****
+  DYNAMIC=".dynamic      ${RELOCATING-0} : { *(.dynamic) }"
+  RODATA=".rodata       ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
+  DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }"
+! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink)  *(.gnu.lto_*) }"
+  INIT_LIT=".init.literal 0 : { *(.init.literal)       }"
+  INIT=".init         0 : { *(.init)           }"
+  FINI_LIT=".fini.literal 0 : { *(.fini.literal)       }"
+--- 140,146 ----
+  DYNAMIC=".dynamic      ${RELOCATING-0} : { *(.dynamic) }"
+  RODATA=".rodata       ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
+  DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }"
+! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }"
+  INIT_LIT=".init.literal 0 : { *(.init.literal)       }"
+  INIT=".init         0 : { *(.init)           }"
+  FINI_LIT=".fini.literal 0 : { *(.fini.literal)       }"
+diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/mep.sc ld/scripttempl/mep.sc
+*** ../binutils-2.23.2.orig/ld/scripttempl/mep.sc      2013-05-14 16:39:39.755718177 +0100
+--- ld/scripttempl/mep.sc      2013-05-14 16:56:08.605745589 +0100
+*************** fi
+*** 114,120 ****
+  DYNAMIC=".dynamic      ${RELOCATING-0} : { *(.dynamic) }"
+  RODATA=".rodata       ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
+  DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro .data.rel.ro.*) }"
+! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink)  *(.gnu.lto_*) }"
+  if test -z "${NO_SMALL_DATA}"; then
+    SBSS=".sbss         ${RELOCATING-0} :
+    {
+--- 114,120 ----
+  DYNAMIC=".dynamic      ${RELOCATING-0} : { *(.dynamic) }"
+  RODATA=".rodata       ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
+  DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro .data.rel.ro.*) }"
+! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }"
+  if test -z "${NO_SMALL_DATA}"; then
+    SBSS=".sbss         ${RELOCATING-0} :
+    {
+diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/pep.sc ld/scripttempl/pep.sc
+*** ../binutils-2.23.2.orig/ld/scripttempl/pep.sc      2013-05-14 16:39:39.755718177 +0100
+--- ld/scripttempl/pep.sc      2013-05-14 16:40:07.064718934 +0100
+*************** SECTIONS
+*** 154,159 ****
+--- 154,160 ----
+      *(.drectve)
+      ${RELOCATING+ *(.note.GNU-stack)}
+      ${RELOCATING+ *(.gnu.lto_*)}
++     ${RELOCATING+ *(.gnu_object_only)}
+    }
+  
+    .idata ${RELOCATING+BLOCK(__section_alignment__)} :
+diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/pe.sc ld/scripttempl/pe.sc
+*** ../binutils-2.23.2.orig/ld/scripttempl/pe.sc       2013-05-14 16:39:39.758718177 +0100
+--- ld/scripttempl/pe.sc       2013-05-14 16:40:07.064718934 +0100
+*************** SECTIONS
+*** 148,153 ****
+--- 148,154 ----
+      *(.drectve)
+      ${RELOCATING+ *(.note.GNU-stack)}
+      ${RELOCATING+ *(.gnu.lto_*)}
++     ${RELOCATING+ *(.gnu_object_only)}
+    }
+  
+    .idata ${RELOCATING+BLOCK(__section_alignment__)} :
diff --git a/binutils/patches/binutils-2.23.52.0.1-addr2line-dynsymtab.patch0 b/binutils/patches/binutils-2.23.52.0.1-addr2line-dynsymtab.patch0
new file mode 100644 (file)
index 0000000..68f0470
--- /dev/null
@@ -0,0 +1,122 @@
+*** ../binutils-2.23.52.0.1.orig/bfd/opncls.c  2013-03-14 11:25:30.338306122 +0000
+--- bfd/opncls.c       2013-03-14 12:20:21.686397360 +0000
+*************** find_separate_debug_file (bfd *abfd, con
+*** 1297,1302 ****
+--- 1297,1304 ----
+        bfd_malloc (strlen (debug_file_directory) + 1
+                    + (canon_dirlen > dirlen ? canon_dirlen : dirlen)
+                    + strlen (".debug/")
++ #define FEDORA_LIB_DEBUG_DIR "/usr/lib/debug/"
++                + strlen (FEDORA_LIB_DEBUG_DIR) + strlen ("usr/")
+                    + strlen (base)
+                    + 1);
+    if (debugfile == NULL)
+*************** find_separate_debug_file (bfd *abfd, con
+*** 1332,1337 ****
+--- 1334,1359 ----
+    if (check_func (debugfile, crc32))
+      goto found;
+  
++   /* Then try in the global debug dir for Fedora libraries.  */
++   sprintf (debugfile, "%s%s%s", FEDORA_LIB_DEBUG_DIR, dir, base);
++   if (separate_debug_file_exists (debugfile, crc32))
++     {
++       free (base);
++       free (dir);
++       free (canon_dir);
++       return debugfile;
++     }
++ 
++   /* Then try in the usr subdirectory of the global debug dir for Fedora libraries.  */
++   sprintf (debugfile, "%s/usr%s%s", FEDORA_LIB_DEBUG_DIR, dir, base);
++   if (separate_debug_file_exists (debugfile, crc32))
++     {
++       free (base);
++       free (dir);
++       free (canon_dir);
++       return debugfile;
++     }
++   
+    /* Then try in the global debugfile directory.  */
+    strcpy (debugfile, debug_file_directory);
+    dirlen = strlen (debug_file_directory) - 1;
+*** ../binutils-2.23.52.0.1.orig/bfd/dwarf2.c  2013-03-14 11:25:30.608306129 +0000
+--- bfd/dwarf2.c       2013-03-14 13:14:18.102487075 +0000
+*************** find_line (bfd *abfd,
+*** 3339,3346 ****
+--- 3339,3349 ----
+    struct dwarf2_debug *stash;
+    /* What address are we looking for?  */
+    bfd_vma addr;
++   /* What is the address without relocation ?  */
++   bfd_vma unrelocated_addr;
+    struct comp_unit* each;
+    bfd_vma found = FALSE;
++   bfd_vma possible_find = FALSE;
+    bfd_boolean do_line;
+  
+    *filename_ptr = NULL;
+*************** find_line (bfd *abfd,
+*** 3380,3385 ****
+--- 3383,3394 ----
+    else
+      abort ();
+  
++   /* If we are dealing with PIC code then the debug information
++      will be based on unrelocated addresses.  Since we cannot be
++      sure if this is a PIC address we test both with and without
++      relocation.  */
++   unrelocated_addr = addr;
++ 
+    if (section->output_section)
+      addr += section->output_section->vma + section->output_offset;
+    else
+*************** find_line (bfd *abfd,
+*** 3442,3447 ****
+--- 3451,3466 ----
+                                                  stash));
+         if (found)
+           goto done;
++ 
++        if (! possible_find)
++          possible_find = ((each->arange.high == 0
++                            || comp_unit_contains_address (each, unrelocated_addr))
++                           && comp_unit_find_nearest_line (each, unrelocated_addr,
++                                                           filename_ptr,
++                                                           functionname_ptr,
++                                                           linenumber_ptr,
++                                                           discriminator_ptr,
++                                                           stash));
+       }
+      }
+  
+*************** find_line (bfd *abfd,
+*** 3535,3540 ****
+--- 3554,3569 ----
+                                                    discriminator_ptr,
+                                                    stash));
+  
++        if (! found && ! do_line && ! possible_find)
++          possible_find = ((each->arange.high == 0
++                            || comp_unit_contains_address (each, unrelocated_addr))
++                           && comp_unit_find_nearest_line (each, unrelocated_addr,
++                                                           filename_ptr,
++                                                           functionname_ptr,
++                                                           linenumber_ptr,
++                                                           discriminator_ptr,
++                                                           stash));
++ 
+         if ((bfd_vma) (stash->info_ptr - stash->sec_info_ptr)
+             == stash->sec->size)
+           {
+*************** find_line (bfd *abfd,
+*** 3552,3557 ****
+--- 3581,3588 ----
+    if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
+      unset_sections (stash);
+  
++   if (! found)
++     return possible_find;
+    return found;
+  }
+  
diff --git a/binutils/patches/binutils-2.23.52.0.1-as-doc-texinfo-fixes.patch0 b/binutils/patches/binutils-2.23.52.0.1-as-doc-texinfo-fixes.patch0
deleted file mode 100644 (file)
index d0b657f..0000000
+++ /dev/null
@@ -1,279 +0,0 @@
-diff -cp ../binutils-2.23.52.0.1.orig/gas/doc/c-arc.texi gas/doc/c-arc.texi
-*** ../binutils-2.23.52.0.1.orig/gas/doc/c-arc.texi    2013-03-04 08:25:32.051931944 +0000
---- gas/doc/c-arc.texi 2013-03-04 08:26:19.234930452 +0000
-*************** The extension instructions are not macro
-*** 220,226 ****
-  encodings for use of these instructions according to the specification
-  by the user.  The parameters are:
-  
-! @table @bullet
-  @item @var{name}
-  Name of the extension instruction
-  
---- 220,226 ----
-  encodings for use of these instructions according to the specification
-  by the user.  The parameters are:
-  
-! @table @code
-  @item @var{name}
-  Name of the extension instruction
-  
-diff -cp ../binutils-2.23.52.0.1.orig/gas/doc/c-arm.texi gas/doc/c-arm.texi
-*** ../binutils-2.23.52.0.1.orig/gas/doc/c-arm.texi    2013-03-04 08:25:32.039931945 +0000
---- gas/doc/c-arm.texi 2013-03-04 08:27:37.462927978 +0000
-*************** ARM and THUMB instructions had their own
-*** 390,418 ****
-  @code{unified} syntax, which can be selected via the @code{.syntax}
-  directive, and has the following main features:
-  
-! @table @bullet
-! @item
-  Immediate operands do not require a @code{#} prefix.
-  
-! @item
-  The @code{IT} instruction may appear, and if it does it is validated
-  against subsequent conditional affixes.  In ARM mode it does not
-  generate machine code, in THUMB mode it does.
-  
-! @item
-  For ARM instructions the conditional affixes always appear at the end
-  of the instruction.  For THUMB instructions conditional affixes can be
-  used, but only inside the scope of an @code{IT} instruction.
-  
-! @item
-  All of the instructions new to the V6T2 architecture (and later) are
-  available.  (Only a few such instructions can be written in the
-  @code{divided} syntax).
-  
-! @item
-  The @code{.N} and @code{.W} suffixes are recognized and honored.
-  
-! @item
-  All instructions set the flags if and only if they have an @code{s}
-  affix.
-  @end table
---- 390,418 ----
-  @code{unified} syntax, which can be selected via the @code{.syntax}
-  directive, and has the following main features:
-  
-! @table @code
-! @item 1
-  Immediate operands do not require a @code{#} prefix.
-  
-! @item 2
-  The @code{IT} instruction may appear, and if it does it is validated
-  against subsequent conditional affixes.  In ARM mode it does not
-  generate machine code, in THUMB mode it does.
-  
-! @item 3
-  For ARM instructions the conditional affixes always appear at the end
-  of the instruction.  For THUMB instructions conditional affixes can be
-  used, but only inside the scope of an @code{IT} instruction.
-  
-! @item 4
-  All of the instructions new to the V6T2 architecture (and later) are
-  available.  (Only a few such instructions can be written in the
-  @code{divided} syntax).
-  
-! @item 5
-  The @code{.N} and @code{.W} suffixes are recognized and honored.
-  
-! @item 6
-  All instructions set the flags if and only if they have an @code{s}
-  affix.
-  @end table
-*************** Either @samp{#} or @samp{$} can be used
-*** 451,478 ****
-  @cindex register names, ARM
-  *TODO* Explain about ARM register naming, and the predefined names.
-  
-- @node ARM-Neon-Alignment
-- @subsection NEON Alignment Specifiers
-- 
-- @cindex alignment for NEON instructions
-- Some NEON load/store instructions allow an optional address
-- alignment qualifier.
-- The ARM documentation specifies that this is indicated by
-- @samp{@@ @var{align}}. However GAS already interprets
-- the @samp{@@} character as a "line comment" start,
-- so @samp{: @var{align}} is used instead.  For example:
-- 
-- @smallexample
--         vld1.8 @{q0@}, [r0, :128]
-- @end smallexample
-- 
-- @node ARM Floating Point
-- @section Floating Point
-- 
-- @cindex floating point, ARM (@sc{ieee})
-- @cindex ARM floating point (@sc{ieee})
-- The ARM family uses @sc{ieee} floating-point numbers.
-- 
-  @node ARM-Relocations
-  @subsection ARM relocation generation
-  
---- 451,456 ----
-*************** respectively.  For example to load the 3
-*** 519,524 ****
---- 497,524 ----
-          MOVT r0, #:upper16:foo
-  @end smallexample
-  
-+ @node ARM-Neon-Alignment
-+ @subsection NEON Alignment Specifiers
-+ 
-+ @cindex alignment for NEON instructions
-+ Some NEON load/store instructions allow an optional address
-+ alignment qualifier.
-+ The ARM documentation specifies that this is indicated by
-+ @samp{@@ @var{align}}. However GAS already interprets
-+ the @samp{@@} character as a "line comment" start,
-+ so @samp{: @var{align}} is used instead.  For example:
-+ 
-+ @smallexample
-+         vld1.8 @{q0@}, [r0, :128]
-+ @end smallexample
-+ 
-+ @node ARM Floating Point
-+ @section Floating Point
-+ 
-+ @cindex floating point, ARM (@sc{ieee})
-+ @cindex ARM floating point (@sc{ieee})
-+ The ARM family uses @sc{ieee} floating-point numbers.
-+ 
-  @node ARM Directives
-  @section ARM Machine Directives
-  
-diff -cp ../binutils-2.23.52.0.1.orig/gas/doc/c-cr16.texi gas/doc/c-cr16.texi
-*** ../binutils-2.23.52.0.1.orig/gas/doc/c-cr16.texi   2013-03-04 08:25:32.086931943 +0000
---- gas/doc/c-cr16.texi        2013-03-04 08:28:09.304926971 +0000
-*************** Operand expression type qualifier is an
-*** 44,69 ****
-  CR16 target operand qualifiers and its size (in bits):
-  
-  @table @samp
-! @item Immediate Operand
-! - s ---- 4 bits
-! @item
-! - m ---- 16 bits, for movb and movw instructions.
-! @item
-! - m ---- 20 bits, movd instructions.
-! @item
-! - l ---- 32 bits
-! 
-! @item Absolute Operand
-! - s ---- Illegal specifier for this operand.
-! @item
-! - m ---- 20 bits, movd instructions.
-! 
-! @item Displacement Operand
-! - s ---- 8 bits
-! @item
-! - m ---- 16 bits
-! @item
-! - l ---- 24 bits
-  @end table
-  
-  For example:
---- 44,76 ----
-  CR16 target operand qualifiers and its size (in bits):
-  
-  @table @samp
-! @item Immediate Operand: s
-! 4 bits.
-! 
-! @item Immediate Operand: m
-! 16 bits, for movb and movw instructions.
-! 
-! @item Immediate Operand: m
-! 20 bits, movd instructions.
-! 
-! @item Immediate Operand: l
-! 32 bits.
-! 
-! @item Absolute Operand: s
-! Illegal specifier for this operand.
-! 
-! @item Absolute Operand: m
-! 20 bits, movd instructions.
-! 
-! @item Displacement Operand: s
-! 8 bits.
-! 
-! @item Displacement Operand: m
-! 16 bits.
-! 
-! @item Displacement Operand: l
-! 24 bits.
-! 
-  @end table
-  
-  For example:
-diff -cp ../binutils-2.23.52.0.1.orig/gas/doc/c-tic54x.texi gas/doc/c-tic54x.texi
-*** ../binutils-2.23.52.0.1.orig/gas/doc/c-tic54x.texi 2013-03-04 08:25:32.035931945 +0000
---- gas/doc/c-tic54x.texi      2013-03-04 08:28:38.186926057 +0000
-*************** In this example, x is replaced with SYM2
-*** 109,115 ****
-  is replaced with x.  At this point, x has already been encountered
-  and the substitution stops.
-  
-! @smallexample @code
-   .asg   "x",SYM1
-   .asg   "SYM1",SYM2
-   .asg   "SYM2",x
---- 109,115 ----
-  is replaced with x.  At this point, x has already been encountered
-  and the substitution stops.
-  
-! @smallexample
-   .asg   "x",SYM1
-   .asg   "SYM1",SYM2
-   .asg   "SYM2",x
-*************** Substitution may be forced in situations
-*** 126,139 ****
-  ambiguous by placing colons on either side of the subsym.  The following
-  code:
-  
-! @smallexample @code
-   .eval  "10",x
-  LAB:X:  add     #x, a
-  @end smallexample
-  
-  When assembled becomes:
-  
-! @smallexample @code
-  LAB10  add     #10, a
-  @end smallexample
-  
---- 126,139 ----
-  ambiguous by placing colons on either side of the subsym.  The following
-  code:
-  
-! @smallexample
-   .eval  "10",x
-  LAB:X:  add     #x, a
-  @end smallexample
-  
-  When assembled becomes:
-  
-! @smallexample
-  LAB10  add     #10, a
-  @end smallexample
-  
-*************** The @code{LDX} pseudo-op is provided for
-*** 309,315 ****
-  of a label or address.  For example, if an address @code{_label} resides
-  in extended program memory, the value of @code{_label} may be loaded as
-  follows:
-! @smallexample @code
-   ldx     #_label,16,a    ; loads extended bits of _label
-   or      #_label,a       ; loads lower 16 bits of _label
-   bacc    a               ; full address is in accumulator A
---- 309,315 ----
-  of a label or address.  For example, if an address @code{_label} resides
-  in extended program memory, the value of @code{_label} may be loaded as
-  follows:
-! @smallexample
-   ldx     #_label,16,a    ; loads extended bits of _label
-   or      #_label,a       ; loads lower 16 bits of _label
-   bacc    a               ; full address is in accumulator A
diff --git a/binutils/patches/binutils-2.24-DW_FORM_ref_addr.patch0 b/binutils/patches/binutils-2.24-DW_FORM_ref_addr.patch0
new file mode 100644 (file)
index 0000000..92ef150
--- /dev/null
@@ -0,0 +1,44 @@
+*** ../binutils-2.24.orig/bfd/dwarf2.c 2014-01-28 11:58:02.072737296 +0000
+--- bfd/dwarf2.c       2014-01-28 11:59:38.575739971 +0000
+*************** find_abstract_instance_name (struct comp
+*** 2126,2131 ****
+--- 2126,2153 ----
+       abort ();
+  
+        info_ptr = unit->sec_info_ptr + die_ref;
++ 
++       /* Now find the CU containing this pointer.  */
++       if (info_ptr >= unit->info_ptr_unit && info_ptr < unit->end_ptr)
++      ;
++       else
++      {
++        /* Check other CUs to see if they contain the abbrev.  */
++        struct comp_unit * u;
++ 
++        for (u = unit->prev_unit; u != NULL; u = u->prev_unit)
++          if (info_ptr >= u->info_ptr_unit && info_ptr < u->end_ptr)
++            break;
++ 
++        if (u == NULL)
++          for (u = unit->next_unit; u != NULL; u = u->next_unit)
++            if (info_ptr >= u->info_ptr_unit && info_ptr < u->end_ptr)
++              break;
++ 
++        if (u)
++          unit = u;
++        /* else FIXME: What do we do now ?  */
++      }
+      }
+    else if (attr_ptr->form == DW_FORM_GNU_ref_alt)
+      {
+*************** find_abstract_instance_name (struct comp
+*** 2137,2142 ****
+--- 2159,2166 ----
+         bfd_set_error (bfd_error_bad_value);
+         return name;
+       }
++       /* FIXME: Do we need to locate the correct CU, in a similar
++       fashion to the code in the DW_FORM_ref_addr case above ?  */
+      }
+    else
+      info_ptr = unit->info_ptr_unit + die_ref;
diff --git a/binutils/patches/binutils-2.24-aarch64-fix-final_link_relocate.patch b/binutils/patches/binutils-2.24-aarch64-fix-final_link_relocate.patch
new file mode 100644 (file)
index 0000000..8c2d37b
--- /dev/null
@@ -0,0 +1,54 @@
+commit f44a1f8e513b37bcc52ba9ea0c172c3e94852756
+Author: Christophe Lyon <christophe.lyon@st.com>
+Date:   Tue Jan 14 15:53:50 2014 +0100
+
+    2014-01-14  Michael Hudson-Doyle  <michael.hudson@linaro.org>
+           Kugan Vivekanandarajah  <kugan.vivekanandarajah@linaro.org>
+    
+       bfd/
+       * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Use correct
+       offset while calculating relocation address.
+       (elfNN_aarch64_create_small_pltn_entry): Likewise.
+       (elfNN_aarch64_init_small_plt0_entry): Likewise.
+
+--- a/bfd/elfnn-aarch64.c
++++ b/bfd/elfnn-aarch64.c
+@@ -3844,7 +3844,7 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
+       value = (symbol_got_offset (input_bfd, h, r_symndx)
+              + globals->root.sgot->output_section->vma
+-             + globals->root.sgot->output_section->output_offset);
++             + globals->root.sgot->output_offset);
+       value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value,
+                                                  0, weak_undef_p);
+@@ -3873,10 +3873,9 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
+     case BFD_RELOC_AARCH64_TLSDESC_LDR:
+       if (globals->root.sgot == NULL)
+       return bfd_reloc_notsupported;
+-
+       value = (symbol_tlsdesc_got_offset (input_bfd, h, r_symndx)
+              + globals->root.sgotplt->output_section->vma
+-             + globals->root.sgotplt->output_section->output_offset
++             + globals->root.sgotplt->output_offset
+              + globals->sgotplt_jump_table_size);
+       value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value,
+@@ -6627,7 +6626,7 @@ elfNN_aarch64_create_small_pltn_entry (struct elf_link_hash_entry *h,
+   plt_entry = plt->contents + h->plt.offset;
+   plt_entry_address = plt->output_section->vma
+-    + plt->output_section->output_offset + h->plt.offset;
++    + plt->output_offset + h->plt.offset;
+   gotplt_entry_address = gotplt->output_section->vma +
+     gotplt->output_offset + got_offset;
+@@ -6934,7 +6933,7 @@ elfNN_aarch64_init_small_plt0_entry (bfd *output_bfd ATTRIBUTE_UNUSED,
+                 + GOT_ENTRY_SIZE * 2);
+   plt_base = htab->root.splt->output_section->vma +
+-    htab->root.splt->output_section->output_offset;
++    htab->root.splt->output_offset;
+   /* Fill in the top 21 bits for this: ADRP x16, PLT_GOT + n * 8.
+      ADRP:   ((PG(S+A)-PG(P)) >> 12) & 0x1fffff */
diff --git a/binutils/patches/binutils-2.24-aarch64-fix-gotplt-offset-ifunc.patch b/binutils/patches/binutils-2.24-aarch64-fix-gotplt-offset-ifunc.patch
new file mode 100644 (file)
index 0000000..64a1d9c
--- /dev/null
@@ -0,0 +1,103 @@
+commit 67428c4aa56d4183d0f531e0d752040745a94423
+Author: Will Newton <will.newton@linaro.org>
+Date:   Mon Nov 25 11:07:07 2013 +0000
+
+    bfd/elfnn-aarch64.c: Fix miscalculation of GOTPLT offset for ifunc syms.
+    
+    The .got.plt header size was not being correctly taken into account
+    when calculating the offset for relocations against ifunc symbols.
+    
+    bfd/ChangeLog:
+    
+    2013-11-26  Will Newton  <will.newton@linaro.org>
+    
+       * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Ensure
+       PLT_INDEX is calculated using correct header size.
+    
+    ld/testsuite/ChangeLog:
+    
+    2013-11-26  Will Newton  <will.newton@linaro.org>
+    
+       * ld-aarch64/aarch64-elf.exp: Add ifunc-21 test.
+       * ld-aarch64/ifunc-21.d: New file.
+       * ld-aarch64/ifunc-21.s: Likewise.
+
+diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
+index 6bc414e..3cd3a18 100644
+--- a/bfd/elfnn-aarch64.c
++++ b/bfd/elfnn-aarch64.c
+@@ -3589,7 +3589,8 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
+             if (globals->root.splt != NULL)
+               {
+-                plt_index = h->plt.offset / globals->plt_entry_size - 1;
++                plt_index = ((h->plt.offset - globals->plt_header_size) /
++                             globals->plt_entry_size);
+                 off = (plt_index + 3) * GOT_ENTRY_SIZE;
+                 base_got = globals->root.sgotplt;
+               }
+diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp
+index 5c150dd..a6b3ea2 100644
+--- a/ld/testsuite/ld-aarch64/aarch64-elf.exp
++++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp
+@@ -155,3 +155,4 @@ run_dump_test "ifunc-18b"
+ run_dump_test "ifunc-19a"
+ run_dump_test "ifunc-19b"
+ run_dump_test "ifunc-20"
++run_dump_test "ifunc-21"
+diff --git a/ld/testsuite/ld-aarch64/ifunc-21.d b/ld/testsuite/ld-aarch64/ifunc-21.d
+new file mode 100644
+index 0000000..fa139b2
+--- /dev/null
++++ b/ld/testsuite/ld-aarch64/ifunc-21.d
+@@ -0,0 +1,31 @@
++#source: ifunc-21.s
++#ld: -shared -z nocombreloc
++#objdump: -d -s -j .got.plt -j .text
++#target: aarch64*-*-*
++
++# Ensure the .got.plt slot used is correct
++
++.*:     file format elf64-(little|big)aarch64
++
++Contents of section .text:
++ 02a0 .*
++Contents of section .got.plt:
++ 103a8 0+ 0+ 0+ 0+  .*
++ 103b8 0+ 0+ [0-9a-f]+ 0+  .*
++
++Disassembly of section .text:
++
++0+2a0 <ifunc>:
++ 2a0: d65f03c0        ret
++
++0+2a4 <bar>:
++ 2a4: 90000080        adrp    x0, 10000 <.*>
++ 2a8: f941e000        ldr     x0, \[x0,#960\]
++ 2ac: d65f03c0        ret
++
++Disassembly of section .got.plt:
++
++.*:
++.*
++.*
++.*
+diff --git a/ld/testsuite/ld-aarch64/ifunc-21.s b/ld/testsuite/ld-aarch64/ifunc-21.s
+new file mode 100644
+index 0000000..a1563dc
+--- /dev/null
++++ b/ld/testsuite/ld-aarch64/ifunc-21.s
+@@ -0,0 +1,13 @@
++      .text
++      .type ifunc, @gnu_indirect_function
++      .hidden ifunc
++ifunc:
++      ret
++      .size   ifunc, .-ifunc
++      .type bar, @function
++      .globl bar
++bar:
++        adrp    x0, :got:ifunc
++        ldr     x0, [x0, #:got_lo12:ifunc]
++      ret
++      .size   bar, .-bar
diff --git a/binutils/patches/binutils-2.24-aarch64-fix-ie-relax.patch b/binutils/patches/binutils-2.24-aarch64-fix-ie-relax.patch
new file mode 100644 (file)
index 0000000..d9157ea
--- /dev/null
@@ -0,0 +1,40 @@
+commit 44f814ce5066f10a3bed29c45d10e0d38f4fa433
+Author: Marcus Shawcroft <marcus.shawcroft@arm.com>
+Date:   Tue Apr 15 17:46:07 2014 +0100
+
+    [AArch64] Fix off by one error in instruction relaxation mask.
+    
+    The AArch64 TLSDESC to IE relaxation code uses a bit mask intended to
+    ensure that destination register in a relaxed ldr instruction is
+    always X0.  The mask has an off by one error resulting in the most
+    significant bit of the destination register being retained in the
+    relaxed instruction.  The issue generally appears when the compiler
+    emits TLS accesses code under high register pressure resulting in a
+    broken code sequence.
+
+diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
+index 42c83fb..8503419 100644
+--- a/bfd/elfnn-aarch64.c
++++ b/bfd/elfnn-aarch64.c
+@@ -3957,7 +3957,7 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
+            ldr xd, [x0, #:tlsdesc_lo12:var] => ldr x0, [x0, #:gottprel_lo12:var]
+          */
+         insn = bfd_getl32 (contents + rel->r_offset);
+-        insn &= 0xfffffff0;
++        insn &= 0xffffffe0;
+         bfd_putl32 (insn, contents + rel->r_offset);
+         return bfd_reloc_continue;
+       }
+diff --git a/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie.s b/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie.s
+index c20690c..38b3721 100644
+--- a/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie.s
++++ b/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie.s
+@@ -4,7 +4,7 @@ var:
+       .word   2
+       .text
+       adrp    x0, :tlsdesc:var
+-      ldr     x1, [x0, #:tlsdesc_lo12:var]
++      ldr     x17, [x0, #:tlsdesc_lo12:var]
+       add     x0, x0, :tlsdesc_lo12:var
+       .tlsdesccall    var
+       blr     x1
diff --git a/binutils/patches/binutils-2.24-aarch64-fix-static-ifunc.patch b/binutils/patches/binutils-2.24-aarch64-fix-static-ifunc.patch
new file mode 100644 (file)
index 0000000..296f162
--- /dev/null
@@ -0,0 +1,118 @@
+commit 14d96265dd8fd934d868c0b8e1991e2fefbe9fc8
+Author: Will Newton <will.newton@linaro.org>
+Date:   Mon Nov 25 14:44:59 2013 +0000
+
+    bfd/elfnn-aarch64.c: Handle static links with ifunc correctly.
+    
+    The code for handling GOT references to ifunc symbols in static links
+    was missing.
+    
+    bfd/ChangeLog:
+    
+    2013-11-26  Will Newton  <will.newton@linaro.org>
+    
+       * elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_symbol):
+       Handle STT_GNU_IFUNC symbols correctly in static links.
+    
+    ld/testsuite/ChangeLog:
+    
+    2013-11-26  Will Newton  <will.newton@linaro.org>
+    
+       * ld-aarch64/aarch64-elf.exp: Add ifunc-22.
+       * ld-aarch64/ifunc-22.d: New file.
+       * ld-aarch64/ifunc-22.s: Likewise.
+
+diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
+index 3cd3a18..9053635 100644
+--- a/bfd/elfnn-aarch64.c
++++ b/bfd/elfnn-aarch64.c
+@@ -6824,7 +6824,34 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd,
+                      + htab->root.sgot->output_offset
+                      + (h->got.offset & ~(bfd_vma) 1));
+-      if (info->shared && SYMBOL_REFERENCES_LOCAL (info, h))
++      if (h->def_regular
++        && h->type == STT_GNU_IFUNC)
++      {
++        if (info->shared)
++          {
++            /* Generate R_AARCH64_GLOB_DAT.  */
++            goto do_glob_dat;
++          }
++        else
++          {
++            asection *plt;
++
++            if (!h->pointer_equality_needed)
++              abort ();
++
++            /* For non-shared object, we can't use .got.plt, which
++               contains the real function address if we need pointer
++               equality.  We load the GOT entry with the PLT entry.  */
++            plt = htab->root.splt ? htab->root.splt : htab->root.iplt;
++            bfd_put_NN (output_bfd, (plt->output_section->vma
++                                     + plt->output_offset
++                                     + h->plt.offset),
++                        htab->root.sgot->contents
++                        + (h->got.offset & ~(bfd_vma) 1));
++            return TRUE;
++          }
++      }
++      else if (info->shared && SYMBOL_REFERENCES_LOCAL (info, h))
+       {
+         if (!h->def_regular)
+           return FALSE;
+@@ -6837,6 +6864,7 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd,
+       }
+       else
+       {
++do_glob_dat:
+         BFD_ASSERT ((h->got.offset & 1) == 0);
+         bfd_put_NN (output_bfd, (bfd_vma) 0,
+                     htab->root.sgot->contents + h->got.offset);
+diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp
+index a6b3ea2..692bf34 100644
+--- a/ld/testsuite/ld-aarch64/aarch64-elf.exp
++++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp
+@@ -156,3 +156,4 @@ run_dump_test "ifunc-19a"
+ run_dump_test "ifunc-19b"
+ run_dump_test "ifunc-20"
+ run_dump_test "ifunc-21"
++run_dump_test "ifunc-22"
+diff --git a/ld/testsuite/ld-aarch64/ifunc-22.d b/ld/testsuite/ld-aarch64/ifunc-22.d
+new file mode 100644
+index 0000000..f28b039
+--- /dev/null
++++ b/ld/testsuite/ld-aarch64/ifunc-22.d
+@@ -0,0 +1,11 @@
++#source: ifunc-22.s
++#objdump: -s -j .got
++#ld: -static
++#target: aarch64*-*-*
++
++# Ensure GOT is populated correctly in static link
++
++.*:     file format elf64-(little|big)aarch64
++
++Contents of section \.got:
++ 4100f0 00000000 00000000 d0004000 00000000  ..........@.....
+diff --git a/ld/testsuite/ld-aarch64/ifunc-22.s b/ld/testsuite/ld-aarch64/ifunc-22.s
+new file mode 100644
+index 0000000..69a87bb
+--- /dev/null
++++ b/ld/testsuite/ld-aarch64/ifunc-22.s
+@@ -0,0 +1,14 @@
++      .text
++      .type ifunc, @gnu_indirect_function
++      .global ifunc
++ifunc:
++      ret
++      .size   ifunc, .-ifunc
++      .type _start, @function
++      .globl _start
++_start:
++        adrp    x0, :got:ifunc
++        ldr     x0, [x0, #:got_lo12:ifunc]
++      .size   _start, .-_start
++      .data
++      .xword  ifunc
diff --git a/binutils/patches/binutils-2.24-aarch64-ld-shared-non-PIC-xfail.patch b/binutils/patches/binutils-2.24-aarch64-ld-shared-non-PIC-xfail.patch
new file mode 100644 (file)
index 0000000..8525596
--- /dev/null
@@ -0,0 +1,55 @@
+commit 273dc279306c2b69fbc1407cc695397e4b015152
+Author: Will Newton <will.newton@linaro.org>
+Date:   Fri May 16 15:22:58 2014 +0100
+
+    ld/aarch64: xfail non-PIC shared object tests on aarch64
+    
+    aarch64 does not support building non-PIC shared objects, so mark
+    tests for these as xfail.
+    
+    ld/testsuite/ChangeLog:
+    
+    2014-05-20  Will Newton  <will.newton@linaro.org>
+    
+       * ld-shared/shared.exp: Mark non-PIC shared object tests
+       as xfail on aarch64.
+
+#-- a/ld/testsuite/ChangeLog
+#++ b/ld/testsuite/ChangeLog
+#@ -1,3 +1,8 @@
++2014-05-20  Will Newton  <will.newton@linaro.org>
++
++      * ld-shared/shared.exp: Mark non-PIC shared object tests
++      as xfail on aarch64.
++
+ 2014-05-19  Andreas Tobler  <andreast@fgznet.ch>
+       * ld-elf/shared.exp: Introduce the extralibs variable to control
+diff --git a/ld/testsuite/ld-shared/shared.exp b/ld/testsuite/ld-shared/shared.exp
+index 9996ece..c723ef7 100644
+--- a/ld/testsuite/ld-shared/shared.exp
++++ b/ld/testsuite/ld-shared/shared.exp
+@@ -244,6 +244,7 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o]
+       if [ string match $shared_needs_pic "yes" ] {
+           setup_xfail "arm*-*-linux*"
+       }
++      setup_xfail "aarch64*-*-linux*"
+       shared_test shnp "shared (non PIC)" mainnp.o sh1np.o sh2np.o shared
+       # Test ELF shared library relocations with a non-zero load
+@@ -270,6 +271,7 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o]
+       if [ string match $shared_needs_pic "yes" ] {
+           setup_xfail "arm*-*-linux*"
+       }
++      setup_xfail "aarch64*-*-linux*"
+       shared_test shnp "shared (non PIC, load offset)" \
+               mainnp.o sh1np.o sh2np.o shared \
+               "-T $srcdir/$subdir/elf-offset.ld"
+@@ -326,6 +328,7 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG $picflag" $srcdir/$subdir/main.c $tmpdir/m
+           if [ string match $shared_needs_pic "yes" ] {
+               setup_xfail "arm*-*-linux*"
+           }
++          setup_xfail "aarch64*-*-linux*"
+           shared_test shmpnp "shared (PIC main, non PIC so)" mainp.o sh1np.o sh2np.o shared
+       }
+     } else {
diff --git a/binutils/patches/binutils-2.24-arm-static-tls.patch b/binutils/patches/binutils-2.24-arm-static-tls.patch
new file mode 100644 (file)
index 0000000..2b580f1
--- /dev/null
@@ -0,0 +1,42 @@
+commit eea6dad2b3ae91189caa91145dd133bae0398d21
+Author: Kyle McMartin <kyle@redhat.com>
+Date:   Fri Jun 20 11:14:09 2014 +0100
+
+    Similarly to the AArch64 patch, set DF_STATIC_TLS for consistency with
+    other architectures when we emit IE relocs in a shared library.
+    
+       * elf32-arm.c (elf32_arm_check_relocs): Set DF_STATIC_TLS when
+       emitting initial-exec relocs when not linking an executable.
+
+--- a/bfd/elf32-arm.c
++++ b/bfd/elf32-arm.c
+@@ -12711,6 +12711,9 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info,
+               default: tls_type = GOT_NORMAL; break;
+               }
++            if (!info->executable && (tls_type & GOT_TLS_IE))
++              info->flags |= DF_STATIC_TLS;
++
+             if (h != NULL)
+               {
+                 h->got.refcount++;
+--- a/ld/testsuite/ld-arm/tls-gdierelax2.d
++++ b/ld/testsuite/ld-arm/tls-gdierelax2.d
+@@ -11,13 +11,13 @@ Disassembly of section .text:
+     [0-9a-f]+:        e59f0004        ldr     r0, \[pc, #4\]  ; .*
+     [0-9a-f]+:        e79f0000        ldr     r0, \[pc, r0\]
+     [0-9a-f]+:        e1a00000        nop                     ; .*
+-    [0-9a-f]+:        00008098        .word   0x00008098
+-    [0-9a-f]+:        0000809c        .word   0x0000809c
++    [0-9a-f]+:        000080a0        .word   0x000080a0
++    [0-9a-f]+:        000080a4        .word   0x000080a4
+ [0-9a-f]+ <bar>:
+     [0-9a-f]+:        4801            ldr     r0, \[pc, #4\]  ; .*
+     [0-9a-f]+:        4478            add     r0, pc
+     [0-9a-f]+:        6800            ldr     r0, \[r0, #0\]
+     [0-9a-f]+:        46c0            nop                     ; .*
+-    [0-9a-f]+:        0000808a        .word   0x0000808a
+-    [0-9a-f]+:        0000808c        .word   0x0000808c
++    [0-9a-f]+:        00008092        .word   0x00008092
++    [0-9a-f]+:        00008094        .word   0x00008094
diff --git a/binutils/patches/binutils-2.24-elfnn-aarch64.patch0 b/binutils/patches/binutils-2.24-elfnn-aarch64.patch0
new file mode 100644 (file)
index 0000000..469387b
--- /dev/null
@@ -0,0 +1,21 @@
+*** ../binutils-2.24.orig/bfd/elfnn-aarch64.c  2013-12-17 11:16:28.723807381 +0000
+--- bfd/elfnn-aarch64.c        2013-12-17 11:18:13.517804067 +0000
+*************** _aarch64_elf_section_data;
+*** 1679,1686 ****
+  #define elf_aarch64_section_data(sec) \
+    ((_aarch64_elf_section_data *) elf_section_data (sec))
+  
+! /* The size of the thread control block.  */
+! #define TCB_SIZE     16
+  
+  struct elf_aarch64_local_symbol
+  {
+--- 1679,1686 ----
+  #define elf_aarch64_section_data(sec) \
+    ((_aarch64_elf_section_data *) elf_section_data (sec))
+  
+! /* The size of the thread control block which is defined to be two pointers.  */
+! #define TCB_SIZE     (ARCH_SIZE/8)*2
+  
+  struct elf_aarch64_local_symbol
+  {
diff --git a/binutils/patches/binutils-2.24-fake-zlib-sections.patch0 b/binutils/patches/binutils-2.24-fake-zlib-sections.patch0
new file mode 100644 (file)
index 0000000..e02dd51
--- /dev/null
@@ -0,0 +1,30 @@
+*** ../binutils-2.24.orig/bfd/compress.c       2014-04-28 16:35:20.429816317 +0100
+--- bfd/compress.c     2014-04-28 16:36:06.450963028 +0100
+***************
+*** 25,30 ****
+--- 25,31 ----
+  #ifdef HAVE_ZLIB_H
+  #include <zlib.h>
+  #endif
++ #include "safe-ctype.h"
+  
+  #ifdef HAVE_ZLIB_H
+  static bfd_boolean
+*************** bfd_is_section_compressed (bfd *abfd, se
+*** 304,309 ****
+--- 305,319 ----
+    compressed = (bfd_get_section_contents (abfd, sec, compressed_buffer, 0, 12)
+               && CONST_STRNEQ ((char*) compressed_buffer, "ZLIB"));
+  
++   /* Check for the pathalogical case of a debug string section that
++      contains the string ZLIB.... as the first entry.  We assume that
++      no uncompressed .debug_str section would ever be big enough to
++      have the first byte of its (big-endian) size be non-zero.  */
++   if (compressed
++       && strcmp (sec->name, ".debug_str") == 0
++       && ISPRINT (compressed_buffer[4]))
++     compressed = FALSE;
++ 
+    /* Restore compress_status.  */
+    sec->compress_status = saved;
+    return compressed;
diff --git a/binutils/patches/binutils-2.24-fat-lto-objects.patch b/binutils/patches/binutils-2.24-fat-lto-objects.patch
new file mode 100644 (file)
index 0000000..fe9c334
--- /dev/null
@@ -0,0 +1,57 @@
+commit b35d44f1af711925bfa4344ef00470fee67122f1
+Author: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
+Date:   Wed Nov 27 13:43:39 2013 +0000
+
+    [ld/testsuite/]
+    2013-11-27  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+    
+       * ld-plugin/lto.exp: Add -ffat-lto-objects.
+       * lib/ld-lib.exp (check_lto_available): Likewise.
+
+--- a/ld/testsuite/ld-plugin/lto.exp
++++ b/ld/testsuite/ld-plugin/lto.exp
+@@ -57,7 +57,7 @@ set lto_link_tests {
+    "" "-O2"
+    {lto-3c.c} {} "libdummy.a"}
+   {"Build liblto-3.a"
+-   "" "-flto"
++   "" "-flto -ffat-lto-objects"
+    {lto-3b.c} {} "liblto-3.a"}
+   {"Build libdummy.a 5a"
+    "" "-flto"
+@@ -111,7 +111,7 @@ set lto_link_tests {
+    "" ""
+    {pr12758a.s} {} "libdummy.a"}
+   {"Build libpr12758.a"
+-   "" "-flto -O2"
++   "" "-flto -O2 -ffat-lto-objects"
+    {pr12758b.c} {} "libpr12758.a"}
+   {"PR ld/12758"
+    "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12758a.o -Wl,--start-group tmpdir/libpr12758.a -Wl,--end-group" ""
+@@ -120,13 +120,13 @@ set lto_link_tests {
+    "" ""
+    {pr12760a.c} {} "libdummy.a"}
+   {"Build libpr12760.a"
+-   "" "-flto -O2"
++   "" "-flto -O2 -ffat-lto-objects"
+    {pr12760b.c} {} "libpr12760.a"}
+   {"PR ld/12760"
+    "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12760a.o -Wl,--start-group tmpdir/libpr12760.a -Wl,--end-group" ""
+    {dummy.c} {} "pr12760.exe" "c" "warning: Bad bar"}
+   {"Build libpr13183.a"
+-   "-T" "-flto -O2"
++   "-T" "-flto -O2 -ffat-lto-objects"
+    {pr13183a.c} {} "libpr13183.a"}
+   {"Build libdummy.a PR ld/13183"
+    "" "-flto -O2"
+--- a/ld/testsuite/lib/ld-lib.exp
++++ b/ld/testsuite/lib/ld-lib.exp
+@@ -1643,7 +1643,7 @@ proc check_lto_available { } {
+       set f [open $src "w"]
+       puts $f ""
+       close $f
+-      set status [remote_exec host $CC "-shared -B[pwd]/tmpdir/ld/ -flto -fuse-linker-plugin $src -o $output"]
++      set status [remote_exec host $CC "-shared -B[pwd]/tmpdir/ld/ -flto -ffat-lto-objects -fuse-linker-plugin $src -o $output"]
+       if { [lindex $status 0] == 0 } {
+           set lto_available_saved 1
+       } else {
diff --git a/binutils/patches/binutils-2.24-indirect-chain.patch0 b/binutils/patches/binutils-2.24-indirect-chain.patch0
new file mode 100644 (file)
index 0000000..b255424
--- /dev/null
@@ -0,0 +1,28 @@
+*** ../binutils-2.24.orig/bfd/elflink.c        2014-08-21 09:17:27.753408085 +0100
+--- bfd/elflink.c      2014-08-21 10:04:52.174935912 +0100
+*************** _bfd_elf_add_default_symbol (bfd *abfd,
+*** 1705,1710 ****
+--- 1705,1716 ----
+        ht = (struct elf_link_hash_entry *) hi->root.u.i.link;
+        (*bed->elf_backend_copy_indirect_symbol) (info, ht, hi);
+  
++        /* A reference to the SHORTNAME symbol from a dynamic library
++       will be satisfied by the versioned symbol at runtime.  In
++       effect, we have a reference to the versioned symbol.  */
++        ht->ref_dynamic_nonweak |= hi->ref_dynamic_nonweak;
++        hi->dynamic_def |= ht->dynamic_def;
++  
+        /* See if the new flags lead us to realize that the symbol must
+        be dynamic.  */
+        if (! *dynsym)
+*************** nondefault:
+*** 1774,1779 ****
+--- 1780,1787 ----
+        if (hi->root.type == bfd_link_hash_indirect)
+       {
+         (*bed->elf_backend_copy_indirect_symbol) (info, h, hi);
++        h->ref_dynamic_nonweak |= hi->ref_dynamic_nonweak;
++        hi->dynamic_def |= h->dynamic_def;
+  
+         /* See if the new flags lead us to realize that the symbol
+            must be dynamic.  */
diff --git a/binutils/patches/binutils-2.24-ldforcele.patch0 b/binutils/patches/binutils-2.24-ldforcele.patch0
new file mode 100644 (file)
index 0000000..6a46c78
--- /dev/null
@@ -0,0 +1,58 @@
+Common subdirectories: ../binutils-2.24.orig/ld/emulparams and ld/emulparams
+Common subdirectories: ../binutils-2.24.orig/ld/emultempl and ld/emultempl
+diff -cp ../binutils-2.24.orig/ld/ldlang.c ld/ldlang.c
+*** ../binutils-2.24.orig/ld/ldlang.c  2014-05-09 10:35:04.589504928 +0100
+--- ld/ldlang.c        2014-05-09 10:35:55.515661478 +0100
+*************** lang_add_output_format (const char *form
+*** 7096,7101 ****
+--- 7096,7113 ----
+              && little != NULL)
+       format = little;
+  
++       if (getenv ("LD_FORCE_LE") != NULL)
++      {
++        if (strcmp (format, "elf64-powerpc") == 0)
++          format = "elf64-powerpcle";
++        else if (strcmp (format, "elf32-powerpc") == 0)
++          format = "elf32-powerpcle";
++        else if (strcmp (format, "elf64-big") == 0)
++          format = "elf64-little";
++        else if (strcmp (format, "elf32-big") == 0)
++          format = "elf32-little";
++      }
++ 
+        output_target = format;
+      }
+  }
+Only in ld: ldlang.c.orig
+diff -cp ../binutils-2.24.orig/ld/ldmain.c ld/ldmain.c
+*** ../binutils-2.24.orig/ld/ldmain.c  2014-05-09 10:35:04.593504941 +0100
+--- ld/ldmain.c        2014-05-09 10:35:55.515661478 +0100
+*************** get_emulation (int argc, char **argv)
+*** 603,608 ****
+--- 603,620 ----
+       }
+      }
+  
++   if ((strncmp (emulation, "elf64ppc", 8) == 0
++        || strncmp (emulation, "elf32ppc", 8) == 0)
++       && getenv ("LD_FORCE_LE") != NULL)
++     {
++       size_t len = strlen (emulation);
++       char *le = xmalloc (len + 2);
++       memcpy (le, emulation, 5);
++       le[5] = 'l';
++       memcpy (le + 6, emulation + 5, len - 4);
++       emulation = le;
++     }
++ 
+    return emulation;
+  }
+  
+Only in ld: ldmain.c.orig
+Common subdirectories: ../binutils-2.24.orig/ld/ldscripts and ld/ldscripts
+Common subdirectories: ../binutils-2.24.orig/ld/.libs and ld/.libs
+Common subdirectories: ../binutils-2.24.orig/ld/po and ld/po
+Common subdirectories: ../binutils-2.24.orig/ld/scripttempl and ld/scripttempl
+Common subdirectories: ../binutils-2.24.orig/ld/testsuite and ld/testsuite
+Common subdirectories: ../binutils-2.24.orig/ld/tmpdir and ld/tmpdir
similarity index 81%
rename from binutils/patches/binutils-2.23.52.0.1-pt-pax-flags-20130326.patch
rename to binutils/patches/binutils-2.24-pt-pax-flags-20131231.patch
index b173b2ae768cd58a4df67444240c7326be7a23fb..cfb2035110849b1c8dc872f07a17800084b7f809 100644 (file)
@@ -1,5 +1,5 @@
---- binutils-2.23.52.0.1/bfd/elf-bfd.h
-+++ binutils-2.23.52.0.1/bfd/elf-bfd.h
+--- binutils-2.24/bfd/elf-bfd.h
++++ binutils-2.24/bfd/elf-bfd.h
 @@ -1577,6 +1577,9 @@ struct elf_obj_tdata
    /* Segment flags for the PT_GNU_STACK segment.  */
    unsigned int stack_flags;
@@ -18,8 +18,8 @@
  #define elf_shstrtab(bfd)     (elf_tdata(bfd) -> o->strtab_ptr)
  #define elf_onesymtab(bfd)    (elf_tdata(bfd) -> symtab_section)
  #define elf_symtab_shndx(bfd) (elf_tdata(bfd) -> symtab_shndx_section)
---- binutils-2.23.52.0.1/bfd/elf.c
-+++ binutils-2.23.52.0.1/bfd/elf.c
+--- binutils-2.24/bfd/elf.c
++++ binutils-2.24/bfd/elf.c
 @@ -1158,6 +1158,7 @@ get_segment_type (unsigned int p_type)
      case PT_GNU_EH_FRAME: pt = "EH_FRAME"; break;
      case PT_GNU_STACK: pt = "STACK"; break;
@@ -89,8 +89,8 @@
     && (segment->p_type != PT_TLS                                      \
         || (section->flags & SEC_THREAD_LOCAL))                                \
     && (segment->p_type == PT_LOAD                                     \
---- binutils-2.23.52.0.1/bfd/elflink.c
-+++ binutils-2.23.52.0.1/bfd/elflink.c
+--- binutils-2.24/bfd/elflink.c
++++ binutils-2.24/bfd/elflink.c
 @@ -5545,17 +5545,30 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
        && ! (*bed->elf_backend_always_size_sections) (output_bfd, info))
      return FALSE;
              notesec = s;
            }
          else if (bed->default_execstack)
---- binutils-2.23.52.0.1/binutils/readelf.c
-+++ binutils-2.23.52.0.1/binutils/readelf.c
+--- binutils-2.24/binutils/readelf.c
++++ binutils-2.24/binutils/readelf.c
 @@ -2740,6 +2740,7 @@ get_segment_type (unsigned long p_type)
                        return "GNU_EH_FRAME";
      case PT_GNU_STACK:        return "GNU_STACK";
  
      default:
        if ((p_type >= PT_LOPROC) && (p_type <= PT_HIPROC))
---- binutils-2.23.52.0.1/include/bfdlink.h
-+++ binutils-2.23.52.0.1/include/bfdlink.h
+--- binutils-2.24/include/bfdlink.h
++++ binutils-2.24/include/bfdlink.h
 @@ -322,6 +322,14 @@ struct bfd_link_info
    /* TRUE if PT_GNU_RELRO segment should be created.  */
    unsigned int relro: 1;
    /* TRUE if .eh_frame_hdr section and PT_GNU_EH_FRAME ELF segment
       should be created.  */
    unsigned int eh_frame_hdr: 1;
---- binutils-2.23.52.0.1/include/elf/common.h
-+++ binutils-2.23.52.0.1/include/elf/common.h
+--- binutils-2.24/include/elf/common.h
++++ binutils-2.24/include/elf/common.h
 @@ -429,6 +429,7 @@
  #define PT_SUNW_EH_FRAME PT_GNU_EH_FRAME      /* Solaris uses the same value */
  #define PT_GNU_STACK  (PT_LOOS + 0x474e551) /* Stack flags */
  #define PT_GNU_RELRO  (PT_LOOS + 0x474e552) /* Read-only after relocation */
 +#define PT_PAX_FLAGS  (PT_LOOS + 0x5041580) /* PaX flags */
- #define PT_GNU_SHR    (PT_LOOS + 0x474e554) /* Sharable segment */
  
  /* Program segment permissions, in program header p_flags field.  */
 @@ -439,6 +440,21 @@
  #define PF_MASKOS     0x0FF00000      /* New value, Oct 4, 1999 Draft */
  #define PF_MASKPROC   0xF0000000      /* Processor-specific reserved bits */
  /* Values for section header, sh_type field.  */
  
  #define SHT_NULL      0               /* Section header table entry unused */
---- binutils-2.23.52.0.1/ld/emultempl/elf32.em
-+++ binutils-2.23.52.0.1/ld/emultempl/elf32.em
+--- binutils-2.24/ld/emultempl/elf32.em
++++ binutils-2.24/ld/emultempl/elf32.em
 @@ -2285,6 +2285,16 @@ fragment <<EOF
          link_info.noexecstack = TRUE;
          link_info.execstack = FALSE;
  EOF
  if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
  fragment <<EOF
---- binutils-2.23.52.0.1/ld/ldgram.y
-+++ binutils-2.23.52.0.1/ld/ldgram.y
+--- binutils-2.24/ld/ldgram.y
++++ binutils-2.24/ld/ldgram.y
 @@ -1119,6 +1119,8 @@ phdr_type:
                            $$ = exp_intop (0x6474e550);
                          else if (strcmp (s, "PT_GNU_STACK") == 0)
                          else
                            {
                              einfo (_("\
---- binutils-2.23.52.0.1/ld/testsuite/ld-alpha/tlsbin.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-alpha/tlsbin.rd
+--- binutils-2.24/ld/testsuite/ld-alpha/tlsbin.rd
++++ binutils-2.24/ld/testsuite/ld-alpha/tlsbin.rd
 @@ -35,13 +35,14 @@ There are [0-9]+ program headers, starting at offset [0-9]+
  
  Program Headers:
  #...
  
  Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 3 entries:
---- binutils-2.23.52.0.1/ld/testsuite/ld-alpha/tlsbinr.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-alpha/tlsbinr.rd
+--- binutils-2.24/ld/testsuite/ld-alpha/tlsbinr.rd
++++ binutils-2.24/ld/testsuite/ld-alpha/tlsbinr.rd
 @@ -42,6 +42,7 @@ Program Headers:
   +LOAD +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ RWE 0x10000
   +DYNAMIC +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ RW +0x8
  #...
  
  Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 2 entries:
---- binutils-2.23.52.0.1/ld/testsuite/ld-alpha/tlspic.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-alpha/tlspic.rd
+--- binutils-2.24/ld/testsuite/ld-alpha/tlspic.rd
++++ binutils-2.24/ld/testsuite/ld-alpha/tlspic.rd
 @@ -38,6 +38,7 @@ Program Headers:
   +LOAD +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ RWE 0x10000
   +DYNAMIC +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ RW +0x8
  #...
  
  Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 7 entries:
---- binutils-2.23.52.0.1/ld/testsuite/ld-elf/eh1.d
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-elf/eh1.d
+--- binutils-2.24/ld/testsuite/ld-elf/eh1.d
++++ binutils-2.24/ld/testsuite/ld-elf/eh1.d
 @@ -22,11 +22,11 @@ Contents of the .eh_frame section:
    DW_CFA_nop
    DW_CFA_nop
  
--00000018 0000001c 0000001c FDE cie=00000000 pc=00400078..00400078
--  DW_CFA_advance_loc: 0 to 00400078
-+00000018 0000001c 0000001c FDE cie=00000000 pc=([0-9a-f]+)..\1
+-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-9a-f]+)..\1
 +  DW_CFA_advance_loc: 0 to [0-9a-f]+
    DW_CFA_def_cfa_offset: 16
    DW_CFA_offset: r6 \(rbp\) at cfa-16
--  DW_CFA_advance_loc: 0 to 00400078
+-  DW_CFA_advance_loc: 0 to 0+400078
 +  DW_CFA_advance_loc: 0 to [0-9a-f]+
    DW_CFA_def_cfa_register: r6 \(rbp\)
  
- 00000038 ZERO terminator
---- binutils-2.23.52.0.1/ld/testsuite/ld-elf/eh2.d
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-elf/eh2.d
+ 0+0038 ZERO terminator
+--- binutils-2.24/ld/testsuite/ld-elf/eh2.d
++++ binutils-2.24/ld/testsuite/ld-elf/eh2.d
 @@ -22,11 +22,11 @@ Contents of the .eh_frame section:
    DW_CFA_nop
    DW_CFA_nop
  
--00000018 0000001c 0000001c FDE cie=00000000 pc=00400078..00400078
--  DW_CFA_advance_loc: 0 to 00400078
-+00000018 0000001c 0000001c FDE cie=00000000 pc=([0-9a-f]+)..\1
+-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-9a-f]+)..\1
 +  DW_CFA_advance_loc: 0 to [0-9a-f]+
    DW_CFA_def_cfa_offset: 16
    DW_CFA_offset: r6 \(rbp\) at cfa-16
--  DW_CFA_advance_loc: 0 to 00400078
+-  DW_CFA_advance_loc: 0 to 0+400078
 +  DW_CFA_advance_loc: 0 to [0-9a-f]+
    DW_CFA_def_cfa_register: r6 \(rbp\)
  
- 00000038 ZERO terminator
---- binutils-2.23.52.0.1/ld/testsuite/ld-elf/eh3.d
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-elf/eh3.d
+ 0+0038 ZERO terminator
+--- binutils-2.24/ld/testsuite/ld-elf/eh3.d
++++ binutils-2.24/ld/testsuite/ld-elf/eh3.d
 @@ -22,11 +22,11 @@ Contents of the .eh_frame section:
    DW_CFA_nop
    DW_CFA_nop
  
--00000018 0000001c 0000001c FDE cie=00000000 pc=00400078..00400078
--  DW_CFA_advance_loc: 0 to 00400078
-+00000018 0000001c 0000001c FDE cie=00000000 pc=([0-9a-f]+)..\1
+-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-9a-f]+)..\1
 +  DW_CFA_advance_loc: 0 to [0-9a-f]+
    DW_CFA_def_cfa_offset: 16
    DW_CFA_offset: r6 \(rbp\) at cfa-16
--  DW_CFA_advance_loc: 0 to 00400078
+-  DW_CFA_advance_loc: 0 to 0+400078
 +  DW_CFA_advance_loc: 0 to [0-9a-f]+
    DW_CFA_def_cfa_register: r6 \(rbp\)
  
- 00000038 ZERO terminator
---- binutils-2.23.52.0.1/ld/testsuite/ld-elf/orphan-region.d
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-elf/orphan-region.d
+ 0+0038 ZERO terminator
+--- binutils-2.24/ld/testsuite/ld-elf/orphan-region.d
++++ binutils-2.24/ld/testsuite/ld-elf/orphan-region.d
 @@ -15,7 +15,9 @@
  Program Headers:
    Type.*
    Segment Sections...
     00     .text .rodata .moredata *
 +   01 +
---- binutils-2.23.52.0.1/ld/testsuite/ld-i386/tlsbin.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-i386/tlsbin.rd
+--- binutils-2.24/ld/testsuite/ld-i386/tlsbin.rd
++++ binutils-2.24/ld/testsuite/ld-i386/tlsbin.rd
 @@ -44,6 +44,7 @@ Program Headers:
   +LOAD.*
   +DYNAMIC.*
  
  Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 9 entries:
   Offset +Info +Type +Sym.Value +Sym. Name
---- binutils-2.23.52.0.1/ld/testsuite/ld-i386/tlsbindesc.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-i386/tlsbindesc.rd
+--- binutils-2.24/ld/testsuite/ld-i386/tlsbindesc.rd
++++ binutils-2.24/ld/testsuite/ld-i386/tlsbindesc.rd
 @@ -42,6 +42,7 @@ Program Headers:
   +LOAD.*
   +DYNAMIC.*
  
  Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 9 entries:
   Offset +Info +Type +Sym.Value +Sym. Name
---- binutils-2.23.52.0.1/ld/testsuite/ld-i386/tlsdesc.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-i386/tlsdesc.rd
+--- binutils-2.24/ld/testsuite/ld-i386/tlsdesc.rd
++++ binutils-2.24/ld/testsuite/ld-i386/tlsdesc.rd
 @@ -39,6 +39,7 @@ Program Headers:
   +LOAD.*
   +DYNAMIC.*
  
  Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 20 entries:
   Offset +Info +Type +Sym.Value +Sym. Name
---- binutils-2.23.52.0.1/ld/testsuite/ld-i386/tlsgdesc.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-i386/tlsgdesc.rd
+--- binutils-2.24/ld/testsuite/ld-i386/tlsgdesc.rd
++++ binutils-2.24/ld/testsuite/ld-i386/tlsgdesc.rd
 @@ -36,12 +36,14 @@ Program Headers:
   +LOAD.*
   +LOAD.*
  
  Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 8 entries:
   Offset +Info +Type +Sym.Value +Sym. Name
---- binutils-2.23.52.0.1/ld/testsuite/ld-i386/tlsnopic.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-i386/tlsnopic.rd
+--- binutils-2.24/ld/testsuite/ld-i386/tlsnopic.rd
++++ binutils-2.24/ld/testsuite/ld-i386/tlsnopic.rd
 @@ -37,6 +37,7 @@ Program Headers:
   +LOAD.*
   +DYNAMIC.*
  
  Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 20 entries:
   Offset +Info +Type +Sym.Value +Sym. Name
---- binutils-2.23.52.0.1/ld/testsuite/ld-i386/tlspic.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-i386/tlspic.rd
+--- binutils-2.24/ld/testsuite/ld-i386/tlspic.rd
++++ binutils-2.24/ld/testsuite/ld-i386/tlspic.rd
 @@ -40,6 +40,7 @@ Program Headers:
   +LOAD.*
   +DYNAMIC.*
  
  Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 26 entries:
   Offset +Info +Type +Sym.Value +Sym. Name
---- binutils-2.23.52.0.1/ld/testsuite/ld-ia64/merge1.d
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-ia64/merge1.d
+--- binutils-2.24/ld/testsuite/ld-ia64/merge1.d
++++ binutils-2.24/ld/testsuite/ld-ia64/merge1.d
 @@ -4,7 +4,7 @@
  #objdump: -d
  
  [     ]*[a-f0-9]+:    0b 60 80 02 00 24       \[MMI\]       addl r12=32,r1;;
  [     ]*[a-f0-9]+:    c0 c0 04 00 48 00                   addl r12=24,r1
  [     ]*[a-f0-9]+:    00 00 04 00                         nop.i 0x0;;
---- binutils-2.23.52.0.1/ld/testsuite/ld-ia64/merge2.d
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-ia64/merge2.d
+--- binutils-2.24/ld/testsuite/ld-ia64/merge2.d
++++ binutils-2.24/ld/testsuite/ld-ia64/merge2.d
 @@ -4,7 +4,7 @@
  #objdump: -d
  
  [     ]*[a-f0-9]+:    0b 60 80 02 00 24       \[MMI\]       addl r12=32,r1;;
  [     ]*[a-f0-9]+:    c0 c0 04 00 48 00                   addl r12=24,r1
  [     ]*[a-f0-9]+:    00 00 04 00                         nop.i 0x0;;
---- binutils-2.23.52.0.1/ld/testsuite/ld-ia64/merge3.d
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-ia64/merge3.d
+--- binutils-2.24/ld/testsuite/ld-ia64/merge3.d
++++ binutils-2.24/ld/testsuite/ld-ia64/merge3.d
 @@ -4,7 +4,7 @@
  #objdump: -d
  
  [     ]*[a-f0-9]+:    0b 60 80 02 00 24       \[MMI\]       addl r12=32,r1;;
  [     ]*[a-f0-9]+:    c0 40 05 00 48 00                   addl r12=40,r1
  [     ]*[a-f0-9]+:    00 00 04 00                         nop.i 0x0;;
---- binutils-2.23.52.0.1/ld/testsuite/ld-ia64/merge4.d
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-ia64/merge4.d
+--- binutils-2.24/ld/testsuite/ld-ia64/merge4.d
++++ binutils-2.24/ld/testsuite/ld-ia64/merge4.d
 @@ -4,7 +4,7 @@
  #objdump: -d
  
  [     ]*[a-f0-9]+:    0b 60 80 02 00 24       \[MMI\]       addl r12=32,r1;;
  [     ]*[a-f0-9]+:    c0 40 05 00 48 00                   addl r12=40,r1
  [     ]*[a-f0-9]+:    00 00 04 00                         nop.i 0x0;;
---- binutils-2.23.52.0.1/ld/testsuite/ld-ia64/merge5.d
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-ia64/merge5.d
+--- binutils-2.24/ld/testsuite/ld-ia64/merge5.d
++++ binutils-2.24/ld/testsuite/ld-ia64/merge5.d
 @@ -4,7 +4,7 @@
  #objdump: -d
  
  [     ]*[a-f0-9]+:    0b 60 80 02 00 24       \[MMI\]       addl r12=32,r1;;
  [     ]*[a-f0-9]+:    c0 40 05 00 48 00                   addl r12=40,r1
  [     ]*[a-f0-9]+:    00 00 04 00                         nop.i 0x0;;
---- binutils-2.23.52.0.1/ld/testsuite/ld-ia64/tlsbin.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-ia64/tlsbin.rd
+--- binutils-2.24/ld/testsuite/ld-ia64/tlsbin.rd
++++ binutils-2.24/ld/testsuite/ld-ia64/tlsbin.rd
 @@ -36,13 +36,14 @@ There are [0-9]+ program headers, starting at offset [0-9]+
  
  Program Headers:
   +IA_64_UNWIND .* R +0x8
  #...
  
---- binutils-2.23.52.0.1/ld/testsuite/ld-ia64/tlspic.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-ia64/tlspic.rd
+--- binutils-2.24/ld/testsuite/ld-ia64/tlspic.rd
++++ binutils-2.24/ld/testsuite/ld-ia64/tlspic.rd
 @@ -40,6 +40,7 @@ Program Headers:
   +LOAD +0x0+1[0-9a-f]+ 0x0+11[0-9a-f]+ 0x0+11[0-9a-f]+ 0x0+0[0-9a-f]+ 0x0+0[0-9a-f]+ RW +0x10000
   +DYNAMIC +0x0+1[0-9a-f]+ 0x0+11[0-9a-f]+ 0x0+11[0-9a-f]+ 0x0+140 0x0+140 RW +0x8
   +IA_64_UNWIND +0x0+1[0-9a-f]+ 0x0+1[0-9a-f]+ 0x0+1[0-9a-f]+ 0x0+18 0x0+18 R +0x8
  #...
  
---- binutils-2.23.52.0.1/ld/testsuite/ld-mips-elf/multi-got-no-shared.d
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-mips-elf/multi-got-no-shared.d
+--- binutils-2.24/ld/testsuite/ld-mips-elf/multi-got-no-shared.d
++++ binutils-2.24/ld/testsuite/ld-mips-elf/multi-got-no-shared.d
 @@ -8,9 +8,9 @@
  .*: +file format.*
  
  #...
  00408d60 <[^>]*> 3c1c0043     lui     gp,0x43
  00408d64 <[^>]*> 279c2c98     addiu   gp,gp,11416
---- binutils-2.23.52.0.1/ld/testsuite/ld-mips-elf/pic-and-nonpic-3a.sd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-mips-elf/pic-and-nonpic-3a.sd
+--- binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-3a.sd
++++ binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-3a.sd
 @@ -1,7 +1,7 @@
  
  Elf file type is DYN \(Shared object file\)
   *0*3 * \.dynamic *
   *0*4 *
 + *0*5 *
---- binutils-2.23.52.0.1/ld/testsuite/ld-mips-elf/pic-and-nonpic-3b.sd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-mips-elf/pic-and-nonpic-3b.sd
+--- binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-3b.sd
++++ binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-3b.sd
 @@ -1,7 +1,7 @@
  
  Elf file type is EXEC \(Executable file\)
   *0*6 *\.dynamic *
   *0*7 *
 + *0*8 *
---- binutils-2.23.52.0.1/ld/testsuite/ld-mips-elf/pic-and-nonpic-4b.sd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-mips-elf/pic-and-nonpic-4b.sd
+--- binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-4b.sd
++++ binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-4b.sd
 @@ -1,7 +1,7 @@
  
  Elf file type is EXEC \(Executable file\)
   *0*6 * \.dynamic *
   *0*7 *
 + *0*8 *
---- binutils-2.23.52.0.1/ld/testsuite/ld-mips-elf/pic-and-nonpic-5b.sd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-mips-elf/pic-and-nonpic-5b.sd
+--- binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-5b.sd
++++ binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-5b.sd
 @@ -1,7 +1,7 @@
  
  Elf file type is EXEC \(Executable file\)
   *0*6 * \.dynamic *
   *0*7 *
 + *0*8 *
---- binutils-2.23.52.0.1/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.sd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.sd
+--- binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.sd
++++ binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.sd
 @@ -1,7 +1,7 @@
  
  Elf file type is EXEC \(Executable file\)
   *0*6 * \.dynamic *
   *0*7 *
 + *0*8 *
---- binutils-2.23.52.0.1/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.sd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.sd
+--- binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.sd
++++ binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.sd
 @@ -1,7 +1,7 @@
  
  Elf file type is EXEC \(Executable file\)
   *0*5 * \.dynamic *
   *0*6 *
 + *0*7 *
---- binutils-2.23.52.0.1/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.sd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.sd
+--- binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.sd
++++ binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.sd
 @@ -1,7 +1,7 @@
  
  Elf file type is EXEC \(Executable file\)
   *0*6 * \.dynamic *
   *0*7 *
 + *0*8 *
---- binutils-2.23.52.0.1/ld/testsuite/ld-powerpc/tlsexe32.r
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-powerpc/tlsexe32.r
+--- binutils-2.24/ld/testsuite/ld-powerpc/tlsexe32.r
++++ binutils-2.24/ld/testsuite/ld-powerpc/tlsexe32.r
 @@ -33,13 +33,14 @@ There are [0-9]+ program headers, starting at offset [0-9]+
  
  Program Headers:
  
  Relocation section '\.rela\.dyn' at offset .* contains 2 entries:
   Offset +Info +Type +Sym\. Value +Symbol's Name \+ Addend
---- binutils-2.23.52.0.1/ld/testsuite/ld-powerpc/tlsso32.r
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-powerpc/tlsso32.r
+--- binutils-2.24/ld/testsuite/ld-powerpc/tlsso32.r
++++ binutils-2.24/ld/testsuite/ld-powerpc/tlsso32.r
 @@ -35,6 +35,7 @@ Program Headers:
   +LOAD .* RWE 0x10000
   +DYNAMIC .* RW +0x4
  [0-9a-f ]+R_PPC_DTPMOD32 +0
  [0-9a-f ]+R_PPC_DTPREL32 +0
  [0-9a-f ]+R_PPC_DTPMOD32 +0
---- binutils-2.23.52.0.1/ld/testsuite/ld-s390/tlsbin.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-s390/tlsbin.rd
+--- binutils-2.24/ld/testsuite/ld-s390/tlsbin.rd
++++ binutils-2.24/ld/testsuite/ld-s390/tlsbin.rd
 @@ -36,6 +36,7 @@ There are [0-9]+ program headers, starting at offset [0-9]+
   +LOAD .* RW +0x1000
   +DYNAMIC .* RW +0x4
  
  Relocation section '.rela.dyn' at offset .* contains 4 entries:
   Offset +Info +Type +Sym.Value +Sym. Name \+ Addend
---- binutils-2.23.52.0.1/ld/testsuite/ld-s390/tlsbin_64.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-s390/tlsbin_64.rd
+--- binutils-2.24/ld/testsuite/ld-s390/tlsbin_64.rd
++++ binutils-2.24/ld/testsuite/ld-s390/tlsbin_64.rd
 @@ -36,6 +36,7 @@ There are [0-9]+ program headers, starting at offset [0-9]+
   +LOAD .* RW +0x1000
   +DYNAMIC .* RW +0x8
  
  Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 4 entries:
   +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
---- binutils-2.23.52.0.1/ld/testsuite/ld-s390/tlspic.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-s390/tlspic.rd
+--- binutils-2.24/ld/testsuite/ld-s390/tlspic.rd
++++ binutils-2.24/ld/testsuite/ld-s390/tlspic.rd
 @@ -39,6 +39,7 @@ Program Headers:
   +LOAD .* RW +0x1000
   +DYNAMIC .* RW +0x4
  
  Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 14 entries:
   Offset +Info +Type +Sym.Value +Sym. Name \+ Addend
---- binutils-2.23.52.0.1/ld/testsuite/ld-s390/tlspic_64.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-s390/tlspic_64.rd
+--- binutils-2.24/ld/testsuite/ld-s390/tlspic_64.rd
++++ binutils-2.24/ld/testsuite/ld-s390/tlspic_64.rd
 @@ -39,6 +39,7 @@ Program Headers:
   +LOAD .* RW +0x1000
   +DYNAMIC .* RW +0x8
  
  Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 14 entries:
   +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
---- binutils-2.23.52.0.1/ld/testsuite/ld-sh/tlsbin-2.d
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-sh/tlsbin-2.d
+--- binutils-2.24/ld/testsuite/ld-sh/tlsbin-2.d
++++ binutils-2.24/ld/testsuite/ld-sh/tlsbin-2.d
 @@ -44,6 +44,7 @@ Program Headers:
   +LOAD.*
   +DYNAMIC.*
  
  Relocation section '\.rela\.dyn' at offset 0x[0-9a-f]+ contains 4 entries:
   Offset +Info +Type +Sym\.Value +Sym\. Name \+ Addend
---- binutils-2.23.52.0.1/ld/testsuite/ld-sh/tlspic-2.d
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-sh/tlspic-2.d
+--- binutils-2.24/ld/testsuite/ld-sh/tlspic-2.d
++++ binutils-2.24/ld/testsuite/ld-sh/tlspic-2.d
 @@ -32,7 +32,7 @@ Key to Flags:
  
  Elf file type is DYN \(Shared object file\)
  
  Relocation section '\.rela\.dyn' at offset 0x[0-9a-f]+ contains 10 entries:
   Offset +Info +Type +Sym\.Value +Sym\. Name \+ Addend
---- binutils-2.23.52.0.1/ld/testsuite/ld-sparc/gotop32.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-sparc/gotop32.rd
+--- binutils-2.24/ld/testsuite/ld-sparc/gotop32.rd
++++ binutils-2.24/ld/testsuite/ld-sparc/gotop32.rd
 @@ -31,6 +31,7 @@ Program Headers:
   +LOAD +0x0+ 0x0+ 0x0+ 0x0+2000 0x0+2000 R E 0x10000
   +LOAD +0x0+2000 0x0+12000 0x0+12000 0x0+2000 0x0+2000 RW +0x10000
  #...
  
  Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entries:
---- binutils-2.23.52.0.1/ld/testsuite/ld-sparc/gotop64.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-sparc/gotop64.rd
+--- binutils-2.24/ld/testsuite/ld-sparc/gotop64.rd
++++ binutils-2.24/ld/testsuite/ld-sparc/gotop64.rd
 @@ -31,6 +31,7 @@ Program Headers:
   +LOAD +0x0+ 0x0+ 0x0+ 0x0+2000 0x0+2000 R E 0x100000
   +LOAD +0x0+2000 0x0+102000 0x0+102000 0x0+2000 0x0+2000 RW +0x100000
  #...
  
  Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entries:
---- binutils-2.23.52.0.1/ld/testsuite/ld-sparc/tlssunbin32.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-sparc/tlssunbin32.rd
+--- binutils-2.24/ld/testsuite/ld-sparc/tlssunbin32.rd
++++ binutils-2.24/ld/testsuite/ld-sparc/tlssunbin32.rd
 @@ -30,13 +30,14 @@ There are [0-9]+ program headers, starting at offset [0-9]+
  
  Program Headers:
  #...
  
  Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 4 entries:
---- binutils-2.23.52.0.1/ld/testsuite/ld-sparc/tlssunbin64.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-sparc/tlssunbin64.rd
+--- binutils-2.24/ld/testsuite/ld-sparc/tlssunbin64.rd
++++ binutils-2.24/ld/testsuite/ld-sparc/tlssunbin64.rd
 @@ -30,13 +30,14 @@ There are [0-9]+ program headers, starting at offset [0-9]+
  
  Program Headers:
  #...
  
  Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 4 entries:
---- binutils-2.23.52.0.1/ld/testsuite/ld-sparc/tlssunnopic32.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-sparc/tlssunnopic32.rd
+--- binutils-2.24/ld/testsuite/ld-sparc/tlssunnopic32.rd
++++ binutils-2.24/ld/testsuite/ld-sparc/tlssunnopic32.rd
 @@ -32,6 +32,7 @@ Program Headers:
   +LOAD .* RW +0x10000
   +DYNAMIC .* RW +0x4
  #...
  
  Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 12 entries:
---- binutils-2.23.52.0.1/ld/testsuite/ld-sparc/tlssunnopic64.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-sparc/tlssunnopic64.rd
+--- binutils-2.24/ld/testsuite/ld-sparc/tlssunnopic64.rd
++++ binutils-2.24/ld/testsuite/ld-sparc/tlssunnopic64.rd
 @@ -32,6 +32,7 @@ Program Headers:
   +LOAD .* RW +0x100000
   +DYNAMIC .* RW +0x8
  #...
  
  Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 14 entries:
---- binutils-2.23.52.0.1/ld/testsuite/ld-sparc/tlssunpic32.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-sparc/tlssunpic32.rd
+--- binutils-2.24/ld/testsuite/ld-sparc/tlssunpic32.rd
++++ binutils-2.24/ld/testsuite/ld-sparc/tlssunpic32.rd
 @@ -36,6 +36,7 @@ Program Headers:
   +LOAD +0x0+2000 0x0+12000 0x0+12000 0x0+184 0x0+184 RWE 0x10000
   +DYNAMIC +0x0+2060 0x0+12060 0x0+12060 0x0+98 0x0+98 RW +0x4
  #...
  
  Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 14 entries:
---- binutils-2.23.52.0.1/ld/testsuite/ld-sparc/tlssunpic64.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-sparc/tlssunpic64.rd
+--- binutils-2.24/ld/testsuite/ld-sparc/tlssunpic64.rd
++++ binutils-2.24/ld/testsuite/ld-sparc/tlssunpic64.rd
 @@ -36,6 +36,7 @@ Program Headers:
   +LOAD +0x0+2000 0x0+102000 0x0+102000 0x0+3a0 0x0+3a0 RWE 0x100000
   +DYNAMIC +0x0+2060 0x0+102060 0x0+102060 0x0+130 0x0+130 RW +0x8
  #...
  
  Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 14 entries:
---- binutils-2.23.52.0.1/ld/testsuite/ld-x86-64/tlsgdesc.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-x86-64/tlsgdesc.rd
+--- binutils-2.24/ld/testsuite/ld-x86-64/tlsgdesc.rd
++++ binutils-2.24/ld/testsuite/ld-x86-64/tlsgdesc.rd
 @@ -36,12 +36,14 @@ Program Headers:
   +LOAD.*
   +LOAD.*
  
  Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 8 entries:
   +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
---- binutils-2.23.52.0.1/ld/testsuite/ld-x86-64/tlspic.rd
-+++ binutils-2.23.52.0.1/ld/testsuite/ld-x86-64/tlspic.rd
+--- binutils-2.24/ld/testsuite/ld-x86-64/tlspic.rd
++++ binutils-2.24/ld/testsuite/ld-x86-64/tlspic.rd
 @@ -40,6 +40,7 @@ Program Headers:
-  +LOAD +0x0+11ac 0x0+2011ac 0x0+2011ac 0x0+244 0x0+244 RW +0x200000
-  +DYNAMIC +0x0+1210 0x0+201210 0x0+201210 0x0+130 0x0+130 RW +0x8
-  +TLS +0x0+11ac 0x0+2011ac 0x0+2011ac 0x0+60 0x0+80 R +0x1
+  +LOAD +0x0+131a 0x0+20131a 0x0+20131a 0x0+246 0x0+246 RW +0x200000
+  +DYNAMIC +0x0+1380 0x0+201380 0x0+201380 0x0+130 0x0+130 RW +0x8
+  +TLS +0x0+131a 0x0+20131a 0x0+20131a 0x0+60 0x0+80 R +0x1
 + +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48]
  
   Section to Segment mapping:
diff --git a/binutils/patches/binutils-2.24-set-section-macros.patch0 b/binutils/patches/binutils-2.24-set-section-macros.patch0
new file mode 100644 (file)
index 0000000..6171c48
--- /dev/null
@@ -0,0 +1,103 @@
+diff -rcp ../binutils-2.24.orig/bfd/bfd-in2.h bfd/bfd-in2.h
+*** ../binutils-2.24.orig/bfd/bfd-in2.h        2014-04-22 12:03:35.226872578 +0100
+--- bfd/bfd-in2.h      2014-04-22 12:07:51.556393678 +0100
+*************** typedef struct bfd_section *sec_ptr;
+*** 294,302 ****
+  
+  #define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
+  
+- #define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE)
+- #define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
+- #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
+  /* Find the address one past the end of SEC.  */
+  #define bfd_get_section_limit(bfd, sec) \
+    (((bfd)->direction != write_direction && (sec)->rawsize != 0       \
+--- 294,299 ----
+*************** struct relax_table {
+*** 1592,1597 ****
+--- 1589,1620 ----
+    int size;
+  };
+  
++ /* Note: the following are provided as inline functions rather than macros
++    because not all callers use the return value.  A macro implementation
++    would use a comma expression, eg: "((ptr)->foo = val, TRUE)" and some
++    compilers will complain about comma expressions that have no effect.  */
++ static inline bfd_boolean
++ bfd_set_section_userdata (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, void * val)
++ {
++   ptr->userdata = val;
++   return TRUE;
++ }
++ 
++ static inline bfd_boolean
++ bfd_set_section_vma (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, bfd_vma val)
++ {
++   ptr->vma = ptr->lma = val;
++   ptr->user_set_vma = TRUE;
++   return TRUE;
++ }
++ 
++ static inline bfd_boolean
++ bfd_set_section_alignment (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, unsigned int val)
++ {
++   ptr->alignment_power = val;
++   return TRUE;
++ }
++ 
+  /* These sections are global, and are managed by BFD.  The application
+     and target back end are not permitted to change the values in
+     these sections.  */
+diff -rcp ../binutils-2.24.orig/bfd/bfd-in.h bfd/bfd-in.h
+*** ../binutils-2.24.orig/bfd/bfd-in.h 2014-04-22 12:03:35.272868967 +0100
+--- bfd/bfd-in.h       2014-04-22 12:06:12.850914084 +0100
+*************** typedef struct bfd_section *sec_ptr;
+*** 287,295 ****
+  
+  #define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
+  
+- #define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE)
+- #define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
+- #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
+  /* Find the address one past the end of SEC.  */
+  #define bfd_get_section_limit(bfd, sec) \
+    (((bfd)->direction != write_direction && (sec)->rawsize != 0       \
+--- 287,292 ----
+diff -rcp ../binutils-2.24.orig/bfd/section.c bfd/section.c
+*** ../binutils-2.24.orig/bfd/section.c        2014-04-22 12:03:35.215873442 +0100
+--- bfd/section.c      2014-04-22 12:06:55.795118059 +0100
+*************** CODE_FRAGMENT
+*** 542,547 ****
+--- 542,573 ----
+  .  int size;
+  .};
+  .
++ .{* Note: the following are provided as inline functions rather than macros
++ .   because not all callers use the return value.  A macro implementation
++ .   would use a comma expression, eg: "((ptr)->foo = val, TRUE)" and some
++ .   compilers will complain about comma expressions that have no effect.  *}
++ .static inline bfd_boolean
++ .bfd_set_section_userdata (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, void * val)
++ .{
++ .  ptr->userdata = val;
++ .  return TRUE;
++ .}
++ .
++ .static inline bfd_boolean
++ .bfd_set_section_vma (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, bfd_vma val)
++ .{
++ .  ptr->vma = ptr->lma = val;
++ .  ptr->user_set_vma = TRUE;
++ .  return TRUE;
++ .}
++ .
++ .static inline bfd_boolean
++ .bfd_set_section_alignment (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, unsigned int val)
++ .{
++ .  ptr->alignment_power = val;
++ .  return TRUE;
++ .}
++ .
+  .{* These sections are global, and are managed by BFD.  The application
+  .   and target back end are not permitted to change the values in
+  .   these sections.  *}
diff --git a/binutils/patches/binutils-2.24-symbol-warning.patch b/binutils/patches/binutils-2.24-symbol-warning.patch
new file mode 100644 (file)
index 0000000..aff6c48
--- /dev/null
@@ -0,0 +1,114 @@
+From 4c6d802e592b3762a149c343bc5722e065e57841 Mon Sep 17 00:00:00 2001
+From: H.J. Lu <hjl.tools@gmail.com>
+Date: Wed, 26 Mar 2014 12:18:59 -0700
+Subject: [PATCH] Scan all input files for symbol reference warning
+
+This patch scans all input files for symbol reference warning if the
+symbol reference doesn't exist in the current input file.
+
+ld/
+
+       PR ld/16756
+       * ldmain.c (symbol_warning): New function.
+       (warning_callback): Use it.  Scan all input files for a reference
+       to SYMBOL.
+
+ld/testsuite/
+
+       PR ld/16756
+       * ld-plugin/lto.exp: Expect filename and line number for PR
+       ld/12760 test.
+---
+ ld/ChangeLog                   |    7 ++++
+ ld/ldmain.c                    |   43 ++++++++++++++++----------
+ ld/testsuite/ChangeLog         |   64 ++++++++++++++++++++++------------------
+ ld/testsuite/ld-plugin/lto.exp |    4 +-
+ 4 files changed, 70 insertions(+), 48 deletions(-)
+
+diff --git a/ld/ldmain.c b/ld/ldmain.c
+index ffc9f84..14253a6 100644
+--- a/ld/ldmain.c
++++ b/ld/ldmain.c
+@@ -1150,6 +1150,25 @@ struct warning_callback_info
+   asymbol **asymbols;
+ };
++/* Look through the relocs to see if we can find a plausible address
++   for SYMBOL in ABFD.  Return TRUE if found.  Otherwise return FALSE.  */
++
++static bfd_boolean
++symbol_warning (const char *warning, const char *symbol, bfd *abfd)
++{
++  struct warning_callback_info cinfo;
++
++  if (!bfd_generic_link_read_symbols (abfd))
++    einfo (_("%B%F: could not read symbols: %E\n"), abfd);
++
++  cinfo.found = FALSE;
++  cinfo.warning = warning;
++  cinfo.symbol = symbol;
++  cinfo.asymbols = bfd_get_outsymbols (abfd);
++  bfd_map_over_sections (abfd, warning_find_reloc, &cinfo);
++  return cinfo.found;
++}
++
+ /* This is called when there is a reference to a warning symbol.  */
+ static bfd_boolean
+--- a/ld/ldmain.c      2014-06-24 14:04:00.700594584 -0400
++++ b/ld/ldmain.c      2014-06-24 14:07:19.452270808 -0400
+@@ -1172,24 +1172,14 @@
+     einfo ("%P: %s%s\n", _("warning: "), warning);
+   else if (symbol == NULL)
+     einfo ("%B: %s%s\n", abfd, _("warning: "), warning);
+-  else if ((abfd->flags & BFD_PLUGIN) == 0)
++  else if (! symbol_warning (warning, symbol, abfd))
+     {
+-      struct warning_callback_info cinfo;
+-
+-      /* Look through the relocs to see if we can find a plausible
+-       address.  */
+-
+-      if (!bfd_generic_link_read_symbols (abfd))
+-      einfo (_("%B%F: could not read symbols: %E\n"), abfd);
+-
+-      cinfo.found = FALSE;
+-      cinfo.warning = warning;
+-      cinfo.symbol = symbol;
+-      cinfo.asymbols = bfd_get_outsymbols (abfd);
+-      bfd_map_over_sections (abfd, warning_find_reloc, &cinfo);
+-
+-      if (! cinfo.found)
+-      einfo ("%B: %s%s\n", abfd, _("warning: "), warning);
++      bfd *b;
++      /* Search all input files for a reference to SYMBOL.  */
++      for (b = info->input_bfds; b; b = b->link_next)
++      if (b != abfd && symbol_warning (warning, symbol, b))
++        return TRUE;
++      einfo ("%B: %s%s\n", abfd, _("warning: "), warning);
+     }
+   return TRUE;
+diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
+index af7307f..53543a6 100644
+--- a/ld/testsuite/ld-plugin/lto.exp
++++ b/ld/testsuite/ld-plugin/lto.exp
+@@ -116,14 +116,14 @@ set lto_link_tests {
+    "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12758a.o -Wl,--start-group tmpdir/libpr12758.a -Wl,--end-group" ""
+    {dummy.c} {} "pr12758.exe"}
+   {"Build libdummy.a PR ld/12760"
+-   "" ""
++   "" "-g -O0"
+    {pr12760a.c} {} "libdummy.a"}
+   {"Build libpr12760.a"
+    "" "-flto -O2 -ffat-lto-objects"
+    {pr12760b.c} {} "libpr12760.a"}
+   {"PR ld/12760"
+    "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12760a.o -Wl,--start-group tmpdir/libpr12760.a -Wl,--end-group" ""
+-   {dummy.c} {} "pr12760.exe" "c" "warning: Bad bar"}
++   {dummy.c} {} "pr12760.exe" "c" "pr12760a.c:6: warning: Bad bar"}
+   {"Build libpr13183.a"
+    "-T" "-flto -O2 -ffat-lto-objects"
+    {pr13183a.c} {} "libpr13183.a"}
+-- 
+1.7.1
diff --git a/binutils/patches/binutils-2.24-use-relro.patch b/binutils/patches/binutils-2.24-use-relro.patch
new file mode 100644 (file)
index 0000000..db3276b
--- /dev/null
@@ -0,0 +1,9 @@
+background:
+http://www.airs.com/blog/archives/189
+
+--- binutils/ld/ldmain.c
++++ binutils/ld/ldmain.c
+@@ -293,2 +293,3 @@ main (int argc, char **argv)
+   link_info.combreloc = TRUE;
++  link_info.relro = TRUE;
+   link_info.strip_discarded = TRUE;
diff --git a/binutils/patches/binutils-2.24-weak-sym-merge.patch0 b/binutils/patches/binutils-2.24-weak-sym-merge.patch0
new file mode 100644 (file)
index 0000000..0625f0d
--- /dev/null
@@ -0,0 +1,22 @@
+*** ../binutils-2.24.orig/bfd/elflink.c        2014-08-15 14:12:59.933394436 +0100
+--- bfd/elflink.c      2014-08-15 14:40:54.787075416 +0100
+*************** _bfd_elf_merge_symbol (bfd *abfd,
+*** 1437,1443 ****
+        if (!(oldbfd != NULL
+           && (oldbfd->flags & BFD_PLUGIN) != 0
+           && (abfd->flags & BFD_PLUGIN) == 0))
+!      *skip = TRUE;
+  
+        /* Merge st_other.  If the symbol already has a dynamic index,
+        but visibility says it should not be visible, turn it into a
+--- 1437,1446 ----
+        if (!(oldbfd != NULL
+           && (oldbfd->flags & BFD_PLUGIN) != 0
+           && (abfd->flags & BFD_PLUGIN) == 0))
+!      {
+!        newdef = FALSE;
+!        *skip = TRUE;
+!      }
+  
+        /* Merge st_other.  If the symbol already has a dynamic index,
+        but visibility says it should not be visible, turn it into a
diff --git a/binutils/patches/binutils-HEAD-change-ld-notice-interface.patch b/binutils/patches/binutils-HEAD-change-ld-notice-interface.patch
new file mode 100644 (file)
index 0000000..db2ea9b
--- /dev/null
@@ -0,0 +1,398 @@
+From 4613510308cea27713e8c7424b2afee9b99f6226 Mon Sep 17 00:00:00 2001
+From: Alan Modra <amodra@gmail.com>
+Date: Tue, 12 Aug 2014 10:43:33 +0930
+Subject: [PATCH] Change ld "notice" interface for better handling of
+ indirect symbols
+
+The main aim of this change was to have non_ir_ref set correctly on
+new indirect symbols.  I could have added a "copy" param to the "notice"
+function, so that indirect symbols could be created in plugin_notice,
+but it seemed cleaner to create indirect syms earlier and pass them
+rather than "string" to "notice".
+
+include/
+       * bfdlink.h (struct bfd_link_callbacks <notice>): Remove "string"
+       param, add "inh".
+bfd/
+       * coff-aux.c (coff_m68k_aux_link_add_one_symbol): Only call "notice"
+       here when not calling the generic add_symbol function.  Formatting.
+       Correct handling of indirect symbols.  Update notice call.
+       * elflink.c (_bfd_elf_notice_as_needed): Update notice call.
+       * linker.c (_bfd_generic_link_add_one_symbol): Create indirect
+       symbols early.  Update notice call.  Add comments regarding weak
+       symbols vs. indirect.
+ld/
+       * ldmain.c (notice): Update args.
+       * plugin.c (plugin_notice): Likewise.  Follow warning sym link.
+       Handle new indirect symbol.
+---
+ bfd/coff-aux.c    | 62 ++++++++++++++++++++++-------------------
+ bfd/elflink.c     |  2 +-
+ bfd/linker.c      | 82 +++++++++++++++++++++++++++++--------------------------
+ include/bfdlink.h | 13 ++++-----
+ ld/ldmain.c       |  6 ++--
+ ld/plugin.c       | 33 ++++++++++++----------
+ 9 files changed, 128 insertions(+), 91 deletions(-)
+
+diff --git a/bfd/coff-aux.c b/bfd/coff-aux.c
+index e79c77a..d95b98b 100644
+--- a/bfd/coff-aux.c
++++ b/bfd/coff-aux.c
+@@ -73,20 +73,17 @@ coff_m68k_aux_link_add_one_symbol (struct bfd_link_info *info,
+                                  bfd_boolean collect,
+                                  struct bfd_link_hash_entry **hashp)
+ {
+-  struct bfd_link_hash_entry *h;
++  struct bfd_link_hash_entry *h, *inh, *t;
+-  if ((flags & (BSF_WARNING | BSF_CONSTRUCTOR | BSF_WEAK)) == 0 &&
+-      !bfd_is_und_section (section) &&
+-      !bfd_is_com_section (section))
++  if ((flags & (BSF_WARNING | BSF_CONSTRUCTOR | BSF_WEAK)) == 0
++      && !bfd_is_und_section (section)
++      && !bfd_is_com_section (section))
+     {
+       /* The new symbol is a definition or an indirect definition */
+       /* This bit copied from linker.c */
+       if (hashp != NULL && *hashp != NULL)
+-      {
+-        h = *hashp;
+-        BFD_ASSERT (strcmp (h->root.string, name) == 0);
+-      }
++      h = *hashp;
+       else
+       {
+         h = bfd_link_hash_lookup (info->hash, name, TRUE, copy, FALSE);
+@@ -98,37 +95,46 @@ coff_m68k_aux_link_add_one_symbol (struct bfd_link_info *info,
+           }
+       }
+-      if (info->notice_hash != (struct bfd_hash_table *) NULL
+-        && (bfd_hash_lookup (info->notice_hash, name, FALSE, FALSE)
+-            != (struct bfd_hash_entry *) NULL))
+-      {
+-        if (! (*info->callbacks->notice) (info, h, abfd, section, value,
+-                                          flags, string))
+-          return FALSE;
+-      }
+-
+       if (hashp != (struct bfd_link_hash_entry **) NULL)
+       *hashp = h;
+       /* end duplication from linker.c */
+-      if (h->type == bfd_link_hash_defined
+-        || h->type == bfd_link_hash_indirect)
++      t = h;
++      inh = NULL;
++      if (h->type == bfd_link_hash_indirect)
+       {
+-        asection *msec;
++        inh = h->u.i.link;
++        t = inh;
++      }
+-        if (h->type == bfd_link_hash_defined)
+-          msec = h->u.def.section;
+-        else
+-          msec = bfd_ind_section_ptr;
++      if (t->type == bfd_link_hash_defined)
++      {
++        asection *msec = t->u.def.section;
++        bfd_boolean special = FALSE;
+         if (bfd_is_abs_section (msec) && !bfd_is_abs_section (section))
+           {
+-            h->u.def.section = section;
+-            h->u.def.value = value;
+-            return TRUE;
++            t->u.def.section = section;
++            t->u.def.value = value;
++            special = TRUE;
+           }
+         else if (bfd_is_abs_section (section) && !bfd_is_abs_section (msec))
+-          return TRUE;
++          special = TRUE;
++
++        if (special)
++          {
++            if (info->notice_all
++                || (info->notice_hash != NULL
++                    && bfd_hash_lookup (info->notice_hash, name,
++                                        FALSE, FALSE) != NULL))
++              {
++                if (!(*info->callbacks->notice) (info, h, inh,
++                                                 abfd, section, value, flags))
++                  return FALSE;
++              }
++
++            return TRUE;
++          }
+       }
+     }
+diff --git a/bfd/elflink.c b/bfd/elflink.c
+index 69a87a6..de0a734 100644
+--- a/bfd/elflink.c
++++ b/bfd/elflink.c
+@@ -3299,7 +3299,7 @@ _bfd_elf_notice_as_needed (bfd *ibfd,
+                          struct bfd_link_info *info,
+                          enum notice_asneeded_action act)
+ {
+-  return (*info->callbacks->notice) (info, NULL, ibfd, NULL, act, 0, NULL);
++  return (*info->callbacks->notice) (info, NULL, NULL, ibfd, NULL, act, 0);
+ }
+ /* Add symbols from an ELF object file to the linker hash table.  */
+diff --git a/bfd/linker.c b/bfd/linker.c
+index 1a5ecef..abdf5b0 100644
+--- a/bfd/linker.c
++++ b/bfd/linker.c
+@@ -1442,13 +1442,23 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info,
+ {
+   enum link_row row;
+   struct bfd_link_hash_entry *h;
++  struct bfd_link_hash_entry *inh = NULL;
+   bfd_boolean cycle;
+   BFD_ASSERT (section != NULL);
+   if (bfd_is_ind_section (section)
+       || (flags & BSF_INDIRECT) != 0)
+-    row = INDR_ROW;
++    {
++      row = INDR_ROW;
++      /* Create the indirect symbol here.  This is for the benefit of
++       the plugin "notice" function.
++       STRING is the name of the symbol we want to indirect to.  */
++      inh = bfd_wrapped_link_hash_lookup (abfd, info, string, TRUE,
++                                        copy, FALSE);
++      if (inh == NULL)
++      return FALSE;
++    }
+   else if ((flags & BSF_WARNING) != 0)
+     row = WARN_ROW;
+   else if ((flags & BSF_CONSTRUCTOR) != 0)
+@@ -1493,8 +1503,8 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info,
+       || (info->notice_hash != NULL
+         && bfd_hash_lookup (info->notice_hash, name, FALSE, FALSE) != NULL))
+     {
+-      if (! (*info->callbacks->notice) (info, h,
+-                                      abfd, section, value, flags, string))
++      if (! (*info->callbacks->notice) (info, h, inh,
++                                      abfd, section, value, flags))
+       return FALSE;
+     }
+@@ -1728,44 +1738,40 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info,
+           return FALSE;
+         /* Fall through.  */
+       case IND:
+-        /* Create an indirect symbol.  */
+-        {
+-          struct bfd_link_hash_entry *inh;
+-
+-          /* STRING is the name of the symbol we want to indirect
+-             to.  */
+-          inh = bfd_wrapped_link_hash_lookup (abfd, info, string, TRUE,
+-                                              copy, FALSE);
+-          if (inh == NULL)
++        if (inh->type == bfd_link_hash_indirect
++            && inh->u.i.link == h)
++          {
++            (*_bfd_error_handler)
++              (_("%B: indirect symbol `%s' to `%s' is a loop"),
++               abfd, name, string);
++            bfd_set_error (bfd_error_invalid_operation);
+             return FALSE;
+-          if (inh->type == bfd_link_hash_indirect
+-              && inh->u.i.link == h)
+-            {
+-              (*_bfd_error_handler)
+-                (_("%B: indirect symbol `%s' to `%s' is a loop"),
+-                 abfd, name, string);
+-              bfd_set_error (bfd_error_invalid_operation);
+-              return FALSE;
+-            }
+-          if (inh->type == bfd_link_hash_new)
+-            {
+-              inh->type = bfd_link_hash_undefined;
+-              inh->u.undef.abfd = abfd;
+-              bfd_link_add_undef (info->hash, inh);
+-            }
++          }
++        if (inh->type == bfd_link_hash_new)
++          {
++            inh->type = bfd_link_hash_undefined;
++            inh->u.undef.abfd = abfd;
++            bfd_link_add_undef (info->hash, inh);
++          }
+-          /* If the indirect symbol has been referenced, we need to
+-             push the reference down to the symbol we are
+-             referencing.  */
+-          if (h->type != bfd_link_hash_new)
+-            {
+-              row = UNDEF_ROW;
+-              cycle = TRUE;
+-            }
++        /* If the indirect symbol has been referenced, we need to
++           push the reference down to the symbol we are referencing.  */
++        if (h->type != bfd_link_hash_new)
++          {
++            /* ??? If inh->type == bfd_link_hash_undefweak this
++               converts inh to bfd_link_hash_undefined.  */
++            row = UNDEF_ROW;
++            cycle = TRUE;
++          }
+-          h->type = bfd_link_hash_indirect;
+-          h->u.i.link = inh;
+-        }
++        h->type = bfd_link_hash_indirect;
++        h->u.i.link = inh;
++        /* Not setting h = h->u.i.link here means that when cycle is
++           set above we'll always go to REFC, and then cycle again
++           to the indirected symbol.  This means that any successful
++           change of an existing symbol to indirect counts as a
++           reference.  ??? That may not be correct when the existing
++           symbol was defweak.  */
+         break;
+       case SET:
+diff --git a/include/bfdlink.h b/include/bfdlink.h
+index 58dba2a..125683d 100644
+--- a/include/bfdlink.h
++++ b/include/bfdlink.h
+@@ -640,15 +640,14 @@ struct bfd_link_callbacks
+     (struct bfd_link_info *, const char *name,
+      bfd *abfd, asection *section, bfd_vma address);
+   /* A function which is called when a symbol in notice_hash is
+-     defined or referenced.  H is the symbol.  ABFD, SECTION and
+-     ADDRESS are the (new) value of the symbol.  If SECTION is
+-     bfd_und_section, this is a reference.  FLAGS are the symbol
+-     BSF_* flags.  STRING is the name of the symbol to indirect to if
+-     the sym is indirect, or the warning string if a warning sym.  */
++     defined or referenced.  H is the symbol, INH the indirect symbol
++     if applicable.  ABFD, SECTION and ADDRESS are the (new) value of
++     the symbol.  If SECTION is bfd_und_section, this is a reference.
++     FLAGS are the symbol BSF_* flags.  */
+   bfd_boolean (*notice)
+     (struct bfd_link_info *, struct bfd_link_hash_entry *h,
+-     bfd *abfd, asection *section, bfd_vma address, flagword flags,
+-     const char *string);
++     struct bfd_link_hash_entry *inh,
++     bfd *abfd, asection *section, bfd_vma address, flagword flags);
+   /* Error or warning link info message.  */
+   void (*einfo)
+     (const char *fmt, ...);
+diff --git a/ld/ldmain.c b/ld/ldmain.c
+index ea25afe..77235d5 100644
+--- a/ld/ldmain.c
++++ b/ld/ldmain.c
+@@ -137,7 +137,7 @@ static bfd_boolean unattached_reloc
+   (struct bfd_link_info *, const char *, bfd *, asection *, bfd_vma);
+ static bfd_boolean notice
+   (struct bfd_link_info *, struct bfd_link_hash_entry *,
+-   bfd *, asection *, bfd_vma, flagword, const char *);
++   struct bfd_link_hash_entry *, bfd *, asection *, bfd_vma, flagword);
+ static struct bfd_link_callbacks link_callbacks =
+ {
+@@ -1461,11 +1461,11 @@ unattached_reloc (struct bfd_link_info *info ATTRIBUTE_UNUSED,
+ static bfd_boolean
+ notice (struct bfd_link_info *info,
+       struct bfd_link_hash_entry *h,
++      struct bfd_link_hash_entry *inh ATTRIBUTE_UNUSED,
+       bfd *abfd,
+       asection *section,
+       bfd_vma value,
+-      flagword flags ATTRIBUTE_UNUSED,
+-      const char *string ATTRIBUTE_UNUSED)
++      flagword flags ATTRIBUTE_UNUSED)
+ {
+   const char *name;
+diff --git a/ld/plugin.c b/ld/plugin.c
+index 8d6ae05..8cca7d0 100644
+--- a/ld/plugin.c
++++ b/ld/plugin.c
+@@ -127,8 +127,9 @@ static const size_t tv_header_size = ARRAY_SIZE (tv_header_tags);
+ /* Forward references.  */
+ static bfd_boolean plugin_notice (struct bfd_link_info *,
+-                                struct bfd_link_hash_entry *, bfd *,
+-                                asection *, bfd_vma, flagword, const char *);
++                                struct bfd_link_hash_entry *,
++                                struct bfd_link_hash_entry *,
++                                bfd *, asection *, bfd_vma, flagword);
+ #if !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H)
+@@ -962,16 +963,21 @@ plugin_call_cleanup (void)
+ static bfd_boolean
+ plugin_notice (struct bfd_link_info *info,
+              struct bfd_link_hash_entry *h,
++             struct bfd_link_hash_entry *inh,
+              bfd *abfd,
+              asection *section,
+              bfd_vma value,
+-             flagword flags,
+-             const char *string)
++             flagword flags)
+ {
++  struct bfd_link_hash_entry *orig_h = h;
++
+   if (h != NULL)
+     {
+       bfd *sym_bfd;
++      if (h->type == bfd_link_hash_warning)
++      h = h->u.i.link;
++
+       /* Nothing to do here if this def/ref is from an IR dummy BFD.  */
+       if (is_ir_dummy_bfd (abfd))
+       ;
+@@ -981,16 +987,15 @@ plugin_notice (struct bfd_link_info *info,
+       else if (bfd_is_ind_section (section)
+              || (flags & BSF_INDIRECT) != 0)
+       {
++        /* ??? Some of this is questionable.  See comments in
++           _bfd_generic_link_add_one_symbol for case IND.  */
+         if (h->type != bfd_link_hash_new)
+           {
+-            struct bfd_link_hash_entry *inh;
+-
+             h->non_ir_ref = TRUE;
+-            inh = bfd_wrapped_link_hash_lookup (abfd, info, string, FALSE,
+-                                                FALSE, FALSE);
+-            if (inh != NULL)
+-              inh->non_ir_ref = TRUE;
++            inh->non_ir_ref = TRUE;
+           }
++        else if (inh->type == bfd_link_hash_new)
++          inh->non_ir_ref = TRUE;
+       }
+       /* Nothing to do here for warning symbols.  */
+@@ -1031,13 +1036,13 @@ plugin_notice (struct bfd_link_info *info,
+     }
+   /* Continue with cref/nocrossref/trace-sym processing.  */
+-  if (h == NULL
++  if (orig_h == NULL
+       || orig_notice_all
+       || (info->notice_hash != NULL
+-        && bfd_hash_lookup (info->notice_hash, h->root.string,
++        && bfd_hash_lookup (info->notice_hash, orig_h->root.string,
+                             FALSE, FALSE) != NULL))
+-    return (*orig_callbacks->notice) (info, h,
+-                                    abfd, section, value, flags, string);
++    return (*orig_callbacks->notice) (info, orig_h, inh,
++                                    abfd, section, value, flags);
+   return TRUE;
+ }
+-- 
+1.9.3
+