From 92c94e7df230dd86eb46e8edf8e9d92531d5f6ef Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Wed, 20 Jun 2012 12:48:27 -0400 Subject: [PATCH] Add symbol versioning For ELF systems, turn on versioned symbols by default, and add a configure option to enable or disable them. --- TODO | 53 +++++++----------------------------------------- autoconf.mk.in | 1 + configure.ac | 34 +++++++++++++++++++++++++++++++ libqpdf.map | 4 ++++ libqpdf/build.mk | 4 +++- make/libtool.mk | 9 +++++++- 6 files changed, 57 insertions(+), 48 deletions(-) create mode 100644 libqpdf.map diff --git a/TODO b/TODO index 9ca8b858..0083c89f 100644 --- a/TODO +++ b/TODO @@ -4,6 +4,13 @@ Next * Get rid of off_t. size_t is okay. Use autoconf to figure out what type to use for offsets. + * Get rid of int/size_t/off_t inconsistencies. MSVC 2010 can find + these if you add /w14267 to the compilation. We might want to do + this by default. The easiest way to fix this on Windows is to + modify msvc.mk to add this to both cl /c lines and run + + make 2>&1 | tee build.log + * Deal with portability issues from gcc 4.7. See portability.patch from debian package. @@ -11,52 +18,6 @@ Next to build and test cleanly in 2.3.1. Hopefully the next release will include 64-bit binary distributions and external libraries. - * Add versioned symbols. Fix below to not use AM_CONDITIONAL. Just - set some variable that can be part of LDFLAGS, like - LD_VERSION_SCRIPT, instead. - -# Check if LD supports linker scripts, and define conditional -# HAVE_LD_VERSION_SCRIPT if so. This functionality is currently -# constrained to compilers using GNU ld on ELF systems or systems -# which provide an adequate emulation thereof. -AC_ARG_ENABLE([ld-version-script], - AS_HELP_STRING([--enable-ld-version-script], - [enable linker version script (default is disabled)]), - [have_ld_version_script=$enableval], [have_ld_version_script=no]) -if test "$have_ld_version_script" != no; then - AC_MSG_CHECKING([if LD -Wl,--version-script works]) - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map" - cat > conftest.map < conftest.map <= 3.81) make_okay=0 if make --version >/dev/null 2>&1; then diff --git a/libqpdf.map b/libqpdf.map new file mode 100644 index 00000000..857f56cb --- /dev/null +++ b/libqpdf.map @@ -0,0 +1,4 @@ +LIBQPDF_8 { + global: + *; +}; diff --git a/libqpdf/build.mk b/libqpdf/build.mk index ec770c23..c5549202 100644 --- a/libqpdf/build.mk +++ b/libqpdf/build.mk @@ -64,6 +64,8 @@ $(OBJS_libqpdf): libqpdf/$(OUTPUT_DIR)/%.$(LOBJ): libqpdf/%.cc # # * If any interfaces have been removed or changed, we are not binary # compatible. Increment CURRENT, and set AGE and REVISION to 0. +# Also update libqpdf.map, changing the numeric portion to match +# CURRENT. # # * Otherwise, if any interfaces have been added since the last # public release, then increment CURRENT and AGE, and set REVISION @@ -72,4 +74,4 @@ $(OBJS_libqpdf): libqpdf/$(OUTPUT_DIR)/%.$(LOBJ): libqpdf/%.cc # * Otherwise, increment REVISION $(TARGETS_libqpdf): $(OBJS_libqpdf) - $(call makelib,$(OBJS_libqpdf),$@,$(LDFLAGS),$(LIBS),7,1,4) + $(call makelib,$(OBJS_libqpdf),$@,$(LDFLAGS),$(LIBS),8,0,0) diff --git a/make/libtool.mk b/make/libtool.mk index 8cd94325..e23ed246 100644 --- a/make/libtool.mk +++ b/make/libtool.mk @@ -18,6 +18,12 @@ endef # --- Private definitions --- +ifeq ($(HAVE_LD_VERSION_SCRIPT), 1) +LD_VERSION_FLAGS=-Wl,--version-script=libqpdf.map +else +LD_VERSION_FLAGS= +endif + # Usage: $(call libdepflags,$(basename obj)) # Usage: $(call fixdeps,$(basename obj)) ifeq ($(GENDEPS),1) @@ -83,7 +89,8 @@ endef # Usage: $(call makelib,objs,library,ldflags,libs,current,revision,age) define makelib $(LIBTOOL) --mode=link \ - $(CXX) $(CXXFLAGS) -o $(2) $(1) $(3) $(4) \ + $(CXX) $(CXXFLAGS) $(LD_VERSION_FLAGS) \ + -o $(2) $(1) $(3) $(4) \ -rpath $(libdir) -version-info $(5):$(6):$(7) endef