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]

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


 --- Danny Smith <danny_r_smith_2001@yahoo.co.nz> wrote: > Date: Wed, 17
Oct 2001 19:47:00 +1000 (EST)
>  --- DJ Delorie <dj@delorie.com> wrote: > 
> > > +	    strstr ( p,"crt")) 	 /* Quick check */ 
> > 
> > Does this really help?  If not, why make the code more complicated
> > that it needs be?
> 
> I thought it would, but I'll defer to your judgment.
> > 
> > And would we need the lengths in the table still, with this patch? 
> 
> No. Nor does autofilter_symbollist. I have changed both to simple arrays
> of
> char* and calculated fixed array length once at file level.
> 
> Revised patch tested on mingw32.
> 

A re-revised patch : Why not use a simple array for autofilter_liblist as
well.

ChangeLog

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

	* pe-dll.c (autofilter_objectlist): Simplify. Add
	startup objects for profiling.
	(autofilter_symbollist, autofilter_liblist): Simplify.
	(auto-export): Constify char * p.
	Extract file basename before lookup of excluded archives
	and objects.
	Use simplified arrays for archive, object and symbol lookup.
	Use exact match when looking up excluded startup objects.


--- pe-dll.c.0	Wed Oct 17 07:51:52 2001
+++ pe-dll.c	Thu Oct 18 13:57:43 2001
@@ -213,36 +213,39 @@ static pe_details_type pe_detail_list[] 
 
 static pe_details_type *pe_details;
 
-static autofilter_entry_type autofilter_symbollist[] =
+static const char*  autofilter_symbollist[] =
 {
-  { "DllMain@12", 10 },
-  { "DllEntryPoint@0", 15 },
-  { "DllMainCRTStartup@12", 20 },
-  { "_cygwin_dll_entry@12", 20 },
-  { "_cygwin_crt0_common@8", 21 },
-  { "_cygwin_noncygwin_dll_entry@12", 30 },
-  { "impure_ptr", 10 },
-  { NULL, 0 }
+  "DllMain@12",
+  "DllEntryPoint@0",
+  "DllMainCRTStartup@12",
+  "_cygwin_dll_entry@12",
+  "_cygwin_crt0_common@8",
+  "_cygwin_noncygwin_dll_entry@12",
+  "impure_ptr"
 };
+static const int af_symbollist_len = ARRAY_SIZE (autofilter_symbollist);
 
 /* Do not specify library suffix explicitly, to allow for dllized
versions.  */
-static autofilter_entry_type autofilter_liblist[] =
-{
-  { "libgcc.", 7 },
-  { "libstdc++.", 10 },
-  { "libmingw32.", 11 },
-  { NULL, 0 }
-};
-
-static autofilter_entry_type autofilter_objlist[] =
+static const char* autofilter_liblist[] =
 {
-  { "crt0.o", 6 },
-  { "crt1.o", 6 },
-  { "crt2.o", 6 },
-  { "dllcrt1.o", 9 },
-  { "dllcrt2.o", 9 },
-  { NULL, 0 }
+  "libgcc.",
+  "libstdc++.",
+  "libmingw32."
+ };
+static const int af_liblist_len = ARRAY_SIZE (autofilter_liblist);
+
+static const char* autofilter_objlist[] =
+{
+  "crt0.o" ,
+  "crt1.o" ,
+  "crt2.o" ,
+  "dllcrt1.o" ,
+  "dllcrt2.o" ,
+  "gcrt0.o",
+  "gcrt1.o" ,
+  "gcrt2.o"  
 };
+static const int af_objlist_len = ARRAY_SIZE (autofilter_objlist);
 
 static autofilter_entry_type autofilter_symbolprefixlist[] =
 {
@@ -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,46 +429,28 @@ auto_export (abfd, d, n)
 		n, abfd, abfd->my_archive);
 
       /* First of all, make context checks:
-         Don't export anything from libgcc.  */
-      if (abfd && abfd->my_archive)
-	{
-	  afptr = autofilter_liblist;
-
-	  while (afptr->name)
-	    {
-	      if (strstr (abfd->my_archive->filename, afptr->name))
+         Don't export anything from system libs.  */
+      if (abfd && abfd->my_archive &&
+          (p=lbasename (abfd->my_archive->filename)))
+	for (i =0; i < af_liblist_len; i++)
+  	 if ( strstr (p, autofilter_liblist[i]))
 		return 0;
-	      afptr++;
-	    }
-	}
 
       /* Next, exclude symbols from certain startup objects.  */
-      afptr = autofilter_objlist;
-
-      while (afptr->name)
-	{
-	  if (abfd && 
-	      (p = strstr (abfd->filename, afptr->name)) &&
-	      (*(p + afptr->len - 1) == 0))
+      if (abfd && (p = lbasename (abfd->filename)))
+	for (i =0; i < af_objlist_len; i++)
+	  if ( strcmp (p, autofilter_objlist[i]) == 0 )
 	    return 0;
 
-	  afptr ++;
-	}
-
       /* Don't try to blindly exclude all symbols
 	 that begin with '__'; this was tried and
 	 it is too restrictive.  */
 
       /* Then, exclude specific symbols.  */
-      afptr = autofilter_symbollist;
-      while (afptr->name)
-	{
-	  if (strcmp (n, afptr->name) == 0)
+      for (i = 0; i < af_symbollist_len; i++)
+	if (strcmp (n, autofilter_symbollist[i]) == 0)
 	    return 0;
 
-	  afptr ++;
-	}
-
       /* Next, exclude symbols starting with ...  */
       afptr = autofilter_symbolprefixlist;
       while (afptr->name)




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]