Created attachment 6488 [details] A fix for 'ar tv' and 'ar x' This is similar to bug 13534 but with 4+GB files and only impacts 32bit platforms. $ dd if=/dev/zero of=file4G bs=1M count=4196 4196+0 records in 4196+0 records out 4399824896 bytes (4.4 GB) copied, 38.398 s, 115 MB/s $ ~/binutils-cvs/binutils/ar q ar4G.ar file4G /home/fgouget/binutils-cvs/binutils/ar: creating ar4G.ar $ od -a ar4G.ar 0000000 ! < a r c h > nl f i l e 4 G / sp 0000020 sp sp sp sp sp sp sp sp 1 3 4 0 7 8 6 0 0000040 3 0 sp sp 1 0 0 0 sp sp 1 0 0 0 sp sp 0000060 1 0 0 6 4 4 sp sp 4 3 9 9 8 2 4 8 0000100 9 6 ` nl nul nul nul nul nul nul nul nul nul nul nul nul 0000120 nul nul nul nul nul nul nul nul nul nul nul nul nul nul nul nul ^C $ ~/binutils-cvs/binutils/ar tv ar4G.ar rw-r--r-- 1000/1000 104857600 Jun 27 10:38 2012 file4G $ ~/binutils-cvs/binutils/ar x ar4G.ar $ ls -l file4G -rw-r--r-- 1 fgouget fgouget 104857600 Jun 27 11:11 file41G The od command shows that the ar archive was created correctly. However 'ar tv' and 'ar x' think it is a 100MB file which is incorrect. This happens because print_arelt_descr(), print_contents() and extract_file() use 32bit size_t variables instead of bfd_size_type ones.
Created attachment 6489 [details] A fix for 'ar tv' and 'ar x' Updated the commit changelog to reference this bug and be more explicit about the ar commands being fixed.
Note that 'ar p' is also impacted: $ ~/binutils-cvs/binutils/ar p ar4G.ar >file4G $ ls -l file4G -rw-r--r-- 1 fgouget fgouget 104857600 Jun 27 11:29 file4G
Created attachment 6490 [details] A fix for 'ar tv', 'ar p' and 'ar x'
CVSROOT: /cvs/src Module name: src Changes by: nickc@sourceware.org 2012-06-29 12:59:49 Modified files: binutils : ChangeLog ar.c bucomm.c Log message: PR binutils/14302 * bucomm.c (print_arelt_descr): Correctly report the archive size field (for 'ar tv'). * ar.c (print_contents): Use correct types for archive element sizes (for 'ar p'). (extract_file): Likewise (for 'ar x'). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/ChangeLog.diff?cvsroot=src&r1=1.1918&r2=1.1919 http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/ar.c.diff?cvsroot=src&r1=1.84&r2=1.85 http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/bucomm.c.diff?cvsroot=src&r1=1.45&r2=1.46
Hi Francois, Thanks for the bug report and patch, and please accept my apologies in getting round to reviewing it. The patch itself is fine, although there are a couple of places where a comment needs to be updated, and a couple of places where there are now redundant type cases. I have taken care of both of these things and applied your patch. Cheers Nick
Thanks for tweaking the patch so it could be committed.