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

* Re: Patch to ld/pe-dll.c: Use explicit lookup for filering excluded  objects
  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 ` DJ Delorie
  2001-10-18 12:27   ` Danny Smith
  0 siblings, 1 reply; 13+ messages in thread
From: DJ Delorie @ 2001-10-17 19:52 UTC (permalink / raw)
  To: danny_r_smith_2001; +Cc: binutils

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

Please note whatever testing you've done for your patch when you
submit it.

> +         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]))

If we're using lbasename, shouldn't we use strncmp instead of strstr?

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

* Re: Patch to ld/pe-dll.c: Use explicit lookup for filering excluded  objects
  2001-10-17 19:52 ` Patch " DJ Delorie
@ 2001-10-18 12:27   ` Danny Smith
  2001-10-18 12:30     ` DJ Delorie
  0 siblings, 1 reply; 13+ messages in thread
From: Danny Smith @ 2001-10-18 12:27 UTC (permalink / raw)
  To: DJ Delorie; +Cc: binutils

 --- DJ Delorie <dj@delorie.com> wrote: > 
> > A re-revised patch : Why not use a simple array for autofilter_liblist
> as
> > well.
> 
> Please note whatever testing you've done for your patch when you
> submit it.
> 
> > +         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]))
> 
> If we're using lbasename, shouldn't we use strncmp instead of strstr? 


Yes.  After looking at the code for libiberty strstr, I agree.
Here is yet another revision.  I have built on mingw and tested with
Charles' dllhelpers-0.2.8 examples, with build of STLPort 4.16b as dll and
testsuite linking against this dll, and by building libbfd as dll and
rebuilding ld to link against libbfd.dll.

My stylistic choices are my stylistic choices, biased by too much fortran
code in the past. This all started out by fixing a bug and I've dug myself
into a stylistic hole as it were. Charles, perhaps you can provide an
alternative.


ChangeLog

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

	* pe-dll.c (autofilter_objectlist): Simplify. Add
	startup objects for profiling.
	(autofilter_symbollist): Simplify.
	(auto-export): Constify char * p.
	Extract file basename before lookup of excluded archives
	and objects.
	Use simplified arrays for object and symbol lookup.
	Use strncmp rather than strstr for archive lookup.
	Use strcmp rather than ststr for object lookup.

--- pe-dll.c.0	Wed Oct 17 07:51:51 2001
+++ pe-dll.c	Thu Oct 18 22:04:01 2001
@@ -213,36 +213,40 @@ 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_array_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 }
+  { "libmingw32.", 11 }
 };
+static const int af_liblist_array_len = ARRAY_SIZE (autofilter_liblist);
 
-static autofilter_entry_type autofilter_objlist[] =
+static const char* autofilter_objlist[] =
 {
-  { "crt0.o", 6 },
-  { "crt1.o", 6 },
-  { "crt2.o", 6 },
-  { "dllcrt1.o", 9 },
-  { "dllcrt2.o", 9 },
-  { NULL, 0 }
+  "crt0.o" ,
+  "crt1.o" ,
+  "crt2.o" ,
+  "dllcrt1.o" ,
+  "dllcrt2.o" ,
+  "gcrt0.o",
+  "gcrt1.o" ,
+  "gcrt2.o"  
 };
+static const int af_objlist_array_len = ARRAY_SIZE (autofilter_objlist);
 
 static autofilter_entry_type autofilter_symbolprefixlist[] =
 {
@@ -418,7 +422,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 +430,29 @@ 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_array_len; i++)
+  	  if (strncmp (p, autofilter_liblist[i].name,
+	      autofilter_liblist[i].len) == 0 )
 		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_array_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_array_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

* Re: Patch to ld/pe-dll.c: Use explicit lookup for filering excluded  objects
  2001-10-18 12:27   ` Danny Smith
@ 2001-10-18 12:30     ` DJ Delorie
  2001-10-18 14:05       ` Danny Smith
  0 siblings, 1 reply; 13+ messages in thread
From: DJ Delorie @ 2001-10-18 12:30 UTC (permalink / raw)
  To: danny_r_smith_2001; +Cc: binutils

> This all started out by fixing a bug and I've dug myself into a
> stylistic hole as it were.

Rather than digging deeper, let's back up for a moment.  What was the
original bug, and what is the minimum change needed to fix it, given
what we've discussed so far?  We can leave the tables as-is for now,
and simplify them later as a separate change.

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

