This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Performance issue with GNU/ld and DLL
Kai,
> So this patch seems to me not ok, as for binary-searching we need to
> make sure list is sorted.
I've reviewed the code and in fact the exports table is update by
def_file_add_export(). This routine insert the items at the good
location, keeping the table sorted.
The only location where the table is updated without using this routine
is in the process_def_file_and_directve line 780 in the section where @
is removed.
/* Canonicalize the export list. */
if (pe_dll_kill_ats)
My patch sort the exports table only in this case and only when needed.
If I have not overlooked some other update the attached patch should be ok.
Comments?
Pascal.
--
--|------------------------------------------------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--| http://www.obry.net - http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B
>From c38ca49a56bba9f87aa10fe9f5292272ac250d07 Mon Sep 17 00:00:00 2001
From: Pascal Obry <pascal@obry.net>
Date: Fri, 10 Feb 2012 08:57:32 +0100
Subject: [PATCH] * pe-dll.c: (auto_export): Use bsearch instead of linear
search. Fixes a performance issue when building large DLL
(with many exports). (process_def_file_and_drectve): Sort
export table only when needed.
---
ld/pe-dll.c | 25 ++++++++++++++++++-------
1 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/ld/pe-dll.c b/ld/pe-dll.c
index ce0ab5d..9964a8e 100644
--- a/ld/pe-dll.c
+++ b/ld/pe-dll.c
@@ -1,6 +1,6 @@
/* Routines to help build PEI-format DLLs (Win32 etc)
Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
- 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+ 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
Written by DJ Delorie <dj@cygnus.com>
This file is part of the GNU Binutils.
@@ -529,16 +529,21 @@ is_import (const char* n)
static int
auto_export (bfd *abfd, def_file *d, const char *n)
{
- int i;
+ def_file_export key;
struct exclude_list_struct *ex;
const autofilter_entry_type *afptr;
const char * libname = 0;
if (abfd && abfd->my_archive)
libname = lbasename (abfd->my_archive->filename);
- for (i = 0; i < d->num_exports; i++)
- if (strcmp (d->exports[i].name, n) == 0)
- return 0;
+ /* Returns if n is in the d->exports table */
+
+ key.name = (char *)n;
+ key.its_name = (char *)n;
+
+ if (bsearch (&key, d->exports, d->num_exports,
+ sizeof (pe_def_file->exports[0]), pe_export_sort))
+ return 0;
if (pe_dll_do_default_excludes)
{
@@ -644,6 +649,7 @@ process_def_file_and_drectve (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *
bfd *b;
struct bfd_section *s;
def_file_export *e = 0;
+ int sort_needed = 0;
if (!pe_def_file)
pe_def_file = def_file_empty ();
@@ -788,10 +794,17 @@ process_def_file_and_drectve (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *
einfo (_("%XCannot export %s: invalid export name\n"),
pe_def_file->exports[i].name);
pe_def_file->exports[i].name = tmp;
+ sort_needed = 1;
}
}
}
+ /* Sort as we have possibly changed the order by removing leading @ */
+
+ if (sort_needed)
+ qsort (pe_def_file->exports, NE, sizeof (pe_def_file->exports[0]),
+ pe_export_sort);
+
if (pe_dll_stdcall_aliases)
{
for (i = 0; i < NE; i++)
@@ -829,8 +842,6 @@ process_def_file_and_drectve (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *
count_exported_byname = 0;
count_with_ordinals = 0;
- qsort (pe_def_file->exports, NE, sizeof (pe_def_file->exports[0]),
- pe_export_sort);
for (i = 0, j = 0; i < NE; i++)
{
if (i > 0 && strcmp (e[i].name, e[i - 1].name) == 0)
--
1.7.9.188.g12766