diff --git a/bfd/elf-attrs.c b/bfd/elf-attrs.c
index bd8ae56678a..12a81181c11 100644
--- a/bfd/elf-attrs.c
+++ b/bfd/elf-attrs.c
@@ -541,9 +541,8 @@ bfd_elf_add_obj_attr_int_string (bfd *abfd, int vendor, unsigned int tag,
   return elf_add_obj_attr_int_string (abfd, vendor, tag, i, s, NULL);
 }
 
-/* Copy the object attributes from IBFD to OBFD.  */
-void
-_bfd_elf_copy_obj_attributes (bfd *ibfd, bfd *obfd)
+static void
+_bfd_elf_copy_obj_attributes_v1 (bfd *ibfd, bfd *obfd)
 {
   obj_attribute *in_attr;
   obj_attribute *out_attr;
@@ -604,6 +603,36 @@ _bfd_elf_copy_obj_attributes (bfd *ibfd, bfd *obfd)
     }
 }
 
+static void
+_bfd_elf_copy_obj_attributes_v2 (bfd *ibfd, bfd *obfd)
+{
+  if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+    return;
+
+  obj_attr_subsection_list *in_attr_subsecs = &elf_obj_attr_subsections (ibfd);
+  obj_attr_subsection_list *out_attr_subsecs = &elf_obj_attr_subsections (obfd);
+
+  for (obj_attr_subsection_v2* isubsec = in_attr_subsecs->first_;
+       isubsec != NULL;
+       isubsec = isubsec->next)
+    {
+      obj_attr_subsection_v2* osubsec =
+	_bfd_elf_obj_attr_subsection_v2_copy (isubsec);
+      LINKED_LIST_APPEND(obj_attr_subsection_v2) (out_attr_subsecs, osubsec);
+    }
+}
+
+/* Copy the object attributes from IBFD to OBFD.  */
+void
+_bfd_elf_copy_obj_attributes (bfd *ibfd, bfd *obfd)
+{
+  if (get_elf_backend_data (ibfd)->obj_attrs_version == 2)
+    _bfd_elf_copy_obj_attributes_v2 (ibfd, obfd);
+  else
+    _bfd_elf_copy_obj_attributes_v1 (ibfd, obfd);
+}
+
 /* Determine whether a GNU object attribute tag takes an integer, a
    string or both.  */
 static int
