public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Re: [Patch/pe-coff] : Add native spelling of import lib names to dynamic lib search
@ 2006-06-20  7:39 Ross Ridge
  0 siblings, 0 replies; 8+ messages in thread
From: Ross Ridge @ 2006-06-20  7:39 UTC (permalink / raw)
  To: binutils

Danny Smith wrote:
>However, the native naming convention for these import libs is "foo.lib"
>and gld_i386pe_open_dynamic_archive does not currently recognize this
>name format. This means that doing something like -L/path/to/sdk -lfoo32
>could link directly to "foo32.dll", rather than find the import lib
>"foo32.lib". 

Umm... doing something like -L/path/to/sdk -lfoo32 already works for
me with ld.  Am I missing something here?

					Ross Ridge

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Patch/pe-coff] : Add native spelling of import lib names to    dynamic  lib search
  2006-06-26 12:32       ` Pedro Alves
@ 2006-06-27 14:57         ` Nick Clifton
  0 siblings, 0 replies; 8+ messages in thread
From: Nick Clifton @ 2006-06-27 14:57 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Binutils, Danny Smith, Christopher Faylor

[-- Attachment #1: Type: text/plain, Size: 1161 bytes --]

Hi Pedro,

>>> This doesn't work correctly. The sizeof (libname_fmt.format) is 
>>> sizeof (const char*), not the sizeof the string.

Doh - and on the 64-bit machine I was using for testing the size was 8 
and so I did not notice any memory leaks.  Sorry about that.

> Sorry for generating a lot of noise, but it seems the patch got mangled 
> up, because I accidently posted as html.
> Here goes the same patch an an attached gzip.

Thanks.  I am still not happy with the static values for the lengths - 
it is too easy to make a mistake and put a wrong value here.  I think 
that the overhead of calling strlen() on the format strings in the array 
is not going to be very big, so it is safer to compute the maximum 
length at run time.  Thus I am going to apply the attached variation of 
your patch instead.

Cheers
   Nick

ld/ChangeLog
2006-06-27  Pedro Alves  <pedro_alves@portugalmail.pt>
	    Nick Clifton  <nickc@redhat.com>

	* emultempl/pe.em (gld_$_open_dynamic_archive): Compute maximum
	length of format strings in the libname_fmt[] array, rather than
	relying upon a statically chosen value.  Adjust xmalloc call to
	use this longest length.



[-- Attachment #2: pe.em.patch --]
[-- Type: text/x-patch, Size: 2604 bytes --]

Index: ld/emultempl/pe.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/pe.em,v
retrieving revision 1.117
diff -c -3 -p -r1.117 pe.em
*** ld/emultempl/pe.em	22 Jun 2006 16:25:36 -0000	1.117
--- ld/emultempl/pe.em	27 Jun 2006 11:37:54 -0000
*************** gld_${EMULATION_NAME}_open_dynamic_archi
*** 1724,1729 ****
--- 1724,1730 ----
  	 so, update the call to xmalloc() below.  */
        { NULL, FALSE }
      };
+   static unsigned int format_max_len = 0;
    const char * filename;
    char * full_string;
    char * base_string;
*************** gld_${EMULATION_NAME}_open_dynamic_archi
*** 1735,1753 ****
  
    filename = entry->filename;
  
    full_string = xmalloc (strlen (search->name)
  			 + strlen (filename)
! 			 /* Allow space for the characters in the format
! 			    string.  Also allow for the path separator that
! 			    is appended after the search name. We actually
! 			    allow 1 more byte than is strictly necessary,
! 			    but this will not hurt.  */
! 			 + sizeof libname_fmt[0].format
  #ifdef DLL_SUPPORT
  			 + (pe_dll_search_prefix
  			    ? strlen (pe_dll_search_prefix) : 0)
  #endif
! 			 + 1);
  
    sprintf (full_string, "%s/", search->name);
    base_string = full_string + strlen (full_string);
--- 1736,1765 ----
  
    filename = entry->filename;
  
+   if (format_max_len == 0)
+     /* We need to allow space in the memory that we are going to allocate
+        for the characters in the format string.  Since the format array is
+        static we only need to calculate this information once.  In theory
+        this value could also be computed statically, but this introduces
+        the possibility for a discrepancy and hence a possible memory
+        corruption.  The lengths we compute here will be too long because
+        they will include any formating characters (%s) in the strings, but
+        this will not matter.  */
+     for (i = 0; libname_fmt[i].format; i++)
+       if (format_max_len < strlen (libname_fmt[i].format))
+ 	format_max_len = strlen (libname_fmt[i].format);
+ 
    full_string = xmalloc (strlen (search->name)
  			 + strlen (filename)
! 			 + format_max_len
  #ifdef DLL_SUPPORT
  			 + (pe_dll_search_prefix
  			    ? strlen (pe_dll_search_prefix) : 0)
  #endif
! 			 /* Allow for the terminating NUL and for the path
! 			    separator character that is inserted between
! 			    search->name and the start of the format string.  */
! 			 + 2);
  
    sprintf (full_string, "%s/", search->name);
    base_string = full_string + strlen (full_string);

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Patch/pe-coff] : Add native spelling of import lib names to    dynamic  lib search
  2006-06-25 13:50     ` Pedro Alves
@ 2006-06-26 12:32       ` Pedro Alves
  2006-06-27 14:57         ` Nick Clifton
  0 siblings, 1 reply; 8+ messages in thread
From: Pedro Alves @ 2006-06-26 12:32 UTC (permalink / raw)
  Cc: Binutils, Danny Smith, Nick Clifton, Christopher Faylor

[-- Attachment #1: Type: text/plain, Size: 1744 bytes --]

Pedro Alves wrote:
 > Pedro Alves wrote:
 >> Nick Clifton wrote:
 >>>>
 >>>>     * emultempl/pe.em 
(gld_${EMULATION_NAME}_open_dynamic_archive):     Restructure.  Add 
native "%s.lib" format to search list
 >>>>     * ld.texinfo (node WIN32): Update documentation on dynamic lib
 >>>>     search order. Add another reason for using import libs.
 >>> 2006-06-19  Danny Smith  <dannysmith@users.sourceforge.net>
 >>>
 >>> Approved and applied.
 >>>
 >>> Note - I slightly changed the construction of the size passed to 
the xmalloc() function, so that instead of using sizeof on a separate 
string, it accesses the libname_fmt structure and pulls a string out of 
there.  I felt that this made it more obvious as to why the value was 
being included in the computation of the amount of memory required.  I 
also added a comment into the declaration of the libname_fmt structure 
to remind future coders to check and update the length if necessary.
 >> This doesn't work correctly. The sizeof (libname_fmt.format) is 
sizeof (const char*), not the sizeof the string.
 >>
 >> Fixed with the following patch. Other possibilities would be to 
s/sizeof/strlen/ or sizeof(*libname_fmt.format),
 >> by I think this way makes the code clearer, and less surprising.
 >>

Sorry for generating a lot of noise, but it seems the patch got mangled 
up, because I accidently posted as html.
Here goes the same patch an an attached gzip.

2006-06-24  Pedro Alves <pedro_alves@portugalmail.pt>

	* emultempl/pe.em (gld_${EMULATION_NAME}_open_dynamic_archive): 		New 
member fixed_len in libname_fmt, representing the length of 	
	the format string minus the length of the formatters. Adjust
	xmalloc call to use the longest of the lengths.

Cheers,
Pedro Alves


[-- Attachment #2: pe.em.diff.gz --]
[-- Type: application/gzip, Size: 1103 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Patch/pe-coff] : Add native spelling of import lib names to   dynamic  lib search
  2006-06-24 17:32   ` Pedro Alves
