[PATCH libICE] Enable visibility annotations

Yury Gribov y.gribov at samsung.com
Mon Apr 18 06:23:36 UTC 2016


On 04/15/2016 07:40 PM, Adam Jackson wrote:
> On Thu, 2016-04-14 at 09:50 +0300, Yury Gribov wrote:
>> Hi all,
>>
>> This patch adds visibility annotations to public functions in libICE and
>> also enables -fvisibility=hidden on platforms where it's available.
>>
>> This results in 10% size decrease (101K -> 92K) and 50% export symbols
>> reduction (141 -> 67) on x86_64.
>
> I'm not sure how you're getting those numbers? 'nm -D --defined' is
> giving me 138 exported before and 100 after, and:
>
>     text	   data	    bss	    dec	    hex	filename
>    90853	   3000	  14560	 108413	  1a77d	libICE.so.before
>    87507	   2712	  14560	 104779	  1994b	libICE.so.after
>
> More like 4k (3.3%) size decrease.

Hm, I originally used readelf but it returns (more or less) same results 
as nm:

$ nm -D --defined ~/install/libICE/usr/local/lib/libICE.so | wc -l
138
$ nm -D --defined ~/install/libICE-patched/usr/local/lib/libICE.so | wc -l
64

$ readelf -sDW ~/install/libICE/usr/local/lib/libICE.so | grep -v UND | 
wc -l
141
$ readelf -sDW ~/install/libICE-patched/usr/local/lib/libICE.so | grep 
-v UND | wc -l
67

It seems that some of the hidden symbols depend on system X11 headers 
e.g. _IceTransAccept from icetrans.c uses 
/usr/include/X11/Xtrans/transport.c which may be different on your system.

I've attached a list of old vs. new symbols on my system for reference.

> I'm a little cautious about patches like this. The X libraries have had
> an effectively static ABI for ages, so even functions that aren't
> exposed in the installed headers might find themselves in use. I'd like
> to at least know that, say, no app or lib in the Debian archive is
> importing any of the newly hidden symbols. Have you checked?

I totally agree that patches like this should be checked before deploy 
(even though using functions which are not a part of librarypublic 
interface may be considered a bad practice).

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

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.

