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: Fri, 19 Oct 2001 05:26:58 +1000 (EST)
- Cc: binutils at sources dot redhat dot com
--- 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.