Skip to content

Commit

Permalink
Expand support for symbol versioning to also allow multiple functions
Browse files Browse the repository at this point in the history
with the same name to exist with bindings to different versions.
  • Loading branch information
Dead2 committed Apr 25, 2023
1 parent 3f06cec commit 65e933c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,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\"")
else()
Expand Down
17 changes: 17 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,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*)
Expand Down Expand Up @@ -2019,6 +2035,7 @@ EOF
;;
esac

echo "Uname: $uname"
echo "ARCH: ${ARCH}"
echo "Using arch directory: ${ARCHDIR}"
echo "Architecture-specific static object files:${ARCH_STATIC_OBJS}"
Expand Down
14 changes: 14 additions & 0 deletions zbuild.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,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
Expand Down

0 comments on commit 65e933c

Please sign in to comment.