Hi, Just moved from binutils 2.22 to 2.23 and ar & ranlib generated bad archives with the message "file truncated". Looking into the problem reveals that in archive.c we have at around line 2414.... file_ptr firstreal; .... file_ptr max_first_real; max_first_real <<= 31; then later we do.... /* The archive file format only has 4 bytes to store the offset of the member. Check to make sure that firstreal has not grown too big. */ if (firstreal >= max_first_real) { bfd_set_error (bfd_error_file_truncated); return FALSE; } I added a check that did this in the errored function. printf("CHECK %d %d (%d)\n",firstreal,max_first_real,sizeof(file_ptr)); It came back with.... CHECK 104 -2147483648 (4) So, shouldn't firstreal/max_first_real be ufile_ptr's ?
Actually, I think I found the patch by Nick Clifton back in June which seems to suggest this is to catch overflows for 4Gb archives. In light of that, I think it really should be ufile_ptr's and that max_first_real should be..... max_first_real = -1; (or 0xffffffff)
Scratch that last comment. Duh.
What is your host machine? What is the size of your file_ptr?
Hi,it's an Atari m68k. file_ptr as mentioned in comment #1 is 4 bytes.
(In reply to comment #4) > Hi,it's an Atari m68k. file_ptr as mentioned in comment #1 is 4 bytes. Does Atari m68k have 64-bit integer?
Yes, 64bits is "unsigned long long"
Do you have a testcase which only requires binutils to reproduce?
Created attachment 6776 [details] test case
With the binary file you can do... ar rcv libxxx.a main.o a - main.o ar: libxxx.a: File truncated
A patch is posted at http://sourceware.org/ml/binutils/2012-12/msg00112.html
CVSROOT: /cvs/src Module name: src Changes by: hjl@sourceware.org 2012-12-09 18:01:39 Modified files: bfd : ChangeLog archive.c Log message: Properly check indicies bigger than 4Gb PR binutils/14933 * archive.c (bsd_write_armap): Properly check indicies bigger than 4Gb. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.5877&r2=1.5878 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/archive.c.diff?cvsroot=src&r1=1.92&r2=1.93
CVSROOT: /cvs/src Module name: src Branch: binutils-2_23-branch Changes by: hjl@sourceware.org 2012-12-09 18:06:44 Modified files: bfd : ChangeLog archive.c Log message: Properly check indicies bigger than 4Gb PR binutils/14933 * archive.c (bsd_write_armap): Properly check indicies bigger than 4Gb. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_23-branch&r1=1.5758.2.31&r2=1.5758.2.32 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/archive.c.diff?cvsroot=src&only_with_tag=binutils-2_23-branch&r1=1.87&r2=1.87.4.1
Fixed.