Bug 9992

Summary: ar has troubles extracting archives
Product: binutils Reporter: Niki W. Waibel <niki.waibel>
Component: binutilsAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: bug-binutils
Priority: P2    
Version: 2.19   
Target Milestone: ---   
Host: i386-pc-solaris2.10 / sparc-sun-solaris2.10 Target: i386-pc-solaris2.10 / sparc-sun-solaris2.10
Build: i386-pc-solaris2.10 / sparc-sun-solaris2.10 Last reconfirmed:
Attachments: contains files referenced in this report
Fix binutils configure script

Description Niki W. Waibel 2009-03-24 14:57:27 UTC
binutils-2.19.51.0.3.20090310
gcc-4.3.3

tested on i386-pc-solaris2.10, sparc-sun-solaris2.10, x86_64-unknown-linux-gnu:
===
x86_64-unknown-linux-gnu $ uname -a
Linux amdlnx-2 2.4.21-58.ELsmp #1 SMP Tue Nov 4 11:38:48 EST 2008 x86_64 GNU/Linux
===
i386-pc-solaris2.10 $ uname -a
SunOS amdsol-1 5.10 Generic_138889-06 i86pc i386 i86pc Solaris
===
sparc-sun-solaris2.10 $ uname -a
SunOS m5000-1 5.10 Generic_138888-01 sun4u sparc SUNW,SPARC-Enterprise Solaris
===

"ar rc" seems to work fine on all platforms.

"ar t" seems to work fine on all platforms (output looks right).

"at tv" reports wrong permissions on i386-pc-solaris2.10 / sparc-sun-solaris2.10!

"ar xv" extracts invalid archives with wrong permissions on i386-pc-solaris2.10
/ sparc-sun-solaris2.10!

===
x86_64-unknown-linux-gnu $ for i in libhello_world.a-i386-pc-solaris2.10
libhello_world.a-sparc-sun-solaris2.10
libhello_world.a-x86_64-unknown-linux-gnu; do ar -tv $i; done
rw-r----- 1062/64000    780 Mar 24 15:21 2009 hello_world.o
rw-r----- 1062/64000    796 Mar 24 15:22 2009 hello_world.o
rw-r----- 1062/64000   1480 Mar 24 15:20 2009 hello_world.o
===
i386-pc-solaris2.10 $ for i in libhello_world.a-i386-pc-solaris2.10
libhello_world.a-sparc-sun-solaris2.10
libhello_world.a-x86_64-unknown-linux-gnu; do ar -tv $i; done
rwx--x--T 64000/12 -18250948 Jan  1 01:00 1970 hello_world.o
rwx--x--T 64000/12 -18250948 Jan  1 01:00 1970 hello_world.o
rw-rwx--T 64000/12 -18250948 Jan  1 01:00 1970 hello_world.o
===
sparc-sun-solaris2.10 $ for i in libhello_world.a-i386-pc-solaris2.10
libhello_world.a-sparc-sun-solaris2.10
libhello_world.a-x86_64-unknown-linux-gnu; do ar -tv $i; done
--------- 64000/68855      0 Jan  1 01:00 1970 hello_world.o
--------- 64000/68855      0 Nov 13 10:29 1969 hello_world.o
--------- 64000/68855      0 Jan  1 01:00 1970 hello_world.o
===

===
x86_64-unknown-linux-gnu $ for i in libhello_world.a-i386-pc-solaris2.10
libhello_world.a-sparc-sun-solaris2.10
libhello_world.a-x86_64-unknown-linux-gnu; do ar -xv $i; ls -l hello_world.o; rm
-f hello_world.o; done
x - hello_world.o
-rw-r----- 1 nwaibel nlstaff 780 2009-03-24 15:34 hello_world.o
x - hello_world.o
-rw-r----- 1 nwaibel nlstaff 796 2009-03-24 15:34 hello_world.o
x - hello_world.o
-rw-r----- 1 nwaibel nlstaff 1480 2009-03-24 15:34 hello_world.o
===
i386-pc-solaris2.10 $ for i in libhello_world.a-i386-pc-solaris2.10
libhello_world.a-sparc-sun-solaris2.10
libhello_world.a-x86_64-unknown-linux-gnu; do ar -xv $i; ls -l hello_world.o; rm
-f hello_world.o; done
x - hello_world.o
ar: libhello_world.a-i386-pc-solaris2.10 is not a valid archive
ls: cannot access hello_world.o: No such file or directory
x - hello_world.o
ar: libhello_world.a-sparc-sun-solaris2.10 is not a valid archive
ls: cannot access hello_world.o: No such file or directory
x - hello_world.o
ar: libhello_world.a-x86_64-unknown-linux-gnu is not a valid archive
ls: cannot access hello_world.o: No such file or directory
===
sparc-sun-solaris2.10 $ for i in libhello_world.a-i386-pc-solaris2.10
libhello_world.a-sparc-sun-solaris2.10
libhello_world.a-x86_64-unknown-linux-gnu; do ar -xv $i; ls -l hello_world.o; rm
-f hello_world.o; done
x - hello_world.o
ar: libhello_world.a-i386-pc-solaris2.10 is not a valid archive
ls: cannot access hello_world.o: No such file or directory
x - hello_world.o
-r-xrw--w- 1 nwaibel nlstaff 0 2009-03-24 15:35 hello_world.o*
x - hello_world.o
ar: libhello_world.a-x86_64-unknown-linux-gnu is not a valid archive
ls: cannot access hello_world.o: No such file or directory
===

