Linker script vs. visibility patch

Karl Vogel karl.vogel at seagha.com
Wed Jul 21 15:46:54 CEST 2004


Here is an overview of konsole compiled with a linker script vs using 
-fvisibility=hidden + KDE_EXPORT:

Normal build:

 217942 Jul 21 14:50 .libs.full/kded_kwrited.so
   6262 Jul 21 14:55 .libs.full/konsole.so
2493671 Jul 21 14:54 .libs.full/libkdeinit_konsole.so
1659603 Jul 21 14:50 .libs.full/libkonsolepart.so

Build with -fvisibility=hidden and KDE_EXPORT:

 210666 Jul 21 15:19 .libs/kded_kwrited.so
   6214 Jul 21 15:21 .libs/konsole.so
2393839 Jul 21 15:21 .libs/libkdeinit_konsole.so
1591911 Jul 21 15:21 .libs/libkonsolepart.so

Build with KDEINIT_VSCRIPT linker script:

2395943 Jul 21 14:52 .libs.map/libkdeinit_konsole.so


And the relocation information:

.libs.full/kded_kwrited.so: 198 relocations, 51 relative (25%), 128 PLT entries
.libs.full/konsole.so: 5 relocations, 2 relative (40%), 2 PLT entries
.libs.full/libkdeinit_konsole.so: 3757 relocations, 1012 relative (26%), 1402 PLT entries
.libs.full/libkonsolepart.so: 2177 relocations, 621 relative (28%), 950 PLT entries

.libs/kded_kwrited.so: 192 relocations, 103 relative (53%), 103 PLT entries
.libs/konsole.so: 5 relocations, 2 relative (40%), 2 PLT entries
.libs/libkdeinit_konsole.so: 3728 relocations, 1787 relative (47%), 810 PLT entries
.libs/libkonsolepart.so: 2152 relocations, 1173 relative (54%), 539 PLT entries

.libs.map/libkdeinit_konsole.so: 3757 relocations, 1816 relative (48%), 810 PLT entries

Changes to sources:

kdemacros.h :
-#define KDE_EXPORT __attribute__ ((visibility("visible")))
+#define KDE_EXPORT __attribute__ ((visibility("default")))

Index: konsole_part.cpp
===================================================================
RCS file: /home/kde/kdebase/konsole/konsole/konsole_part.cpp,v
retrieving revision 1.93
diff -u -r1.93 konsole_part.cpp
--- konsole_part.cpp	6 May 2004 18:58:37 -0000	1.93
+++ konsole_part.cpp	21 Jul 2004 13:22:55 -0000
@@ -60,7 +60,7 @@
    * the form 'void *init_lib<library name>()  It always returns a
    * new factory object
    */
-  void *init_libkonsolepart()
+  void KDE_EXPORT *init_libkonsolepart()
   {
     return new konsoleFactory;
   }
Index: kwrited.cpp
===================================================================
RCS file: /home/kde/kdebase/konsole/konsole/kwrited.cpp,v
retrieving revision 1.42
diff -u -r1.42 kwrited.cpp
--- kwrited.cpp	20 Apr 2004 15:13:39 -0000	1.42
+++ kwrited.cpp	21 Jul 2004 13:22:55 -0000
@@ -91,7 +91,7 @@
 }
 
 extern "C"
-KDEDModule *create_kwrited( const QCString& obj )
+KDEDModule KDE_EXPORT *create_kwrited( const QCString& obj )
     {
     return new KWritedModule( obj );
     }
Index: main.cpp
===================================================================
RCS file: /home/kde/kdebase/konsole/konsole/main.cpp,v
retrieving revision 1.267
diff -u -r1.267 main.cpp
--- main.cpp	10 Jul 2004 15:51:52 -0000	1.267
+++ main.cpp	21 Jul 2004 13:22:56 -0000
@@ -149,7 +149,7 @@
 
 
 /* --| main |------------------------------------------------------ */
-extern "C" int kdemain(int argc, char* argv[])
+extern "C" int KDE_EXPORT kdemain(int argc, char* argv[])
 {
   setgid(getgid()); setuid(getuid()); // drop privileges
 


More information about the Kde-optimize mailing list