This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: x86_64-pc-mingw32 native ld.exe randomly failed to read the archive file


Hi Zhou drangon,

could you may try the current SVN version of w64 crt. I think this was 
related to the problem, that in (xxx)o64 methods the errno variable wasn't 
reseted correctly.

Thanks for reporting and cheers,
 i.A. Kai Tietz

|  (\_/)  This is Bunny. Copy and paste Bunny
| (='.'=) into your signature to help him gain
| (")_(") world domination.

------------------------------------------------------------------------------------------
  OneVision Software Entwicklungs GmbH & Co. KG
  Dr.-Leo-Ritter-StraÃe 9 - 93049 Regensburg
  Tel: +49.(0)941.78004.0 - Fax: +49.(0)941.78004.489 - www.OneVision.com
  Commerzbank Regensburg - BLZ 750 400 62 - Konto 6011050
  Handelsregister: HRA 6744, Amtsgericht Regensburg
  KomplementÃrin: OneVision Software Entwicklungs Verwaltungs GmbH
  Dr.-Leo-Ritter-StraÃe 9 â 93049 Regensburg
  Handelsregister: HRB 8932, Amtsgericht Regensburg - GeschÃftsfÃhrer: 
Ulrike DÃhler, Manuela Kluger

binutils-owner@sourceware.org wrote on 04.10.2007 17:02:33:

> I add some printf in binutils/bfd/archive.c to print out some value.
> 
> ----------------------------------------------------------------------
> 380   if (bfd_bread (hdrp, sizeof (struct ar_hdr), abfd) != sizeof
> (struct ar_hdr))
>  381     {
>  382       if (bfd_get_error () != bfd_error_system_call)
>  383     bfd_set_error (bfd_error_no_more_archived_files);
>  384       return NULL;
>  385     }
>  386   printf( "-4- hdr.ar_mag [%s], ARFMAG [%s], mag [%s]\n",
> hdr.ar_fmag, ARFMAG, mag == NULL ? "(null)" : mag );
>  387   if (strncmp (hdr.ar_fmag, ARFMAG, 2) != 0
>  388       && (mag == NULL
>  389       || strncmp (hdr.ar_fmag, mag, 2) != 0))
>  390     {
>  391       bfd_set_error (bfd_error_malformed_archive);
>  392       return NULL;
>  393     }
>  394
>  395   errno = 0;
>  396   parsed_size = strtol (hdr.ar_size, NULL, 10);
>  397   printf( "-4- hdr.ar_size [%s], parsed_size %d, ar_name [%s]\n",
> hdr.ar_size, (int)parsed_size, hdr.ar_name );
>  398   if (errno != 0)
>  399     {
>  400       bfd_set_error (bfd_error_malformed_archive);
>  401       return NULL;
>  402     }
> ---------------------------------------------------------------
> 
> and from the log, the first some times, it reads the archive 
successfully :
> 
> ----------------------------------------------------------
> *** [bfd_generic_archive_p:644] begin read file
> [..\target\x86_64-pc-mingw32\lib\libmingw32.a]
> -4- hdr.ar_mag [`
> ], ARFMAG [`
> ], mag [(null)]
> -4- hdr.ar_size [1758      `
> ], parsed_size 1758, ar_name [/               1191037575  0     0
> 0       1758      `
> ]
> -4- hdr.ar_mag [`
> ], ARFMAG [`
> ], mag [(null)]
> -4- hdr.ar_size [22        `
> ], parsed_size 22, ar_name [//
>      22        `
> ]
> -2- slurp ok
> -4- hdr.ar_mag [`
> ], ARFMAG [`
> ], mag [(null)]
> -4- hdr.ar_size [22        `
> ], parsed_size 22, ar_name [//
>      22        `
> ]
> -3- extended ok
> -4- hdr.ar_mag [`
> ], ARFMAG [`
> ], mag [(null)]
> -4- hdr.ar_size [2985      `
> ], parsed_size 2985, ar_name [crt0_c.o/       1191037555  500   501
> 100664  2985      `
> ]
> *** has map and first object failed.
> -----------------------------------------------------------
> 
> but the last some times, it reads failed
> 
> ------------------------------------------------------------
> *** [bfd_generic_archive_p:644] begin read file
> [..\target\x86_64-pc-mingw32\lib\libmingw32.a]
> -4- hdr.ar_mag [`
> ], ARFMAG [`
> ], mag [(null)]
> -4- hdr.ar_size [1758      `
> ], parsed_size 1758, ar_name [/               1191037575  0     0
> 0       1758      `
> ]
> -4- hdr.ar_mag [`
> ], ARFMAG [`
> ], mag [(null)]
> -4- hdr.ar_size [22        `
> ], parsed_size 22, ar_name [//
>      22        `
> ]
> -2- slurp ok
> -4- hdr.ar_mag [ `], ARFMAG [`
> ], mag [(null)]
> -3- namedata is NULL
> *** slurp or extend failed
> ----------------------------------------------------------
> 
> the hdr head reads " hdr.ar_mag [ `] ", it should be "`v\01",
> I don't understand why this value suddenly goes wrong ...
> 
> 
> 2007/10/4, zhou drangon <drangon.mail@gmail.com>:
> > under x86_64 linux, I built the cross x86_64-pc-mingw32 compiler using 
the
> > latest CVS/SVN head of binutils gcc mingw-w64,
> > and the use the cross compiler to build the native x86_64-pc-mingw32
> > compiler toolchain.
> >
> > Then I ran the compiler in native WinXP x64, the compiler toolchain
> > failed to compile.
> > And I think this is mostly a bug of ld.exe when reading the archive 
file.
> >
> > A very simple "hello world" program t3.c, use gcc.exe and as.exe to
> > create obj file :
> > ..\target\bin\gcc -S t3.c
> > ..\target\bin\as t3.s -o t3.o
> >
> > then the following command can generate t3.exe successfully under 
> command line
> >
> > ..\target\bin\ld.exe -static -o t3.exe
> > ..\target\x86_64-pc-mingw32\lib\crt2.o
> > ..\target\x86_64-pc-mingw32\lib\crtbegin.o   -L
> > ..\target\x86_64-pc-mingw32\lib  t3.o t3_pp.o -lmingw32 -lmoldname
> > -lmingwex -lmsvcrt -luser32 -lkernel32 -ladvapi32 -lshell32 -lmingw32
> > -lmoldname -lmingwex -lmsvcrt
> > ..\target\x86_64-pc-mingw32\lib\crtend.o
> >
> > but if I double the "-lmingw32", it failed to generate exe file
> >
> > ..\target\bin\ld.exe -static -o t3.exe
> > ..\target\x86_64-pc-mingw32\lib\crt2.o
> > ..\target\x86_64-pc-mingw32\lib\crtbegin.o   -L
> > ..\target\x86_64-pc-mingw32\lib  t3.o t3_pp.o -lmingw32 -lmingw32
> > -lmoldname -lmingwex -lmsvcrt
> > -luser32 -lkernel32 -ladvapi32 -lshell32 -lmingw32 -lmoldname -
> lmingwex -lmsvcrt
> >   ..\target\x86_64-pc-mingw32\lib\crtend.o
> > ..\target\x86_64-pc-mingw32\lib\libmingw32.a: file not recognized:
> File format n
> > ot recognized
> >
> > If I run the command similar with the first successful example ( 
> mainly change
> > the "\" to "/" ) in MSYS, run the same command several times,
> > all the odd times run successfule and all the even times run failed.
> > the same command!
> >
> > How can I get more information or debug it ?
> >
> [attachment "ld.log" deleted by Kai Tietz/Onevision] 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]