* Re: Patch to ld/pe-dll.c: Use explicit lookup for filering excluded  objects
  2001-10-18 12:30     ` DJ Delorie
@ 2001-10-18 14:05       ` Danny Smith
  2001-10-18 17:02         ` DJ Delorie
  0 siblings, 1 reply; 13+ messages in thread
From: Danny Smith @ 2001-10-18 14:05 UTC (permalink / raw)
  To: DJ Delorie; +Cc: binutils

 --- DJ Delorie <dj@delorie.com> wrote: > 
> > This all started out by fixing a bug and I've dug myself into a
> > stylistic hole as it were.
> 
> Rather than digging deeper, let's back up for a moment.  What was the
> original bug, and what is the minimum change needed to fix it, given
> what we've discussed so far?  We can leave the tables as-is for now,
> and simplify them later as a separate change. 

Okay.

ChangeLog

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

	* pe-dll.c (autofilter_objectlist):  Add startup objects
	for profiling.
	(auto-export): Constify char * p.
	Extract file basename and use strcmp rather than ststr 
	for object lookup.

--- pe-dll.c.0	Wed Oct 17 07:51:51 2001
+++ pe-dll.c	Fri Oct 19 09:41:52 2001
@@ -241,6 +241,8 @@ static autofilter_entry_type autofilter_
   { "crt2.o", 6 },
   { "dllcrt1.o", 9 },
   { "dllcrt2.o", 9 },
+  { "gcrt1.o", 7 },
+  { "gcrt2.o", 7 },  
   { NULL, 0 }
 };
 
@@ -418,7 +420,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)
@@ -440,16 +442,16 @@ auto_export (abfd, d, n)
 	}
 
       /* Next, exclude symbols from certain startup objects.  */
-      afptr = autofilter_objlist;
 
+      if (abfd && (p = lbasename (abfd->filename)) )
+	{
+          afptr = autofilter_objlist;
       while (afptr->name)
 	{
-	  if (abfd && 
-	      (p = strstr (abfd->filename, afptr->name)) &&
-	      (*(p + afptr->len - 1) == 0))
+	      if ( strcmp (p, afptr->name) == 0 )
 	    return 0;
-
 	  afptr ++;
+	    }
 	}



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

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

* Re: Patch to ld/pe-dll.c: Use explicit lookup for filering excluded  objects
  2001-10-18 14:05       ` Danny Smith
@ 2001-10-18 17:02         ` DJ Delorie
  2001-10-18 17:37           ` Danny Smith
  0 siblings, 1 reply; 13+ messages in thread
From: DJ Delorie @ 2001-10-18 17:02 UTC (permalink / raw)
  To: danny_r_smith_2001; +Cc: binutils

> 2001-10-19  Danny Smith  <danny_r_smith_2001@yahoo.co.nz>
> 
> 	* pe-dll.c (autofilter_objectlist):  Add startup objects
> 	for profiling.
> 	(auto-export): Constify char * p.
> 	Extract file basename and use strcmp rather than ststr 
> 	for object lookup.

Applied.  Thanks!

Now, if we're interested in reviewing the design of that code and
perhaps simplifying it, let's do.  But I'd like to hear a few success
stories with this patch in place before I commit anything :-)

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

* Re: Patch to ld/pe-dll.c: Use explicit lookup for filering excluded  objects
  2001-10-18 17:02         ` DJ Delorie
@ 2001-10-18 17:37           ` Danny Smith
  0 siblings, 0 replies; 13+ messages in thread
From: Danny Smith @ 2001-10-18 17:37 UTC (permalink / raw)
  To: DJ Delorie; +Cc: binutils

 --- DJ Delorie <dj@delorie.com> wrote: > 
> > 2001-10-19  Danny Smith  <danny_r_smith_2001@yahoo.co.nz>
> > 
> > 	* pe-dll.c (autofilter_objectlist):  Add startup objects
> > 	for profiling.
> > 	(auto-export): Constify char * p.
> > 	Extract file basename and use strcmp rather than ststr 
> > 	for object lookup.
> 
> Applied.  Thanks!
> 
> Now, if we're interested in reviewing the design of that code and
> perhaps simplifying it, let's do.  But I'd like to hear a few success
> stories with this patch in place before I commit anything :-) 

Thank you for your patience. 
Danny

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

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

* Re: Patch to ld/pe-dll.c: Use explicit lookup for filering excluded  objects
  2001-10-17  2:47   ` Danny Smith
  2001-10-17 22:39     ` Charles Wilson
@ 2001-10-19 10:34     ` Charles Wilson
  1 sibling, 0 replies; 13+ messages in thread
From: Charles Wilson @ 2001-10-19 10:34 UTC (permalink / raw)
  To: Danny Smith; +Cc: DJ Delorie, binutils

Danny Smith wrote:
> Yes.  After looking at the code for libiberty strstr, I agree.
> Here is yet another revision.  I have built on mingw and tested with
> Charles' dllhelpers-0.2.8 examples, with build of STLPort 4.16b as dll and
> testsuite linking against this dll, and by building libbfd as dll and
> rebuilding ld to link against libbfd.dll.
> 
> My stylistic choices are my stylistic choices, biased by too much fortran
> code in the past. This all started out by fixing a bug and I've dug myself
> into a stylistic hole as it were. Charles, perhaps you can provide an
> alternative.

I withdraw my objections.  Do your "worst", Danny  :-)

It appears that with your proposed changes, none of these lists will use
the length parameter, so they can all be changed to simple arrays of
char*.

autofilter_liblist
autofilter_objlist
autofilter_symbollist

Leaving only the *prefix and *suffix lists...

--Chuck

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

* Re: Patch to ld/pe-dll.c: Use explicit lookup for filering excluded  objects
  2001-10-17  2:47   ` Danny Smith