-Y
-------------- next part --------------
__bss_start
_edata
_end
_fini
IceAcceptConnection
IceAddConnectionWatch
IceAllocScratch
IceAppLockConn
IceAppUnlockConn
IceAuthFileName
IceCheckShutdownNegotiation
IceCloseConnection
IceComposeNetworkIdList
IceConnectionNumber
IceConnectionStatus
IceConnectionString
_IceErrorBadLength
_IceErrorBadMinor
_IceErrorBadState
_IceErrorBadValue
IceFlush
IceFreeAuthFileEntry
IceFreeListenObjs
IceGenerateMagicCookie
IceGetAuthFileEntry
IceGetConnectionContext
IceGetInBufSize
IceGetListenConnectionNumber
IceGetListenConnectionString
IceGetOutBufSize
IceGetPeerName
IceInitThreads
IceLastReceivedSequenceNumber
IceLastSentSequenceNumber
IceListenForConnections
IceListenForWellKnownConnections
IceLockAuthFile
IceOpenConnection
_IcePaMagicCookie1Proc
IcePing
_IcePoMagicCookie1Proc
IceProcessMessages
IceProtocolRevision
IceProtocolSetup
IceProtocolShutdown
IceProtocolVersion
_IceRead
IceReadAuthFileEntry
_IceReadSkip
IceRegisterForProtocolReply
IceRegisterForProtocolSetup
IceRelease
IceRemoveConnectionWatch
IceSetErrorHandler
IceSetHostBasedAuthProc
IceSetIOErrorHandler
IceSetPaAuthData
IceSetShutdownNegotiation
IceSwapping
IceUnlockAuthFile
IceVendor
_IceWrite
IceWriteAuthFileEntry
_init
-------------- next part --------------
__bss_start
_edata
_end
_fini
IceAcceptConnection
IceAddConnectionWatch
_IceAddOpcodeMapping
_IceAddReplyWait
IceAllocScratch
IceAppLockConn
IceAppUnlockConn
_IceAuthCount
IceAuthFileName
_IceAuthNames
_IceCheckReplyReady
IceCheckShutdownNegotiation
IceCloseConnection
IceComposeNetworkIdList
_IceConnectionClosed
_IceConnectionCount
IceConnectionNumber
_IceConnectionObjs
_IceConnectionOpened
IceConnectionStatus
IceConnectionString
_IceConnectionStrings
_IceErrorAuthenticationFailed
_IceErrorAuthenticationRejected
_IceErrorBadLength
_IceErrorBadMajor
_IceErrorBadMinor
_IceErrorBadState
_IceErrorBadValue
_IceErrorHandler
_IceErrorMajorOpcodeDuplicate
_IceErrorNoAuthentication
_IceErrorNoVersion
_IceErrorProtocolDuplicate
_IceErrorSetupFailed
_IceErrorUnknownProtocol
IceFlush
IceFreeAuthFileEntry
_IceFreeConnection
IceFreeListenObjs
IceGenerateMagicCookie
IceGetAuthFileEntry
IceGetConnectionContext
IceGetInBufSize
IceGetListenConnectionNumber
IceGetListenConnectionString
IceGetOutBufSize
_IceGetPaAuthData
_IceGetPaValidAuthIndices
IceGetPeerName
_IceGetPeerName
_IceGetPoAuthData
_IceGetPoValidAuthIndices
IceInitThreads
_IceIOErrorHandler
_IceLastMajorOpcode
IceLastReceivedSequenceNumber
IceLastSentSequenceNumber
IceListenForConnections
IceListenForWellKnownConnections
IceLockAuthFile
IceOpenConnection
_IcePaAuthDataEntries
_IcePaAuthDataEntryCount
_IcePaAuthProcs
_IcePaMagicCookie1Proc
IcePing
_IcePoAuthProcs
_IcePoMagicCookie1Proc
IceProcessMessages
IceProtocolRevision
_IceProtocols
IceProtocolSetup
IceProtocolShutdown
IceProtocolVersion
_IceRead
IceReadAuthFileEntry
_IceReadSkip
IceRegisterForProtocolReply
IceRegisterForProtocolSetup
IceRelease
IceRemoveConnectionWatch
_IceSearchReplyWaits
IceSetErrorHandler
IceSetHostBasedAuthProc
IceSetIOErrorHandler
IceSetPaAuthData
_IceSetReplyReady
IceSetShutdownNegotiation
IceSwapping
_IceTransAccept
_IceTransBytesReadable
_IceTransClose
_IceTransCloseForCloning
_IceTransConnect
_IceTransCreateListener
_IceTransDisconnect
_IceTransFreeConnInfo
_IceTransGetConnectionNumber
_IceTransGetHostname
_IceTransGetMyAddr
_IceTransGetMyNetworkId
_IceTransGetPeerAddr
_IceTransGetPeerNetworkId
_IceTransIsListening
_IceTransIsLocal
_IceTransListen
_IceTransMakeAllCLTSServerListeners
_IceTransMakeAllCOTSServerListeners
_IceTransNoListen
_IceTransOpenCLTSClient
_IceTransOpenCLTSServer
_IceTransOpenCOTSClient
_IceTransOpenCOTSServer
_IceTransRead
_IceTransReadv
_IceTransReceived
_IceTransResetListener
_IceTransSetOption
_IceTransSocketINET6Funcs
_IceTransSocketINETFuncs
_IceTransSocketLocalFuncs
_IceTransSocketTCPFuncs
_IceTransSocketUNIXFuncs
_IceTransWrite
_IceTransWritev
IceUnlockAuthFile
IceVendor
_IceVersionCount
_IceVersions
_IceWatchProcs
_IceWrite
IceWriteAuthFileEntry
_init


More information about the xorg-devel mailing list