Bug 25316 - ia64 ld fails to convert binary into elf: "failed to merge target specific data"
Summary: ia64 ld fails to convert binary into elf: "failed to merge target specific data"
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.32
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-25 22:55 UTC by Sergei Trofimovich
Modified: 2020-01-06 13:10 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
binutils-2.32-ia64-allow-binary-merge.patch (327 bytes, patch)
2019-12-25 23:39 UTC, Sergei Trofimovich
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Trofimovich 2019-12-25 22:55:30 UTC
Bug originally reported at https://bugs.gentoo.org/699180 by Émeric Maschino.

Small reproducer:
  $ 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
  $ ia64-unknown-linux-gnu-ld -r -b binary hello.123 -o hello.o --no-warn-mismatch

It works without problems on other targets. AFAIU glibc's inlent is to:
1. convert arbitrary binary into an ELF file
2. assign a symbol to it
3. refer from other source files

It's a step 1 that fails.

The target is ia64-unknown-linux-gnu.
Comment 1 Sergei Trofimovich 2019-12-25 23:13:04 UTC
AFAIU eary failure happens at input checking against ELF:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=bfd/elfnn-ia64.c;h=459d986c0350f5e5982c7738ea69273f2ae97f7a;hb=HEAD#l4744

4735 static bfd_boolean
4736 elfNN_ia64_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
4737 {
...
4743   /* Don't even pretend to support mixed-format linking.  */
4744   if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
...
4746     return FALSE;

Looks like many other targets have that check but see to work. Does ia64 port miss some earlier step to convert binary into an ELF?
Comment 2 Sergei Trofimovich 2019-12-25 23:39:30 UTC
Created attachment 12147 [details]
binutils-2.32-ia64-allow-binary-merge.patch

It looks like other targets (like mips and riscv64) just skip _private hook entirely. I did the same and got something that looks like an ia64 ELF. Will test a bit.
Comment 3 Sergei Trofimovich 2019-12-26 10:41:56 UTC
Sent for review as https://sourceware.org/ml/binutils/2019-12/msg00340.html
Comment 5 Alan Modra 2020-01-06 13:10:02 UTC
Fixed