[PATCH v2] ia64: don't fail when converting binary into ELF

Sergei Trofimovich slyfox@gentoo.org
Fri Dec 27 10:15:00 GMT 2019


From: Sergei Trofimovich <siarheit@google.com>

In ld/PR25316 ia64 is a rare target that fails the following test:
  $ echo hi > hello.123
  $ ia64-unknown-linux-gnu-ld -r -b binary hello.123 -o hello.o
  ia64-unknown-linux-gnu-ld: failed to merge target specific data of file hello.123

There is no need to support binary merging explicitly (as other targets).

bfd/ChangeLog
2019-12-26  Sergei Trofimovich <siarheit@google.com>

        * elfnn-ia64.c (elfNN_ia64_merge_private_bfd_data): don't fail
        on binary inputs ld/PR25316.
        (is_ia64_elf): new helper to filter on ia64 objects.
---
 bfd/ChangeLog    |  6 ++++++
 bfd/elfnn-ia64.c | 10 ++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 073bbb6f2b..cfbd841f79 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2019-12-27  Sergei Trofimovich <siarheit@google.com>
+
+	* elfnn-ia64.c (elfNN_ia64_merge_private_bfd_data): don't fail
+	on binary inputs ld/PR25316.
+	(is_ia64_elf): new helper to filter on ia64 objects.
+
 2019-12-23  Alan Modra  <amodra@gmail.com>
 
 	* vms-alpha.c (add_symbol): Add "max" parameter.  Error on string
diff --git a/bfd/elfnn-ia64.c b/bfd/elfnn-ia64.c
index 459d986c03..f63c431528 100644
--- a/bfd/elfnn-ia64.c
+++ b/bfd/elfnn-ia64.c
@@ -39,6 +39,10 @@
 #define	LOG_SECTION_ALIGN	2
 #endif
 
+#define is_ia64_elf(bfd) \
+  (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
+   && elf_object_id (bfd) == IA64_ELF_DATA)
+
 typedef struct bfd_hash_entry *(*new_hash_entry_func)
   (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
 
@@ -4740,10 +4744,8 @@ elfNN_ia64_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
   flagword in_flags;
   bfd_boolean ok = TRUE;
 
-  /* Don't even pretend to support mixed-format linking.  */
-  if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
-      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
-    return FALSE;
+  if (!is_ia64_elf (ibfd) || !is_ia64_elf (obfd))
+    return TRUE;
 
   in_flags  = elf_elfheader (ibfd)->e_flags;
   out_flags = elf_elfheader (obfd)->e_flags;
-- 
2.24.1



More information about the Binutils mailing list