This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Performance issue with GNU/ld and DLL
- From: Pascal Obry <pascal at obry dot net>
- To: nick clifton <nickc at redhat dot com>
- Cc: binutils at sourceware dot org
- Date: Fri, 10 Feb 2012 09:01:37 +0100
- Subject: Re: Performance issue with GNU/ld and DLL
- References: <4F23FE5A.7040108@obry.net> <4F2E47C4.8010505@obry.net> <4F2FD2F9.6000500@redhat.com>
- Reply-to: pascal at obry dot net
Here is the patch I'm proposing to solve this issue.
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 826e3c2ab58cabf0c02aee9e29248b1daef2b1e9 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).
---
ld/pe-dll.c | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/ld/pe-dll.c b/ld/pe-dll.c
index ce0ab5d..c65616d 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)
{
--
1.7.9.188.g12766