speclib vs. -lc trouble.

Dave Korn dave.korn.cygwin@googlemail.com
Sun Apr 12 04:43:00 GMT 2009


Dave Korn wrote:
> ld/emultempl/pe.em:gld_${EMULATION_NAME}_after_open()
> 
>     /* This next chunk of code tries to detect the case where you have
>        two import libraries for the same DLL (specifically,
>        symbolically linking libm.a and libc.a in cygwin to
>        libcygwin.a).  In those cases, it's possible for function
>        thunks from the second implib to be used but without the
>        head/tail objects, causing an improper import table.  We detect
>        those cases and rename the "other" import libraries to match
>        the one the head/tail come from, so that the linker will sort
>        things nicely and produce a valid import table.  */
> 
> 
> I think it's also where my libraries are getting swapped over.

  Because, let's see; we do this:

		/* Rename this implib to match the other one.  */
		n = xmalloc (strlen (other_bfd_filename) + 1);
		strcpy (n, other_bfd_filename);
		is->the_bfd->my_archive->filename = n;

and rename the parent BFD owning cygwin_crt0.o from libc.a to libcygwin.a.  If
the BFD is flushed, what's to stop us from re-opening the file descriptor with
the new filename and reading data from offsets corresponding to the offsets in
the old filename, because those offsets are cached in the BFD's archive cache
in the filepos members of the ar_cache entries.

    cheers,
      DaveK



More information about the Cygwin-developers mailing list