diff options
author | João Valverde <j@v6e.pt> | 2023-01-25 21:41:55 +0000 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2023-02-13 00:24:21 +0000 |
commit | 9cb759b38eda2b4768e74bf77746a34f99b9ce9e (patch) | |
tree | 5a6ea54e8365885432b4f0d89051aa0538afa86b /wsutil | |
parent | 81996c5d79883b3615cbf70c4f0053e31c2ede8c (diff) |
Enable rpathification and working relocation on Linux (take 3)
Dumpcap depends on wsutil.so. The path to the shared library
is encoded in the RPATH (or RUNPATH) property of ELF binaries.
This is currently an absolute path on most Unixy systems.
Dumpcap could not be made to work with a relative RPATH because it
uses elevated privileges and some loaders will ignore relative
RPATHs and non-standard paths under those circumstances, because of
(justified) security concerns.
To enable relocation of the program we link dumpcap statically
with wsutil instead.
This provides a fully working relocatable installation on Linux
and other platforms that support relative RPATHs.
Diffstat (limited to 'wsutil')
-rw-r--r-- | wsutil/CMakeLists.txt | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/wsutil/CMakeLists.txt b/wsutil/CMakeLists.txt index 04dbcdd098..a886f9e248 100644 --- a/wsutil/CMakeLists.txt +++ b/wsutil/CMakeLists.txt @@ -410,6 +410,45 @@ install(FILES ${WSUTIL_PUBLIC_HEADERS} EXCLUDE_FROM_ALL ) +add_library(wsutil_static STATIC + ${WSUTIL_FILES} +) + +target_compile_definitions(wsutil_static PRIVATE + ENABLE_STATIC + BUILD_WSUTIL +) + +target_link_libraries(wsutil_static + PUBLIC + ${GLIB2_LIBRARIES} + PRIVATE + ${GMODULE2_LIBRARIES} + ${APPLE_CORE_FOUNDATION_LIBRARY} + ${CMAKE_DL_LIBS} + ${GCRYPT_LIBRARIES} + ${GNUTLS_LIBRARIES} + ${ZLIB_LIBRARIES} + ${PCRE2_LIBRARIES} + ${WIN_IPHLPAPI_LIBRARY} + ${WIN_WS2_32_LIBRARY} +) + +target_include_directories(wsutil_static SYSTEM + PUBLIC + ${GLIB2_INCLUDE_DIRS} + ${GCRYPT_INCLUDE_DIRS} + ${GNUTLS_INCLUDE_DIRS} + PRIVATE + ${GMODULE2_INCLUDE_DIRS} + ${ZLIB_INCLUDE_DIRS} + ${PCRE2_INCLUDE_DIRS} +) + +if(NOT VCSVERSION_OVERRIDE) + add_dependencies(wsutil_static vcs_version) +endif() + add_executable(wmem_test EXCLUDE_FROM_ALL wmem/wmem_test.c ${WMEM_FILES}) target_link_libraries(wmem_test wsutil) |