Bug 4453 - ar doesn't recognize ELF64 on mips
Summary: ar doesn't recognize ELF64 on mips
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.18
: P2 normal
Target Milestone: ---
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-02 20:55 UTC by Aurelien Jarno
Modified: 2008-01-23 23:48 UTC (History)
2 users (show)

See Also:
Host: mipsel-unknown-linux-gnu
Target: mipsel-unknown-linux-gnu
Build: mipsel-unknown-linux-gnu
Last reconfirmed: 2008-01-19 13:03:35


Attachments
potential fix (570 bytes, patch)
2008-01-19 13:14 UTC, Alan Modra
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Aurelien Jarno 2007-05-02 20:55:34 UTC
ar (and ranlib) do not correctly identify ELF64 files in an archive. It 
complains that the format is ambiguous. See the testcase below:

[tesla:~]$ touch foo.c
[tesla:~]$ gcc -mabi=64 -o foo.o -c foo.c
[tesla:~]$ ar cq libfoo.a foo.o
[tesla:~]$ ar t libfoo.a
ar: libfoo.a: File format is ambiguous
ar: Matching formats: ecoff-littlemips ecoff-bigmips elf64-tradlittlemips
[tesla:~]$
Comment 1 Alan Modra 2007-10-09 04:08:26 UTC
Is this still the case with current binutils?  A 2007-09-14 patch may have fixed
this problem.
Comment 2 Alan Modra 2008-01-17 04:30:27 UTC
Not a bug.  If you don't configure binutils with support for a particular
target, ar won't recognize those object files.  mipsel-linux doesn't support
64-bit mips by default.  Use --enable-targets to add more targets.
Comment 3 Aurelien Jarno 2008-01-17 11:35:32 UTC
The binutils on which the problem exists is already built 
with "--enable-targets=mips64el-linux-gnu". It is confirmed by the error 
message:

  ar: Matching formats: ecoff-littlemips ecoff-bigmips elf64-tradlittlemips

What should be the correct --enable-targets for 64-bit mipsel?
Comment 4 H.J. Lu 2008-01-18 17:22:58 UTC
Can you try the current CVS?
Comment 5 Aurelien Jarno 2008-01-18 20:24:06 UTC
I am not able to reproduce the problem anymore with the latest CVS. I guess the 
problem has been fixed recently, but I don't know exactly when.

Thanks for the fix.
Comment 6 Alan Modra 2008-01-19 11:52:32 UTC
I can reproduce the problem with current CVS, and since I closed it incorrectly
at comment #2, I'm reopening.
Comment 7 Alan Modra 2008-01-19 13:14:48 UTC
Created attachment 2206 [details]
potential fix

ar tries to open the archive for all supported bfd targets.  Normally, bfd
checks that the first object in an archive is the same target as the archive to
count as a successful match, but it doesn't do this if the archive has no
armap.	When one of more of the ecoff targets is supported, the ecoff archive
check decides there is no armap (correctly, since there is no ecoff armap), so
the ecoff target is incorrectly taken to match.
Comment 9 Aurelien Jarno 2008-01-23 23:48:47 UTC
Thanks a lot for the fix. I have just tested and it works fine for me.