@ 2006-06-25 13:50     ` Pedro Alves
  2006-06-26 12:32       ` Pedro Alves
  0 siblings, 1 reply; 8+ messages in thread
From: Pedro Alves @ 2006-06-25 13:50 UTC (permalink / raw)
  To: Binutils; +Cc: Danny Smith, Nick Clifton, Christopher Faylor

Pedro Alves wrote:
> Nick Clifton wrote:
>>>
>>>     * emultempl/pe.em (gld_${EMULATION_NAME}_open_dynamic_archive): 
>>>     Restructure.  Add native "%s.lib" format to search list
>>>     * ld.texinfo (node WIN32): Update documentation on dynamic lib
>>>     search order. Add another reason for using import libs.   
>> 2006-06-19  Danny Smith  <dannysmith@users.sourceforge.net>
>>
>> Approved and applied.
>>
>> Note - I slightly changed the construction of the size passed to the 
>> xmalloc() function, so that instead of using sizeof on a separate 
>> string, it accesses the libname_fmt structure and pulls a string out 
>> of there.  I felt that this made it more obvious as to why the value 
>> was being included in the computation of the amount of memory 
>> required.  I also added a comment into the declaration of the 
>> libname_fmt structure to remind future coders to check and update the 
>> length if necessary.
> This doesn't work correctly. The sizeof (libname_fmt.format) is sizeof 
> (const char*), not the sizeof the string.
>
> Fixed with the following patch. Other possibilities would be to 
> s/sizeof/strlen/ or sizeof(*libname_fmt.format),
> by I think this way makes the code clearer, and less surprising.
>
To be clear:
Where I said "Fixed", I meant "This patch is a proposed fix".

