[PATCH libICE 1/7] Added visibility annotations.
Emil Velikov
emil.l.velikov at gmail.com
Sun May 8 08:19:30 UTC 2016
From: Yury Gribov <y.gribov at samsung.com>
This allow us to be good citizen by hiding the private symbols and
reducing the overall size of the binary.
Note: _IceTransNoListen must be exported (albeit being a non-public
symbol) as explained in the comment just above it.
Signed-off-by: Yury Gribov <y.gribov at samsung.com>
v2:
- Add commit message.
- Reuse existing CFLAGS
- Add a beefy comment about the _IceTransNoListen export.
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
Some numbers on my Arch setup.
$ size
text data bss dec hex filename
91409 3000 14560 108969 1a9a9 libICE.so.before
85227 2568 14560 102355 18fd3 libICE.so.after
$ nm -CD --defined-only | wc -l
libICE.so.6.3.0.before 137
libICE.so.6.3.0.after 65
---
configure.ac | 30 +++++++++++++++++
include/X11/ICE/ICElib.h | 82 +++++++++++++++++++++++------------------------
include/X11/ICE/ICEmsg.h | 18 +++++------
include/X11/ICE/ICEutil.h | 18 +++++------
src/icetrans.c | 16 +++++++++
5 files changed, 105 insertions(+), 59 deletions(-)
diff --git a/configure.ac b/configure.ac
index 458882a..2e76cf8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,6 +40,36 @@ AC_DEFINE(ICE_t, 1, [Xtrans transport type])
AC_CHECK_LIB([bsd], [arc4random_buf])
AC_CHECK_FUNCS([asprintf arc4random_buf])
+AC_MSG_CHECKING(for symbol visibility support)
+if test x$GCC = xyes; then
+ VISIBILITY_CFLAGS="-fvisibility=hidden"
+else
+ if test x$SUNCC = xyes; then
+ VISIBILITY_CFLAGS="-xldscope=hidden"
+ else
+ have_visibility=no
+ fi
+fi
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $VISIBILITY_CFLAGS $ICE_CFLAGS"
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
+ [#include <X11/Xfuncproto.h>
+ #if defined(__CYGWIN__) || defined(__MINGW32__)
+ #error No visibility support
+ #endif
+ extern _X_HIDDEN int hidden_int;
+ extern _X_EXPORT int public_int;
+ extern _X_HIDDEN int hidden_int_func(void);
+ extern _X_EXPORT int public_int_func(void);]],
+ [])],
+ have_visibility=yes,
+ have_visibility=no)
+CFLAGS=$save_CFLAGS
+AC_MSG_RESULT([$have_visibility])
+if test x$have_visibility != xno; then
+ ICE_CFLAGS="$ICE_CFLAGS $VISIBILITY_CFLAGS"
+fi
+
# Allow checking code with lint, sparse, etc.
XORG_WITH_LINT
XORG_LINT_LIBRARY([ICE])
diff --git a/include/X11/ICE/ICElib.h b/include/X11/ICE/ICElib.h
index 402cbc8..a1d2256 100644
--- a/include/X11/ICE/ICElib.h
+++ b/include/X11/ICE/ICElib.h
@@ -205,7 +205,7 @@ typedef void (*IceIOErrorHandler) (
_XFUNCPROTOBEGIN
-extern int IceRegisterForProtocolSetup (
+_X_EXPORT int IceRegisterForProtocolSetup (
const char * /* protocolName */,
const char * /* vendor */,
const char * /* release */,
@@ -217,7 +217,7 @@ extern int IceRegisterForProtocolSetup (
IceIOErrorProc /* IOErrorProc */
);
-extern int IceRegisterForProtocolReply (
+_X_EXPORT int IceRegisterForProtocolReply (
const char * /* protocolName */,
const char * /* vendor */,
const char * /* release */,
@@ -232,7 +232,7 @@ extern int IceRegisterForProtocolReply (
IceIOErrorProc /* IOErrorProc */
);
-extern IceConn IceOpenConnection (
+_X_EXPORT IceConn IceOpenConnection (
char * /* networkIdsList */,
IcePointer /* context */,
Bool /* mustAuthenticate */,
@@ -241,18 +241,18 @@ extern IceConn IceOpenConnection (
char * /* errorStringRet */
);
-extern IcePointer IceGetConnectionContext (
+_X_EXPORT IcePointer IceGetConnectionContext (
IceConn /* iceConn */
);
-extern Status IceListenForConnections (
+_X_EXPORT Status IceListenForConnections (
int * /* countRet */,
IceListenObj ** /* listenObjsRet */,
int /* errorLength */,
char * /* errorStringRet */
);
-extern Status IceListenForWellKnownConnections (
+_X_EXPORT Status IceListenForWellKnownConnections (
char * /* port */,
int * /* countRet */,
IceListenObj ** /* listenObjsRet */,
@@ -260,58 +260,58 @@ extern Status IceListenForWellKnownConnections (
char * /* errorStringRet */
);
-extern int IceGetListenConnectionNumber (
+_X_EXPORT int IceGetListenConnectionNumber (
IceListenObj /* listenObj */
);
-extern char *IceGetListenConnectionString (
+_X_EXPORT char *IceGetListenConnectionString (
IceListenObj /* listenObj */
);
-extern char *IceComposeNetworkIdList (
+_X_EXPORT char *IceComposeNetworkIdList (
int /* count */,
IceListenObj * /* listenObjs */
);
-extern void IceFreeListenObjs (
+_X_EXPORT void IceFreeListenObjs (
int /* count */,
IceListenObj * /* listenObjs */
);
-extern void IceSetHostBasedAuthProc (
+_X_EXPORT void IceSetHostBasedAuthProc (
IceListenObj /* listenObj */,
IceHostBasedAuthProc /* hostBasedAuthProc */
);
-extern IceConn IceAcceptConnection (
+_X_EXPORT IceConn IceAcceptConnection (
IceListenObj /* listenObj */,
IceAcceptStatus * /* statusRet */
);
-extern void IceSetShutdownNegotiation (
+_X_EXPORT void IceSetShutdownNegotiation (
IceConn /* iceConn */,
Bool /* negotiate */
);
-extern Bool IceCheckShutdownNegotiation (
+_X_EXPORT Bool IceCheckShutdownNegotiation (
IceConn /* iceConn */
);
-extern IceCloseStatus IceCloseConnection (
+_X_EXPORT IceCloseStatus IceCloseConnection (
IceConn /* iceConn */
);
-extern Status IceAddConnectionWatch (
+_X_EXPORT Status IceAddConnectionWatch (
IceWatchProc /* watchProc */,
IcePointer /* clientData */
);
-extern void IceRemoveConnectionWatch (
+_X_EXPORT void IceRemoveConnectionWatch (
IceWatchProc /* watchProc */,
IcePointer /* clientData */
);
-extern IceProtocolSetupStatus IceProtocolSetup (
+_X_EXPORT IceProtocolSetupStatus IceProtocolSetup (
IceConn /* iceConn */,
int /* myOpcode */,
IcePointer /* clientData */,
@@ -324,89 +324,89 @@ extern IceProtocolSetupStatus IceProtocolSetup (
char * /* errorStringRet */
);
-extern Status IceProtocolShutdown (
+_X_EXPORT Status IceProtocolShutdown (
IceConn /* iceConn */,
int /* majorOpcode */
);
-extern IceProcessMessagesStatus IceProcessMessages (
+_X_EXPORT IceProcessMessagesStatus IceProcessMessages (
IceConn /* iceConn */,
IceReplyWaitInfo * /* replyWait */,
Bool * /* replyReadyRet */
);
-extern Status IcePing (
+_X_EXPORT Status IcePing (
IceConn /* iceConn */,
IcePingReplyProc /* pingReplyProc */,
IcePointer /* clientData */
);
-extern char *IceAllocScratch (
+_X_EXPORT char *IceAllocScratch (
IceConn /* iceConn */,
unsigned long /* size */
);
-extern int IceFlush (
+_X_EXPORT int IceFlush (
IceConn /* iceConn */
);
-extern int IceGetOutBufSize (
+_X_EXPORT int IceGetOutBufSize (
IceConn /* iceConn */
);
-extern int IceGetInBufSize (
+_X_EXPORT int IceGetInBufSize (
IceConn /* iceConn */
);
-extern IceConnectStatus IceConnectionStatus (
+_X_EXPORT IceConnectStatus IceConnectionStatus (
IceConn /* iceConn */
);
-extern char *IceVendor (
+_X_EXPORT char *IceVendor (
IceConn /* iceConn */
);
-extern char *IceRelease (
+_X_EXPORT char *IceRelease (
IceConn /* iceConn */
);
-extern int IceProtocolVersion (
+_X_EXPORT int IceProtocolVersion (
IceConn /* iceConn */
);
-extern int IceProtocolRevision (
+_X_EXPORT int IceProtocolRevision (
IceConn /* iceConn */
);
-extern int IceConnectionNumber (
+_X_EXPORT int IceConnectionNumber (
IceConn /* iceConn */
);
-extern char *IceConnectionString (
+_X_EXPORT char *IceConnectionString (
IceConn /* iceConn */
);
-extern unsigned long IceLastSentSequenceNumber (
+_X_EXPORT unsigned long IceLastSentSequenceNumber (
IceConn /* iceConn */
);
-extern unsigned long IceLastReceivedSequenceNumber (
+_X_EXPORT unsigned long IceLastReceivedSequenceNumber (
IceConn /* iceConn */
);
-extern Bool IceSwapping (
+_X_EXPORT Bool IceSwapping (
IceConn /* iceConn */
);
-extern IceErrorHandler IceSetErrorHandler (
+_X_EXPORT IceErrorHandler IceSetErrorHandler (
IceErrorHandler /* handler */
);
-extern IceIOErrorHandler IceSetIOErrorHandler (
+_X_EXPORT IceIOErrorHandler IceSetIOErrorHandler (
IceIOErrorHandler /* handler */
);
-extern char *IceGetPeerName (
+_X_EXPORT char *IceGetPeerName (
IceConn /* iceConn */
);
@@ -414,15 +414,15 @@ extern char *IceGetPeerName (
* Multithread Routines
*/
-extern Status IceInitThreads (
+_X_EXPORT Status IceInitThreads (
void
);
-extern void IceAppLockConn (
+_X_EXPORT void IceAppLockConn (
IceConn /* iceConn */
);
-extern void IceAppUnlockConn (
+_X_EXPORT void IceAppUnlockConn (
IceConn /* iceConn */
);
diff --git a/include/X11/ICE/ICEmsg.h b/include/X11/ICE/ICEmsg.h
index f6e7121..d2636aa 100644
--- a/include/X11/ICE/ICEmsg.h
+++ b/include/X11/ICE/ICEmsg.h
@@ -39,46 +39,46 @@ _XFUNCPROTOBEGIN
* Function prototypes for internal ICElib functions
*/
-extern Status _IceRead (
+_X_EXPORT Status _IceRead (
IceConn /* iceConn */,
unsigned long /* nbytes */,
char * /* ptr */
);
-extern void _IceReadSkip (
+_X_EXPORT void _IceReadSkip (
IceConn /* iceConn */,
unsigned long /* nbytes */
);
-extern void _IceWrite (
+_X_EXPORT void _IceWrite (
IceConn /* iceConn */,
unsigned long /* nbytes */,
char * /* ptr */
);
-extern void _IceErrorBadMinor (
+_X_EXPORT void _IceErrorBadMinor (
IceConn /* iceConn */,
int /* majorOpcode */,
int /* offendingMinor */,
int /* severity */
);
-extern void _IceErrorBadState (
+_X_EXPORT void _IceErrorBadState (
IceConn /* iceConn */,
int /* majorOpcode */,
int /* offendingMinor */,
int /* severity */
);
-extern void _IceErrorBadLength (
+_X_EXPORT void _IceErrorBadLength (
IceConn /* iceConn */,
int /* majorOpcode */,
int /* offendingMinor */,
int /* severity */
);
-extern void _IceErrorBadValue (
+_X_EXPORT void _IceErrorBadValue (
IceConn /* iceConn */,
int /* majorOpcode */,
int /* offendingMinor */,
@@ -87,7 +87,7 @@ extern void _IceErrorBadValue (
IcePointer /* value */
);
-extern IcePoAuthStatus _IcePoMagicCookie1Proc (
+_X_EXPORT IcePoAuthStatus _IcePoMagicCookie1Proc (
IceConn /* iceConn */,
IcePointer * /* authStatePtr */,
Bool /* cleanUp */,
@@ -99,7 +99,7 @@ extern IcePoAuthStatus _IcePoMagicCookie1Proc (
char ** /* errorStringRet */
);
-extern IcePaAuthStatus _IcePaMagicCookie1Proc (
+_X_EXPORT IcePaAuthStatus _IcePaMagicCookie1Proc (
IceConn /* iceConn */,
IcePointer * /* authStatePtr */,
Bool /* swap */,
diff --git a/include/X11/ICE/ICEutil.h b/include/X11/ICE/ICEutil.h
index dbf1490..592993e 100644
--- a/include/X11/ICE/ICEutil.h
+++ b/include/X11/ICE/ICEutil.h
@@ -76,45 +76,45 @@ typedef struct {
* Function Prototypes
*/
-extern char *IceAuthFileName (
+_X_EXPORT char *IceAuthFileName (
void
);
-extern int IceLockAuthFile (
+_X_EXPORT int IceLockAuthFile (
const char * /* file_name */,
int /* retries */,
int /* timeout */,
long /* dead */
);
-extern void IceUnlockAuthFile (
+_X_EXPORT void IceUnlockAuthFile (
const char * /* file_name */
);
-extern IceAuthFileEntry *IceReadAuthFileEntry (
+_X_EXPORT IceAuthFileEntry *IceReadAuthFileEntry (
FILE * /* auth_file */
);
-extern void IceFreeAuthFileEntry (
+_X_EXPORT void IceFreeAuthFileEntry (
IceAuthFileEntry * /* auth */
);
-extern Status IceWriteAuthFileEntry (
+_X_EXPORT Status IceWriteAuthFileEntry (
FILE * /* auth_file */,
IceAuthFileEntry * /* auth */
);
-extern IceAuthFileEntry *IceGetAuthFileEntry (
+_X_EXPORT IceAuthFileEntry *IceGetAuthFileEntry (
const char * /* protocol_name */,
const char * /* network_id */,
const char * /* auth_name */
);
-extern char *IceGenerateMagicCookie (
+_X_EXPORT char *IceGenerateMagicCookie (
int /* len */
);
-extern void IceSetPaAuthData (
+_X_EXPORT void IceSetPaAuthData (
int /* numEntries */,
IceAuthDataEntry * /* entries */
);
diff --git a/src/icetrans.c b/src/icetrans.c
index 52e432b..8322f16 100644
--- a/src/icetrans.c
+++ b/src/icetrans.c
@@ -24,8 +24,24 @@
#include <config.h>
#endif
+#include <X11/Xfuncproto.h>
+
#define ICE_t 1
#define TRANS_CLIENT 1
#define TRANS_SERVER 1
+/* The following function is implemented via the Xtrans package based on the
+ * transport.c include.
+ *
+ * Quoting Alan Coopersmith:
+ * "While that's absolutely not part of the public API, and no one should have
+ * ever called it, since we utterly failed to give them any way to provide a
+ * reasonable security mode without it, I believe there are several important
+ * callers in the various DE's."
+ *
+ * [Emil Velikov] As of 5th of May 2016, at least KDE depends (via
+ * libkdeinit5_ksmserver.so module) on the function.
+ */
+_X_EXPORT int _IceTransNoListen(const char * protocol);
+
#include <X11/Xtrans/transport.c>
--
2.8.0
More information about the xorg-devel
mailing list