This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Patch to ld/pe-dll.c: Use explicit lookup for filering excluded objects
- To: DJ Delorie <dj at delorie dot com>
- Subject: Re: Patch to ld/pe-dll.c: Use explicit lookup for filering excluded objects
- From: Danny Smith <danny_r_smith_2001 at yahoo dot co dot nz>
- Date: Wed, 17 Oct 2001 19:47:00 +1000 (EST)
- Cc: binutils at sources dot redhat dot com, cwilson at ece dot gatech dot edu
--- 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.