Cheers,
Pedro Alves

P.S. Is the mailing list having problems, or is it just me?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Patch/pe-coff] : Add native spelling of import lib names to   dynamic  lib search
  2006-06-22 13:52 ` Nick Clifton
@ 2006-06-24 17:32   ` Pedro Alves
  2006-06-25 13:50     ` Pedro Alves
  0 siblings, 1 reply; 8+ messages in thread
From: Pedro Alves @ 2006-06-24 17:32 UTC (permalink / raw)
  To: Binutils; +Cc: Danny Smith, Nick Clifton, Christopher Faylor

Hi all,

Nick Clifton wrote:
> Hi Danny,
>
>> 2006-06-19  Danny Smith  <dannysmith@users.sourceforge.net>
>>
>>     * emultempl/pe.em (gld_${EMULATION_NAME}_open_dynamic_archive): 
>>     Restructure.  Add native "%s.lib" format to search list
>>     * ld.texinfo (node WIN32): Update documentation on dynamic lib
>>     search order. Add another reason for using import libs.   
>
> Approved and applied.
>
> Note - I slightly changed the construction of the size passed to the 
> xmalloc() function, so that instead of using sizeof on a separate 
> string, it accesses the libname_fmt structure and pulls a string out 
> of there.  I felt that this made it more obvious as to why the value 
> was being included in the computation of the amount of memory 
> required.  I also added a comment into the declaration of the 
> libname_fmt structure to remind future coders to check and update the 
> length if necessary.
This doesn't work correctly. The sizeof (libname_fmt.format) is sizeof 
(const char*), not the sizeof the string.

Fixed with the following patch. Other possibilities would be to 
s/sizeof/strlen/ or sizeof(*libname_fmt.format),
by I think this way makes the code clearer, and less surprising.

Cheers,
Pedro Alves

----

2006-06-24  Pedro Alves pedro_alves@portugalmail.pt

	PR ld/2537
	* emultempl/pe.em (gld_${EMULATION_NAME}_open_dynamic_archive): New member 
	fixed_len in libname_fmt, representing the length of the format string minus 
	the length of the formatters. Adjust xmalloc call to use the longest of the lengths.

--- pe.em.org    2006-06-24 13:18:22.000000000 +0100
+++ pe.em    2006-06-24 13:54:16.000000000 +0100
@@ -1697,52 +1697,60 @@ gld_${EMULATION_NAME}_open_dynamic_archi
   static const struct
     {
       const char * format;
+      int fixed_len;
       bfd_boolean use_prefix;
     }
   libname_fmt [] =
     {
       /* Preferred explicit import library for dll's.  */
-      { "lib%s.dll.a", FALSE },
+      { "lib%s.dll.a", 9, FALSE },
       /* Alternate explicit import library for dll's.  */
-      { "%s.dll.a", FALSE },
+      { "%s.dll.a", 6, FALSE },
       /* "libfoo.a" could be either an import lib or a static lib.
           For backwards compatibility, libfoo.a needs to precede
           libfoo.dll and foo.dll in the search.  */
-      { "lib%s.a", FALSE },
+      { "lib%s.a", 5, FALSE },
       /* The 'native' spelling of an import lib name is "foo.lib".  */ 
     
-      { "%s.lib", FALSE },
+      { "%s.lib", 4, FALSE },
 #ifdef DLL_SUPPORT
       /* Try "<prefix>foo.dll" (preferred dll name, if specified).  */
-      {    "%s%s.dll", TRUE },
+      {    "%s%s.dll", 4, TRUE },
 #endif
       /* Try "libfoo.dll" (default preferred dll name).  */
-      {    "lib%s.dll", FALSE },
+      {    "lib%s.dll", 7, FALSE },
       /* Finally try 'native' dll name "foo.dll".  */
-      {  "%s.dll", FALSE },
-      /* Note: If adding more formats to this table, make sure to check to
-     see if their length is longer than libname_fmt[0].format, and if
-     so, update the call to xmalloc() below.  */
-      { NULL, FALSE }
+      {  "%s.dll", 4, FALSE },
+      { NULL, 0, FALSE }
     };
   const char * filename;
   char * full_string;
   char * base_string;
   unsigned int i;
-
+  static int fixed_format_max_len = -1;
 
   if (! entry->is_archive)
     return FALSE;
 
+  if (fixed_format_max_len < 0)
+    {
+      fixed_format_max_len = 0;
+      for (i = 0; libname_fmt[i].format; i++)
+      {
+        if (fixed_format_max_len < libname_fmt[i].fixed_len)
+          fixed_format_max_len = libname_fmt[i].fixed_len;
+      }
+    }
+    
   filename = entry->filename;
 
   full_string = xmalloc (strlen (search->name)
              + strlen (filename)
-             /* Allow space for the characters in the format
-                string.  Also allow for the path separator that
-                is appended after the search name. We actually
-                allow 1 more byte than is strictly necessary,
-                but this will not hurt.  */
-             + sizeof libname_fmt[0].format
+             /* Allow space for the fixed characters in the format
+                string.  */
+             + fixed_format_max_len
+             /* Also allow for the path separator that
+               is appended after the search name.  */
+             + sizeof ("/") - 1
 #ifdef DLL_SUPPORT
              + (pe_dll_search_prefix
                 ? strlen (pe_dll_search_prefix) : 0)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Patch/pe-coff] : Add native spelling of import lib names to  dynamic  lib search
  2006-06-19  9:35 Danny Smith
@ 2006-06-22 13:52 ` Nick Clifton
  2006-06-24 17:32   ` Pedro Alves
  0 siblings, 1 reply; 8+ messages in thread
From: Nick Clifton @ 2006-06-22 13:52 UTC (permalink / raw)
  To: Danny Smith; +Cc: Binutils, Christopher Faylor

Hi Danny,

> 2006-06-19  Danny Smith  <dannysmith@users.sourceforge.net>
> 
> 	* emultempl/pe.em (gld_${EMULATION_NAME}_open_dynamic_archive): 
> 	Restructure.  Add native "%s.lib" format to search list
> 	* ld.texinfo (node WIN32): Update documentation on dynamic lib
> 	search order. Add another reason for using import libs.	

Approved and applied.

Note - I slightly changed the construction of the size passed to the 
xmalloc() function, so that instead of using sizeof on a separate 
string, it accesses the libname_fmt structure and pulls a string out of 
there.  I felt that this made it more obvious as to why the value was 
being included in the computation of the amount of memory required.  I 
also added a comment into the declaration of the libname_fmt structure 
to remind future coders to check and update the length if necessary.

Cheers
   Nick

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Patch/pe-coff] : Add native spelling of import lib names to  dynamic lib search
@ 2006-06-20  8:51 Danny Smith
  0 siblings, 0 replies; 8+ messages in thread
From: Danny Smith @ 2006-06-20  8:51 UTC (permalink / raw)
  To: Binutils


At
<http://sourceware.org/ml/binutils/2006-06/msg00294.html>
Ross Ridge wrote

> Danny Smith wrote:
> >However, the native naming convention for these import libs is
"foo.lib"
> >and gld_i386pe_open_dynamic_archive does not currently recognize this
> >name format. This means that doing something like -L/path/to/sdk
-lfoo32
> >could link directly to "foo32.dll", rather than find the import lib
> >"foo32.lib". 
> 
> Umm... doing something like -L/path/to/sdk -lfoo32 already works for
> me with ld.  Am I missing something here?
>

It finds foo32.lib after unsuccesfully going through the dynamic lib
search list, then trying to find a static lib name libfoo32.a  and
finally trying the .lib spelling in
gld_${EMULATION_NAME}_find_potential_libraries

If 'foo32.dll' is found before the import lib, 'foo32.lib', ld will
attempt direct linking to foo32.dll. This will fail if, as in platform
sdk, the symbols are exported only by aliased name.

Now  I  realize that putting a DLL in a library search path is not the
best thing to do, but it happens.

It often happens when building/testing a project and the makefile puts
the new dll and the import lib in the same  directory.

See this:
http://cygwin.com/ml/cygwin/2006-06/msg00187.html

I didn't like the answer given by the cygwin respondents.  The patch was
an alternative answer.

Danny

> 					Ross Ridge
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Patch/pe-coff] : Add native spelling of import lib names to dynamic  lib search
@ 2006-06-19  9:35 Danny Smith
  2006-06-22 13:52 ` Nick Clifton
  0 siblings, 1 reply; 8+ messages in thread
