This is the mail archive of the binutils@sources.redhat.com 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]

Patch to ld/pe-dll.c: Use explicit lookup for filering excluded objects


Currently the auto-export code in pe-dll.c exludes any objects whose
filenames  *end* with substrings listed in a lookup table. This can cause
problems if users actually end a file with one of these substrings, eg
not_crt0.o would be excluded.  Appended patch uses exact lookup to make
sure that only system objects are excluded.  

It also extacts basename from archive filenames before looping through the
lookup table to search for excluded patterns. This should speed up the
search when filename has a long prefix.

Tested on mingw32. 


ChangeLog

	2001-10-16  Danny Smith  <danny_r_smith_2001@yahoo.co.nz>

	* pe-dll.c (autofilter_entry_type autofilter_objectlist): Add
	startup objects for profiling.
	(auto-export): Constify char * p.
	Extract file basename before lookup of excluded archives
	and objects.
	Use exact match when looking up excluded startup objects.


--- pe-dll.c.0	Wed Oct 17 07:51:51 2001
+++ pe-dll.c	Wed Oct 17 11:16:13 2001
@@ -241,6 +241,9 @@ static autofilter_entry_type autofilter_
   { "crt2.o", 6 },
   { "dllcrt1.o", 9 },
   { "dllcrt2.o", 9 },
+  { "gcrt0.o", 7 },
+  { "gcrt1.o", 7 },
+  { "gcrt2.o", 7 },
   { NULL, 0 }
 };
 
@@ -418,7 +421,7 @@ auto_export (abfd, d, n)
 
   if (pe_dll_do_default_excludes)
     {
-      char * p;
+      const char * p;
       int    len;
 
       if (pe_dll_extra_pe_debug)
@@ -426,31 +429,33 @@ auto_export (abfd, d, n)
 		n, abfd, abfd->my_archive);
 
       /* First of all, make context checks:
-         Don't export anything from libgcc.  */
+         Don't export anything from system libs.  */
       if (abfd && abfd->my_archive)
 	{
+	  if ((p=lbasename (abfd->my_archive->filename)))
+	    {
 	  afptr = autofilter_liblist;
-
 	  while (afptr->name)
 	    {
-	      if (strstr (abfd->my_archive->filename, afptr->name))
+		  if (strstr (p, afptr->name))
 		return 0;
 	      afptr++;
 	    }
 	}
-
+	}
       /* Next, exclude symbols from certain startup objects.  */
+      if ( abfd )
+	if ((p = lbasename (abfd->filename)) && 
+	    strstr ( p,"crt")) 	 /* Quick check */ 
+	  {
       afptr = autofilter_objlist;
-
-      while (afptr->name)
+	    while (afptr->name)   /* Check for exact match */
 	{
-	  if (abfd && 
-	      (p = strstr (abfd->filename, afptr->name)) &&
-	      (*(p + afptr->len - 1) == 0))
+	        if ( strcmp (p, afptr->name) == 0 )
 	    return 0;
-
 	  afptr ++;
 	}
+	  }
 
       /* Don't try to blindly exclude all symbols
 	 that begin with '__'; this was tried and 
 



http://briefcase.yahoo.com.au - Yahoo! Briefcase
- Manage your files online.


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