public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* RE[2]:Patch to ld/pe-dll.c: Use explicit lookup for filering excluded  objects
@ 2001-10-17 18:09 Danny Smith
  2001-10-17 19:52 ` Patch " DJ Delorie
  0 siblings, 1 reply; 13+ messages in thread
From: Danny Smith @ 2001-10-17 18:09 UTC (permalink / raw)
  To: DJ Delorie, binutils

 --- 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.

^ permalink raw reply	[flat|nested] 13+ messages in thread
* Patch to ld/pe-dll.c: Use explicit lookup for filering excluded  objects
@ 2001-10-16 15:48 Danny Smith
  2001-10-16 16:14 ` DJ Delorie
  0 siblings, 1 reply; 13+ messages in thread
From: Danny Smith @ 2001-10-16 15:48 UTC (permalink / raw)
  To: binutils; +Cc: Charles Wilson

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.

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

end of thread, other threads:[~2001-10-19 10:34 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-17 18:09 RE[2]:Patch to ld/pe-dll.c: Use explicit lookup for filering excluded objects Danny Smith
2001-10-17 19:52 ` Patch " DJ Delorie
2001-10-18 12:27   ` Danny Smith
2001-10-18 12:30     ` DJ Delorie
2001-10-18 14:05       ` Danny Smith
2001-10-18 17:02         ` DJ Delorie
2001-10-18 17:37           ` Danny Smith
  -- strict thread matches above, loose matches on Subject: below --
2001-10-16 15:48 Danny Smith
2001-10-16 16:14 ` DJ Delorie
2001-10-16 22:04   ` Charles Wilson
2001-10-17  2:47   ` Danny Smith
2001-10-17 22:39     ` Charles Wilson
2001-10-19 10:34     ` Charles Wilson

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).