[PATCH] libkdeinit symbol pruning

Karl Vogel karl.vogel at seagha.com
Sun Jul 18 16:25:48 CEST 2004


It seems that the extra symbol problem is not only restricted to kcm plugins:

$ objdump -CT /opt/kde/lib/libkdeinit_*.so|egrep "g +DF .text"|grep -v kdemain|wc -l
7682


A quick test with libkdeinit_konqueror.so shows that it exports 812 unused
symbols, after using a version script to only export kdemain, the binary size
was reduced with some 140Kb!

Before:

-rwxr-xr-x 1 kvo kvo 3860293 Jul 5 00:21 /opt/kde/lib/libkdeinit_konqueror.so

After:

-rwxr-xr-x 1 kvo kvo 3721942 Jul 18 16:00 /opt/kde/lib/libkdeinit_konqueror.so



Following patch alters am_edit to make libkdeinit_ libraries only export
kdemain():

--- admin/am_edit.orig  2004-07-18 15:32:02.977675288 +0200
+++ admin/am_edit       2004-07-18 16:10:37.813766712 +0200
@@ -892,7 +892,7 @@
                     substituteLine($lookup, "${kdeinit}_la_LIBADD = libkdeinit_${kdeinit}.la");
                     appendLines("libkdeinit_${kdeinit}_la_LIBADD = $libadd\n");
                 }
-                appendLines("libkdeinit_${kdeinit}_la_LDFLAGS = -no-undefined -avoid-version \$(all_libraries)\n");
+                appendLines("libkdeinit_${kdeinit}_la_LDFLAGS = -Wl,--version-script=\$(top_srcdir)/admin/kdeinit.map -no-undefined -avoid-version \$(all_libraries)\n");

                 # add library dependencies
                 $lookup = $kdeinit . '_la_DEPENDENCIES\s*=[ \t]*(.*)';


It needs the following version script in the admin directory:

$ cat admin/kdeinit.map
{
        global: kdemain;
        local: *;
};


NOTE: unsermake seems to ignore the am_edit changes, so if you use unsermake
it will _NOT_ use the version script! Something for an unsermake-whiz to look
at :-)


More information about the Kde-optimize mailing list