[PATCH libICE] Enable visibility annotations

Yury Gribov y.gribov at samsung.com
Wed Apr 27 07:48:48 UTC 2016


On 04/26/2016 02:14 PM, Emil Velikov wrote:
> On 26 April 2016 at 07:54, Yury Gribov <y.gribov at samsung.com> wrote:
>> On 04/20/2016 10:03 AM, Yury Gribov wrote:
>>>
>>> On 04/19/2016 06:35 PM, Yury Gribov wrote:
>>>>
>>>> On 04/18/2016 06:21 PM, Adam Jackson wrote:
>>>>>
>>>>> On Mon, 2016-04-18 at 09:23 +0300, Yury Gribov wrote:
>>>>>
>>>>>> Does below look like a sane approach?
>>>>>> 1) get all deps via
>>>>>>      $ apt-cache rdepends libice6 libice-dev
>>>>>> 2) unpack each of the above .debs and scan for ELFs
>>>>>> 3) for each ELF see if one of now hidden symbols is UND
>>>>>
>>>>>
>>>>> That sounds good to me.
>>>>
>>>>
>>>> I've cooked a simple script (attached, reviews welcome) and applied it
>>>> to Ubuntu 14. It showed that there are additional uses for
>>>> _IceTransNoListen (mentioned by Alan in separate email) but nothing else.
>>>>
>>>>>> Note that this does not handle transitive dependencies e.g. if some
>>>>>> weird library links static version of libICE and the re-exports it's
>>>>>> symbols as part of new lib's public interface.
>>>>>
>>>>>
>>>>> It'd be possible to scan for this too I suspect.  Look for packages
>>>>> that BuildRequire libice6-static, scan the resulting binaries for
>>>>> exports. I suspect there are zero such packages.
>>>>
>>>>
>>>> I have postponed this activity for now (especially given that this
>>>> behavior would be a serious packaging abuse).
>>>
>>>
>>> Here's an updated patch with added _IceTransNoListen.  Does this look
>>> better now?
>>
>>
>> Ping.
>>
> Pong. Sending patches as attachments is not the most productive way to
> get things reviewed ;-)

I see. Strangely the Content-Disposition in my previous email is 
properly set to "inline". I've both inlined and attached the new patch 
to be sure.

> But seriously, you want to update the configure.ac to handle more than
> just GCC. Feel free to copy some/most of the logic from xserver's
> configure.ac

Right, fixed. I initially decided to not copy the visibility detection 
hunk from other places because was unsure of licenses and stuff. But 
xserver license is obviously compatible so should be fine.

> Emil
>
>


 From 40fa9c6eb6fbaa924bf90efcefef681bbaab4194 Mon Sep 17 00:00:00 2001
From: Yury Gribov <y.gribov at samsung.com>
Date: Tue, 12 Apr 2016 17:04:09 +0300
Subject: [PATCH] Added visibility annotations.

Signed-off-by: Yury Gribov <y.gribov at samsung.com>
---
  configure.ac              | 42 ++++++++++++++++++++++++
  include/X11/ICE/ICElib.h  | 82 
+++++++++++++++++++++++------------------------
  include/X11/ICE/ICEmsg.h  | 18 +++++------
  include/X11/ICE/ICEutil.h | 18 +++++------
  src/icetrans.c            |  4 +++
  5 files changed, 105 insertions(+), 59 deletions(-)

diff --git a/configure.ac b/configure.ac
index 458882a..f63da07 100644
--- a/configure.ac
+++ b/configure.ac
@@ -29,8 +29,13 @@ XORG_WITH_FOP
  XORG_WITH_XSLTPROC
  XORG_CHECK_SGML_DOCTOOLS(1.8)

+AC_ARG_ENABLE(visibility, AS_HELP_STRING([--enable-visibility], [Enable 
symbol visibility (default: auto)]),
+              [SYMBOL_VISIBILITY=$enableval],
+              [SYMBOL_VISIBILITY=auto])
+
  # Obtain compiler/linker options for depedencies
  PKG_CHECK_MODULES(ICE, xproto xtrans)
+PKG_PROG_PKG_CONFIG

  # Transport selection macro from xtrans.m4
  XTRANS_CONNECTION_FLAGS
@@ -40,6 +45,43 @@ AC_DEFINE(ICE_t, 1, [Xtrans transport type])
  AC_CHECK_LIB([bsd], [arc4random_buf])
  AC_CHECK_FUNCS([asprintf arc4random_buf])

+have_visibility=disabled
+if test x$SYMBOL_VISIBILITY != xno; then
+  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
+  if test x$have_visibility != xno; then
+    save_CFLAGS="$CFLAGS"
+    proto_inc=`$PKG_CONFIG --cflags xproto`
+    CFLAGS="$CFLAGS $VISIBILITY_CFLAGS $proto_inc"
+    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
+  fi
+  AC_MSG_RESULT([$have_visibility])
+  if test x$have_visibility != xno; then
+    ICE_CFLAGS="$ICE_CFLAGS $VISIBILITY_CFLAGS"
+  fi
+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..8005aba 100644
--- a/src/icetrans.c
+++ b/src/icetrans.c
@@ -24,8 +24,12 @@
  #include <config.h>
  #endif

+#include <X11/Xfuncproto.h>
+
  #define ICE_t 1
  #define TRANS_CLIENT 1
  #define TRANS_SERVER 1

+_X_EXPORT int _IceTransNoListen (const char * protocol);
+
  #include <X11/Xtrans/transport.c>
-- 
1.9.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Added-visibility-annotations.patch
Type: text/x-patch
Size: 13104 bytes
Desc: not available
URL: <https://lists.x.org/archives/xorg-devel/attachments/20160427/09afab17/attachment-0001.bin>


More information about the xorg-devel mailing list