... could be an endian issue ...

this bug causes issues when compiling programs that create and extract archives
during their compile process (recognized with gcc-4.3.3 and libX11-1.2 -->
impossible to compile with binutils-2.19.51.0.3.20090310 on i386-pc-solaris2.10
/ sparc-sun-solaris2.10).

things seem to be fine with binutils-2.19.50.0.1.20081007,
but fail on 2.19.51.0.1.20090106 and 2.19.51.0.2.20090204.

will attach test directory
===
$ ls -al
total 33
drwxr-x---  2 nwaibel nlstaff 1024 2009-03-24 15:54 ./
drwx--x--x 31 nwaibel nlstaff 2048 2009-03-24 13:22 ../
-rw-r-----  1 nwaibel nlstaff   86 2009-03-24 13:24 hello_world.c
-rwxr-x---  1 nwaibel nlstaff 6046 2009-03-24 15:21 hello_world-i386-pc-solaris2.10*
-rw-r-----  1 nwaibel nlstaff  780 2009-03-24 15:21
hello_world.o-i386-pc-solaris2.10
-rw-r-----  1 nwaibel nlstaff  796 2009-03-24 15:22
hello_world.o-sparc-sun-solaris2.10
-rw-r-----  1 nwaibel nlstaff 1480 2009-03-24 15:20
hello_world.o-x86_64-unknown-linux-gnu
-rwxr-x---  1 nwaibel nlstaff 6554 2009-03-24 15:22
hello_world-sparc-sun-solaris2.10*
-rwxr-x---  1 nwaibel nlstaff 6653 2009-03-24 15:20
hello_world-x86_64-unknown-linux-gnu*
-rw-r-----  1 nwaibel nlstaff  922 2009-03-24 15:21
libhello_world.a-i386-pc-solaris2.10
-rw-r-----  1 nwaibel nlstaff  938 2009-03-24 15:22
libhello_world.a-sparc-sun-solaris2.10
-rw-r-----  1 nwaibel nlstaff 1622 2009-03-24 15:20
libhello_world.a-x86_64-unknown-linux-gnu
-rw-r-----  1 nwaibel nlstaff  203 2009-03-24 14:14 Makefile
===
for reference.
Comment 1 Niki W. Waibel 2009-03-24 15:00:28 UTC
Created attachment 3841 [details]
contains files referenced in this report
Comment 2 Niki W. Waibel 2009-03-24 16:37:02 UTC
i meant to say:
===
"ar xv" either fails to extract archives (most cases, error message: "... is not
a valid archive") on i386-pc-solaris2.10 / sparc-sun-solaris2.10;

or extracts with wrong permissions and zero size on sparc-sun-solaris2.10 (but
only with archives generated on sparc-sun-solaris2.10).
===
Comment 3 Nick Clifton 2009-03-27 21:04:56 UTC
Created attachment 3852 [details]
Fix binutils configure script
Comment 4 Nick Clifton 2009-03-27 21:07:47 UTC
Hi Niki,

  This was a nasty one.  In the end I tracked the problem down to the configure
script in the binutils directory which was behaving differently from the
configure script in the bfd directory, with the result that the two sets of
sources disagreed on the size of files that were being supported.  Most notably
this meant that the stat structure was a different size when being used by the
bfd library to when it was being used by the binutils programs.

  Please try out the uploaded patch and see if the problems are solved for you.
 (I have included a patch to the binutils/configure file so that you do not have
to run autoconf yourself).

Cheers
  Nick
Comment 5 Niki W. Waibel 2009-03-27 23:33:34 UTC
nick, with your patch ar works perfectly on both platforms. thanks a lot for
this quick fix! niki
Comment 6 Sourceware Commits 2009-03-31 08:08:45 UTC
Subject: Bug 9992

CVSROOT:	/cvs/src
Module name:	src
Changes by:	nickc@sourceware.org	2009-03-31 08:08:33

Modified files:
	binutils       : ChangeLog configure configure.in 

Log message:
	PR 9992
	* configure.in: Import Solaris specific largefile test from
	bfd/configure.in.
	* configure: Regenerate.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/binutils/ChangeLog.diff?cvsroot=src&r1=1.1448&r2=1.1449
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/binutils/configure.diff?cvsroot=src&r1=1.120&r2=1.121
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/binutils/configure.in.diff?cvsroot=src&r1=1.92&r2=1.93

Comment 7 H.J. Lu 2009-04-07 18:02:16 UTC
Fixed.