From: Danny Smith @ 2006-06-19  9:35 UTC (permalink / raw)
  To: Binutils; +Cc: Christopher Faylor

[-- Attachment #1: Type: text/plain, Size: 1609 bytes --]

Hello, 

Current ld is able to handle the short import lib format (ILF)
used by windows32 native compiler. This means that mingw32 and cygwin
projects can link against system dlls using the import libs provided by
the  OS vendor (ie, the platform software and driver development kits
distributed by MS).

However, the native naming convention for these import libs is "foo.lib"
and gld_i386pe_open_dynamic_archive does not currently recognize this
name format. This means that doing something like -L/path/to/sdk -lfoo32
could link directly to "foo32.dll", rather than find the import lib
"foo32.lib". In the case of windows systems libs, this direct linking to
dll does _not_ work because of aliasing of the names in the symbol
export table. An import lib is necessary and the developer has to either
rename foo.lib to lib.foo.a or forego the -L/path/to/sdk -lfoo32 -lbar32
syntax and specify the full pathname of each import lib on the command
line. Recognition of "foo.lib" as an import lib would also mean that the
testing of dll's that are intended to work with native as well as GNU
development tools could bypass the current necessity of copying
lib.foo.a to foo.lib, 

The attached patch adds this feature. I have also added a note on symbol
aliasing and import libs to ld.texinfo.


ChangeLog

2006-06-19  Danny Smith  <dannysmith@users.sourceforge.net>

	* emultempl/pe.em (gld_${EMULATION_NAME}_open_dynamic_archive): 
	Restructure.  Add native "%s.lib" format to search list
	* ld.texinfo (node WIN32): Update documentation on dynamic lib
	search order. Add another reason for using import libs.	

[-- Attachment #2: open_dynamic.patch --]
[-- Type: application/octet-stream, Size: 8329 bytes --]

Index: emultempl/pe.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/pe.em,v
retrieving revision 1.114
diff -c -3 -p -r1.114 pe.em
*** emultempl/pe.em	11 May 2006 08:48:58 -0000	1.114
--- emultempl/pe.em	19 Jun 2006 00:46:33 -0000
*************** gld_${EMULATION_NAME}_open_dynamic_archi
*** 1695,1780 ****
     lang_input_statement_type *entry)
  {
    const char * filename;
!   char * string;
  
    if (! entry->is_archive)
      return FALSE;
  
    filename = entry->filename;
  
!   string = (char *) xmalloc (strlen (search->name)
! 			     + strlen (filename)
! 			     + sizeof "/lib.a.dll"
  #ifdef DLL_SUPPORT
! 			     + (pe_dll_search_prefix ? strlen (pe_dll_search_prefix) : 0)
  #endif
! 			     + 1);
  
!   /* Try "libfoo.dll.a" first (preferred explicit import library for dll's.  */
!   sprintf (string, "%s/lib%s.dll.a", search->name, filename);
! 
!   if (! ldfile_try_open_bfd (string, entry))
      {
!       /* Try "foo.dll.a" next (alternate explicit import library for dll's.  */
!       sprintf (string, "%s/%s.dll.a", search->name, filename);
!       if (! ldfile_try_open_bfd (string, entry))
  	{
! 	  /* Try libfoo.a next. Normally, this would be interpreted as a static
! 	     library, but it *could* be an import library. For backwards compatibility,
! 	     libfoo.a needs to ==precede== libfoo.dll and foo.dll in the search,
! 	     or sometimes errors occur when building legacy packages.
! 
! 	     Putting libfoo.a here means that in a failure case (i.e. the library
! 	     -lfoo is not found) we will search for libfoo.a twice before
! 	     giving up -- once here, and once when searching for a "static" lib.
! 	     for a "static" lib.  */
! 	  /* Try "libfoo.a" (import lib, or static lib, but must
! 	     take precedence over dll's).  */
! 	  sprintf (string, "%s/lib%s.a", search->name, filename);
! 	  if (! ldfile_try_open_bfd (string, entry))
! 	    {
! #ifdef DLL_SUPPORT
! 	      if (pe_dll_search_prefix)
! 		{
! 		  /* Try "<prefix>foo.dll" (preferred dll name, if specified).  */
! 		  sprintf (string, "%s/%s%s.dll", search->name, pe_dll_search_prefix, filename);
! 		  if (! ldfile_try_open_bfd (string, entry))
! 		    {
! 		      /* Try "libfoo.dll" (default preferred dll name).  */
! 		      sprintf (string, "%s/lib%s.dll", search->name, filename);
! 		      if (! ldfile_try_open_bfd (string, entry))
! 			{
! 			  /* Finally, try "foo.dll" (alternate dll name).  */
! 			  sprintf (string, "%s/%s.dll", search->name, filename);
! 			  if (! ldfile_try_open_bfd (string, entry))
! 			    {
! 			      free (string);
! 			      return FALSE;
! 			    }
! 			}
! 		    }
! 		}
! 	      else /* pe_dll_search_prefix not specified.  */
! #endif
! 		{
! 		  /* Try "libfoo.dll" (preferred dll name).  */
! 		  sprintf (string, "%s/lib%s.dll", search->name, filename);
! 		  if (! ldfile_try_open_bfd (string, entry))
! 		    {
! 		      /* Finally, try "foo.dll" (alternate dll name).  */
! 		      sprintf (string, "%s/%s.dll", search->name, filename);
! 		      if (! ldfile_try_open_bfd (string, entry))
! 			{
! 			  free (string);
! 			  return FALSE;
! 			}
! 		    }
! 		}
! 	    }
  	}
      }
  
!   entry->filename = string;
  
    return TRUE;
  }
--- 1695,1773 ----
     lang_input_statement_type *entry)
  {
    const char * filename;
!   char * full_string,  * base_string;
! 
!   static const struct
!     {
!       const char *format;
!       bfd_boolean use_prefix;
!     }
!   libname_fmt [] =
!     {
!       /* Preferred explicit import library for dll's.  */
!       { "lib%s.dll.a", FALSE },
!       /* Alternate explicit import library for dll's.  */
!       { "%s.dll.a", FALSE },
!       /* "libfoo.a" could be either an import lib or a static lib.
!           For backwards compatibility, libfoo.a needs to precede
!          "libfoo.dll" and "foo.dll" in the search,  */
!       { "lib%s.a" , FALSE },
!       /* The 'native' spelling of an import lib name is "foo.lib".  */  	
!       { "%s.lib", FALSE },
! #ifdef DLL_SUPPORT
!       /* Try "<prefix>foo.dll" (preferred dll name, if specified).  */
!       {	"%s%s.dll", TRUE },
! #endif
!       /* Try "libfoo.dll" (default preferred dll name).  */
!       {	"lib%s.dll", FALSE },
!       /* Finally try 'native' dll name "foo.dll".  */
!       {  "%s.dll", FALSE },
!       { NULL, FALSE }
!     };
! 
!   int i;
  
    if (! entry->is_archive)
      return FALSE;
  
    filename = entry->filename;
  
!   full_string = (char *) xmalloc (strlen (search->name)
! 			     	  + strlen (filename)
! 				  + sizeof "/lib.a.dll"
  #ifdef DLL_SUPPORT
! 				  + (pe_dll_search_prefix
! 				     ? strlen (pe_dll_search_prefix)
! 				     : 0)
  #endif
! 				  + 1);
  
!   sprintf (full_string, "%s/", search->name);
!   base_string = full_string + strlen (full_string);
!   
!   for (i = 0; libname_fmt[i].format; i++)
      {
! #ifdef DLL_SUPPORT 
!       if (libname_fmt[i].use_prefix)
  	{
! 	  if (!pe_dll_search_prefix)
! 	    continue;
! 	  sprintf (base_string, libname_fmt[i].format, pe_dll_search_prefix, filename);
  	}
+       else
+ #endif
+ 	sprintf (base_string, libname_fmt[i].format, filename);
+       if (ldfile_try_open_bfd (full_string, entry))
+ 	break;
+     }
+ 
+   if (!libname_fmt[i].format)
+     {
+       free (full_string);
+       return FALSE;
      }
  
!   entry->filename = full_string;
  
    return TRUE;
  }