@ 2001-10-17 22:39     ` Charles Wilson
  2001-10-19 10:34     ` Charles Wilson
  1 sibling, 0 replies; 13+ messages in thread
From: Charles Wilson @ 2001-10-17 22:39 UTC (permalink / raw)
  To: Danny Smith; +Cc: DJ Delorie, binutils

Danny Smith wrote:

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


Sigh.  I'm not as enthusiastic about this change.  dunno why, call it 
stylistic, but I liked the parallelism of the five loops, and using the 
same data structures for each list.  Also, the addition of yet more 
static variables (even if they are auto-calculated) just seems hackish, 
compared to the standard "loop until NULL" structure that was in use 
before.  This to me seems to be a stylistic regression.  But it *will* 
work, so I can't object to it on practical grounds.

Or maybe I'm just being overly paternalistic to my own code. <g>

--Chuck


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

* Re: Patch to ld/pe-dll.c: Use explicit lookup for filering excluded  objects
  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
  1 sibling, 2 replies; 13+ messages in thread
From: Danny Smith @ 2001-10-17  2:47 UTC (permalink / raw)
  To: DJ Delorie; +Cc: binutils, cwilson

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

ChangeLog

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

	* pe-dll.c (autofilter_objectlist): Simplify. Add
	startup objects for profiling.
	(autofilter_symbollist): Simplify.
	(auto-export): Constify char * p.
	Extract file basename before lookup of excluded archives
	and objects.
	Use simplified arrays for archive and object lookup.
	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 22:28:47 2001
@@ -213,17 +213,18 @@ 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[] =
@@ -234,15 +235,18 @@ static autofilter_entry_type autofilter_
   { NULL, 0 }
 };
 
-static autofilter_entry_type autofilter_objlist[] =
+static const char * autofilter_objlist[] =
 {
-  { "crt0.o", 6 },
-  { "crt1.o", 6 },
-  { "crt2.o", 6 },
-  { "dllcrt1.o", 9 },
-  { "dllcrt2.o", 9 },
-  { NULL, 0 }
+  "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 +422,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 +430,33 @@ 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)
+         Don't export anything from system libs.  */
+      if (abfd && abfd->my_archive &&
+          (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.  */
-      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

* Re: Patch to ld/pe-dll.c: Use explicit lookup for filering excluded  objects
  2001-10-16 16:14 ` DJ Delorie
@ 2001-10-16 22:04   ` Charles Wilson
  2001-10-17  2:47   ` Danny Smith
  1 sibling, 0 replies; 13+ messages in thread
From: Charles Wilson @ 2001-10-16 22:04 UTC (permalink / raw)
  To: DJ Delorie; +Cc: danny_r_smith_2001, binutils

DJ Delorie wrote:

>>+	    strstr ( p,"crt")) 	 /* Quick check */ 
>>
> 
> Does this really help?  If not, why make the code more complicated
> that it needs be?


It might help, a little -- but probably not enough to warrant uglifying 
the code.  Other than that, I like this patch (if that matters).

> 
> And would we need the lengths in the table still, with this patch?
> 


Yes, afptr->len is used in the "exclude prefix" and "exclude suffix" 
tests farther down in auto_export().  Now, as you point out, we don't 
really need the lengths in autofilter_objlist[]'s entries -- but then 
we'd have to define a separate type for it.  Right now:

autofilter_symbollist
autofilter_liblist
autofilter_objlist
autofilter_symbolprefixlist
autofilter_symbolsuffixlist

are all arrays of "autofilter_entry_type" (struct with one string field 
and one int field).  We don't use the length field from

autofilter_liblist
autofilter_objlist (with this patch)
autofilter_symbollist

but we do use it from

autofilter_symbolprefixlist
autofilter_symbolsuffixlist

--Chuck



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

* Re: 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
  2001-10-16 22:04   ` Charles Wilson
  2001-10-17  2:47   ` Danny Smith
  0 siblings, 2 replies; 13+ messages in thread
From: DJ Delorie @ 2001-10-16 16:14 UTC (permalink / raw)
  To: danny_r_smith_2001; +Cc: binutils, cwilson

> +	    strstr ( p,"crt")) 	 /* Quick check */ 

Does this really help?  If not, why make the code more complicated
that it needs be?

And would we need the lengths in the table still, with this patch?

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