Discussion:
[Bug binutils/22458] New: libbfd fails to detect elf32-littlearm target when it is compiled with support for all targets
orivej at gmx dot fr
2017-11-19 04:25:45 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=22458

Bug ID: 22458
Summary: libbfd fails to detect elf32-littlearm target when it
is compiled with support for all targets
Product: binutils
Version: 2.29
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: binutils
Assignee: unassigned at sourceware dot org
Reporter: orivej at gmx dot fr
Target Milestone: ---

binutils 2.29.1 compiled with --enable-targets=all do not work with ARM ELF
files unless the target (elf32-littlearm) is specified explicitly. For example
[1],

objdump -t atomic_lock_free.0.o

prints

objdump: atomic_lock_free.0.o: File format is ambiguous
objdump: Matching formats: elf32-littlearm elf32-littlearm-symbian
elf32-littlearm-vxworks

This bug was reportedly solved by the patch in [2], but the patch is present in
the current binutils. elf32-littlearm-symbian and elf32-littlearm-vxworks may
have lost their lower priority since then. Currently I'm using this [3]
workaround.

[1] https://github.com/NixOS/nixpkgs/files/1485206/atomic_lock_free.0.o.gz
[2] https://sourceware.org/ml/binutils/2013-05/msg00271.html
[3]
https://github.com/NixOS/nixpkgs/commit/c76890f2fe24ca64bc216515149f7316080912f0
--
You are receiving this mail because:
You are on the CC list for the bug.
vcunat at gmail dot com
2017-11-19 06:57:13 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=22458

Vladimír Čunát <vcunat at gmail dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |vcunat at gmail dot com
--
You are receiving this mail because:
You are on the CC list for the bug.
John.Ericson at Obsidian dot Systems
2017-12-31 07:42:38 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=22458

John Ericson <John.Ericson at Obsidian dot Systems> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |John.Ericson at Obsidian dot Syste
| |ms
--
You are receiving this mail because:
You are on the CC list for the bug.
amodra at gmail dot com
2018-05-15 02:49:14 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=22458

Alan Modra <amodra at gmail dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |amodra at gmail dot com

--- Comment #1 from Alan Modra <amodra at gmail dot com> ---
Please do fill in host and target. I suspect what you've done is configured
binutils on, say, x86_64-linux with --enable-targets=all. That would make the
primary binutils target x86_64-linux with arm targets secondary. In that case
binutils doesn't know which of the arm targets to choose by default. If you
configure with --target=arm-linuxeabi --enable-targets=all then arm-linuxeabi
becomes the primary target, even if your host is x86_64-linux.

Making your particular arm target higher priority than others by patching
match_priority isn't a solution that can be applied to the main binutils
sources. (Of course, you are welcome to do as you like with your own copy of
the source!)
--
You are receiving this mail because:
You are on the CC list for the bug.
orivej at gmx dot fr
2018-05-15 22:03:27 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=22458

Orivej Desh <orivej at gmx dot fr> changed:

What |Removed |Added
----------------------------------------------------------------------------
Target| |elf32-littlearm
Host| |x86_64 Linux

--- Comment #2 from Orivej Desh <orivej at gmx dot fr> ---
I suspect what you've done is configured binutils on, say, x86_64-linux with --enable-targets=all.
This is correct.
Making your particular arm target higher priority than others by patching match_priority isn't a solution that can be applied to the main binutils sources.
If this is so, you have to close this bug report, but I adhere to the opinion
that you expressed in the linked mail [1] that libbfd should disambiguate
elf32-littlearm-* in favor of elf32-littlearm:

“The first hunk in the following patch stops bfd choosing a generic ELF target
(like elf32-little) when another target is a better match (eg.
elf32-littlearm). The last hunk effectively banishes "File format is
ambiguous" errors for ELF. This might be a little controversial, but if
vxworks, symbian and nacl are confused by using the more general machine
specific ELF target then they really should have specified OS_ABI or
implemented target object_p, archive_p and core_file_p functions.”

We have applied the patch that priorities elf32-littlearm in order to support
Rust tests that expect "nm elf32-object.o" to work (on x86_64 Linux) [2]. It
works when binutils are built without --enable-targets=all by selecting
"elf32-little" target, but fails with "File format is ambiguous" error when
binutils are built with more targets.

[1] https://sourceware.org/ml/binutils/2013-05/msg00271.html
[2] https://github.com/NixOS/nixpkgs/pull/30484#issuecomment-345472766
--
You are receiving this mail because:
You are on the CC list for the bug.
amodra at gmail dot com
2018-05-15 23:56:19 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=22458

Alan Modra <amodra at gmail dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2018-05-15
CC|amodra at gmail dot com |
Assignee|unassigned at sourceware dot org |amodra at gmail dot com
Ever confirmed|0 |1

--- Comment #3 from Alan Modra <amodra at gmail dot com> ---
Huh, I'll have a look at what was supposed to happen with my 2013 patch. The
comment I made then certainly seems to indicate that one of the ARM targets
ought to have been chosen.
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...