From: Hans Kristian Rosbach Date: Thu, 29 Dec 2022 12:45:50 +0000 (+0100) Subject: Expand support for symbol versioning to also allow multiple functions X-Git-Tag: 2.1.4~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=828dde716b4666d681d2a6af748f7a1cd7a43fcf;p=thirdparty%2Fzlib-ng.git Expand support for symbol versioning to also allow multiple functions with the same name to exist with bindings to different versions. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 003e66db7..8d5d5ae9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1140,6 +1140,9 @@ if(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS) set_target_properties(zlib PROPERTIES COMPILE_FLAGS "-fno-semantic-interposition") endif() if(NOT APPLE) + if(NOT ZLIB_COMPAT) + add_definitions(-DHAVE_SYMVER) + endif() set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib${SUFFIX}.map\"") elseif(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}" OR NOT WITH_RPATH) diff --git a/configure b/configure index 53aa012a9..bb37b9664 100755 --- a/configure +++ b/configure @@ -567,6 +567,22 @@ else esac fi +# Symbol versioning +case "$uname" in + CYGWIN* | Cygwin* | cygwin* | MINGW* | mingw* | MSYS* | msys* | Darwin* | darwin*) + echo "Checking for Symbol versioning... No." + ;; + *) + if test $shared -eq 1; then + echo "Checking for Symbol versioning... Yes." + CFLAGS="${CFLAGS} -DHAVE_SYMVER" + SFLAGS="${SFLAGS} -DHAVE_SYMVER" + else + echo "Checking for Symbol versioning... No." + fi + ;; +esac + # Simplify some later conditionals case "$uname" in Linux* | linux*) @@ -2029,6 +2045,7 @@ EOF ;; esac +echo "Uname: $uname" echo "ARCH: ${ARCH}" echo "Using arch directory: ${ARCHDIR}" echo "Architecture-specific static object files:${ARCH_STATIC_OBJS}" diff --git a/zbuild.h b/zbuild.h index 2f9dd6b1c..bb964d6c0 100644 --- a/zbuild.h +++ b/zbuild.h @@ -119,6 +119,20 @@ # define Z_INTERNAL #endif +/* Symbol versioning helpers, allowing multiple versions of a function to exist. + * Functions using this must also be added to zlib-ng.map for each version. + * Double @@ means this is the default for newly compiled applications to link against. + * Single @ means this is kept for backwards compatibility. + * This is only used for Zlib-ng native API, and only on platforms supporting this. + */ +#if defined(HAVE_SYMVER) +# define ZSYMVER(func,alias,ver) __asm__(".symver " func ", " alias "@ZLIB_NG_" ver); +# define ZSYMVER_DEF(func,alias,ver) __asm__(".symver " func ", " alias "@@ZLIB_NG_" ver); +#else +# define ZSYMVER(func,alias,ver) +# define ZSYMVER_DEF(func,alias,ver) +#endif + #ifndef __cplusplus # define Z_REGISTER register #else