[Cbe-oss-dev] [PATCH] use -fvisibility=hidden in libspe

Christoph Hellwig hch at lst.de
Sat Jul 1 20:38:57 EST 2006


We can control visibility of symbols in ELF libraries.  The default
visibility allows everyone to see the symbols and means they need to go
through .GOT indirections, etc.  Switching the visibility to hidden for
all non-API symbols allows to reduce size of the library and speed it
up.  Besides keeping people from using internal symbols, of course.

For libspe the gain is:
   text	   data	    bss	    dec	    hex	filename
  55293	   1888	    148	  57329	   dff1	libspe.so.1.1.0
  59991	   1888	    148	  62027	   f24b	libspe.so.1.1.0.old

And here's the patch:


Index: libspe/libspe.h
===================================================================
--- libspe.orig/libspe.h	2006-07-01 12:26:57.000000000 +0200
+++ libspe/libspe.h	2006-07-01 12:32:14.000000000 +0200
@@ -142,6 +142,7 @@
 #define SPE_SIG_NOTIFY_REG_1		0x0001
 #define SPE_SIG_NOTIFY_REG_2		0x0002
 
+#pragma GCC visibility push(default)
 /* APIs for SPE threads.
  */
 extern spe_gid_t spe_create_group (int policy, int priority, int spe_events);
@@ -278,6 +279,7 @@
  * returns the file descriptor for the spe context.
  */
 extern int __spe_get_context_fd(speid_t speid);
+#pragma GCC visibility pop
 
 #endif
 
Index: libspe/spe.h
===================================================================
--- libspe.orig/spe.h	2006-07-01 12:26:57.000000000 +0200
+++ libspe/spe.h	2006-07-01 12:32:14.000000000 +0200
@@ -103,6 +103,7 @@
         int retfd;
 };
 
+#pragma GCC visibility push(default)
 /* Low-level SPE execution API.
  */
 
@@ -123,6 +124,7 @@
 
 extern void register_handler(void * handler, unsigned int callnum );
 extern int check_priority(int policy, int priority);
+#pragma GCC visibility pop
 
 /*
  * For testing purposes only 
Index: libspe/Makefile
===================================================================
--- libspe.orig/Makefile	2006-07-01 12:32:17.000000000 +0200
+++ libspe/Makefile	2006-07-01 12:32:37.000000000 +0200
@@ -66,6 +66,7 @@
 			-Wmissing-prototypes -Wmissing-declarations \
 			-Wmissing-noreturn -Wredundant-decls \
 			-Wnested-externs -Winline -Wformat \
+			-fvisibility=hidden \
 			${EXTRA_CFLAGS} ${OPTFLAGS}
 ifdef GLIBC23
 CFLAGS += -DHAVE_GLIBC23



More information about the cbe-oss-dev mailing list