Index: ld.texinfo
===================================================================
RCS file: /cvs/src/src/ld/ld.texinfo,v
retrieving revision 1.164
diff -c -3 -p -r1.164 ld.texinfo
*** ld.texinfo	14 Jun 2006 02:43:57 -0000	1.164
--- ld.texinfo	19 Jun 2006 00:46:55 -0000
*************** to find, in the first directory of its s
*** 5986,5992 ****
  @example
  libxxx.dll.a 
  xxx.dll.a 
! libxxx.a 
  cygxxx.dll (*)
  libxxx.dll 
  xxx.dll 
--- 5986,5993 ----
  @example
  libxxx.dll.a 
  xxx.dll.a 
! libxxx.a
! xxx.lib
  cygxxx.dll (*)
  libxxx.dll 
  xxx.dll 
*************** even when auto-import features are exerc
*** 6061,6067 ****
  @samp{--enable-runtime-pseudo-relocs} is used.
  
  Given the improvements in speed and memory usage, one might justifiably
! wonder why import libraries are used at all.  There are two reasons:
  
  1. Until recently, the link-directly-to-dll functionality did @emph{not}
  work with auto-imported data.
--- 6062,6068 ----
  @samp{--enable-runtime-pseudo-relocs} is used.
  
  Given the improvements in speed and memory usage, one might justifiably
