This is the mail archive of the cygwin-apps@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

cygwin ld import library issue fix (removing unused "_nm_" symbols)


Hi,
this patch fixes an cygwin ld issue (GNU ld version 2.11.92 20011001) I've
encountered while analysing the runtime linking performance for kde.

Background:

The ld-auto-import stuff introduces additional symbols (_nm_...) in the import
library which are only needed for data exports.
Unfortunally this symbols are generated for every export.
Additional ld rexports imported "_nm_" symbols from other dlls, so one get
symbols like "_nm___nm__scanf" for example.

One can say this isn't a real problem and the answer is yes ... for little
dll's.
But if you look in the below mentioned import libraries, one can save about 30%
of the import libraries size.
For the kde 2.2.2 devel libs and base package this would save about 26MB.
And this seems to be a fact for applying this fix.

without patch
-rwxrwxrwx    1 1002     Kein      3190016 Apr 20 19:12 libkdecore.dll.a
-rwxrwxrwx    1 1002     Kein         7526 Apr 20 19:01 libkdefakes.dll.a
-rwxrwxrwx    1 1002     Kein      5693370 Apr 20 01:16 libkdeui.dll.a


with patch
-rwxrwxrwx    1 1002     Kein      2126660 Apr 25 10:48 libkdecore.dll.a
-rwxrwxrwx    1 1002     Kein         1448 Apr 25 10:45 libkdefakes.dll.a
-rwxrwxrwx    1 1002     Kein      3622512 Apr 25 11:06 libkdeui.dll.a


$ diff pe-dll.c.orig pe-dll.c -ubBp
--- pe-dll.c.orig       Wed Apr 24 09:48:59 2002
+++ pe-dll.c    Thu Apr 25 08:33:08 2002
@@ -248,6 +250,8 @@ static autofilter_entry_type autofilter_
   /* Do __imp_ explicitly to save time.  */
   { "__rtti_", 7 },
   { "__builtin_", 10 },
+  // RH: prevent generating reimported functions
+  { "_nm_", 4 },
   /* Don't export symbols specifying internal DLL layout.  */
   { "_head_", 6 },
   { "_fmode", 6 },
@@ -1789,6 +1793,8 @@ make_one (exp, parent)
   quick_symbol (abfd, U ("_imp__"), exp->internal_name, "", id5, BSF_GLOBAL,
0);
   /* Symbol to reference ord/name of imported
      symbol, used to implement auto-import.  */
+  /* RH: only for auto-imported data */
+  if (exp->flag_data)
   quick_symbol (abfd, U("_nm__"), exp->internal_name, "", id6, BSF_GLOBAL, 0);
   if (pe_dll_compat_implib)
     quick_symbol (abfd, U ("__imp_"), exp->internal_name, "",

Any comments ?

Regards
Ralf Habacker



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]