! wonder why import libraries are used at all.  There are three reasons:
  
  1. Until recently, the link-directly-to-dll functionality did @emph{not}
  work with auto-imported data.
*************** symbols that point to the exports of a d
*** 6072,6080 ****
  for the cygwin kernel makes use of this ability, and it is not
  possible to do this without an import lib.
  
  So, import libs are not going away.  But the ability to replace
  true import libs with a simple symbolic link to (or a copy of) 
! a dll, in most cases, is a useful addition to the suite of tools 
  binutils makes available to the win32 developer.  Given the 
  massive improvements in memory requirements during linking, storage
  requirements, and linking speed, we expect that many developers
--- 6073,6086 ----
  for the cygwin kernel makes use of this ability, and it is not
  possible to do this without an import lib.
  
+ 3. Symbol aliases can only be resolved using an import lib.  This is
+ critical when linking against OS-supplied dll's (eg, the win32 API)
+ in which symbols are usually exported as undecorated aliases of their
+ stdcall-decorated assembly names.
+ 
  So, import libs are not going away.  But the ability to replace
  true import libs with a simple symbolic link to (or a copy of) 
! a dll, in many cases, is a useful addition to the suite of tools 
  binutils makes available to the win32 developer.  Given the 
  massive improvements in memory requirements during linking, storage
  requirements, and linking speed, we expect that many developers

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-06-27 11:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-20  7:39 [Patch/pe-coff] : Add native spelling of import lib names to dynamic lib search Ross Ridge
  -- strict thread matches above, loose matches on Subject: below --
2006-06-20  8:51 Danny Smith
2006-06-19  9:35 Danny Smith
2006-06-22 13:52 ` Nick Clifton
2006-06-24 17:32   ` Pedro Alves
2006-06-25 13:50     ` Pedro Alves
2006-06-26 12:32       ` Pedro Alves
2006-06-27 14:57         ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).