Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Implement symbol versioning

Restrict visibility of symbols to the symbols we actually want to be
public.
  • Loading branch information...
commit 57ffb888eb1bbec268df189d42926b7b5da26a5d 1 parent bbb1d1a
Tollef Fog Heen authored
4 configure.ac
@@ -441,6 +441,10 @@ AC_SUBST(VARNISH_STATE_DIR)
441 441 # Default configuration directory.
442 442 varnishconfdir='${sysconfdir}/varnish'
443 443 AC_SUBST(varnishconfdir)
  444 +
  445 +# Check for linker script support
  446 +gl_LD_VERSION_SCRIPT
  447 +
444 448 # Now that we're done using the compiler to look for functions and
445 449 # libraries, set CFLAGS to what we want them to be for our own code
446 450
9 lib/libvarnishapi/Makefile.am
@@ -24,9 +24,16 @@ libvarnishapi_la_SOURCES = \
24 24 vsm.c \
25 25 vsl_arg.c \
26 26 vsl.c \
27   - vsc.c
  27 + vsc.c \
  28 + libvarnishapi.map
28 29
29 30 libvarnishapi_la_CFLAGS = \
30 31 -DVARNISH_STATE_DIR='"${VARNISH_STATE_DIR}"'
31 32
32 33 libvarnishapi_la_LIBADD = @PCRE_LIBS@
  34 +
  35 +if HAVE_LD_VERSION_SCRIPT
  36 +libvarnishapi_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libvarnishapi.map
  37 +else
  38 +libvarnishapi_la_LDFLAGS += -export-symbols-regex '^V'
  39 +endif
70 lib/libvarnishapi/libvarnishapi.map
... ... @@ -0,0 +1,70 @@
  1 +/*-
  2 + * Copyright (c) 2011 Varnish Software AS
  3 + * All rights reserved.
  4 + *
  5 + * Author: Tollef Fog Heen <tfheen@varnish-software.com>
  6 + *
  7 + * Redistribution and use in source and binary forms, with or without
  8 + * modification, are permitted provided that the following conditions
  9 + * are met:
  10 + * 1. Redistributions of source code must retain the above copyright
  11 + * notice, this list of conditions and the following disclaimer.
  12 + * 2. Redistributions in binary form must reproduce the above copyright
  13 + * notice, this list of conditions and the following disclaimer in the
  14 + * documentation and/or other materials provided with the distribution.
  15 + *
  16 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  17 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19 + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
  20 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  21 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  22 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  23 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  24 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  25 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  26 + * SUCH DAMAGE.
  27 + */
  28 +
  29 +LIBVARNISHAPI_1.0 {
  30 + global:
  31 + # Functions
  32 + VSM_New;
  33 + VSM_Diag;
  34 + VSM_n_Arg;
  35 + VSM_Name;
  36 + VSM_Delete;
  37 + VSM_Open;
  38 + VSM_ReOpen;
  39 + VSM_Seq;
  40 + VSM_Head;
  41 + VSM_Find_Chunk;
  42 + VSM_Close;
  43 + VSM_iter0;
  44 + VSM_intern;
  45 +
  46 + VSC_Setup;
  47 + VSC_Arg;
  48 + VSC_Open;
  49 + VSC_Main;
  50 + VSC_Iter;
  51 +
  52 + VSL_Setup;
  53 + VSL_Open;
  54 + VSL_Arg;
  55 + VSL_H_Print;
  56 + VSL_Select;
  57 + VSL_NonBlocking;
  58 + VSL_Dispatch;
  59 + VSL_NextLog;
  60 + VSL_Matched;
  61 +
  62 + VCLI_WriteResult;
  63 + VCLI_ReadResult;
  64 + VCLI_AuthResponse;
  65 +
  66 + # Variables
  67 + VSL_tags;
  68 + local:
  69 + *;
  70 +};
44 m4/ld-version-script.m4
... ... @@ -0,0 +1,44 @@
  1 +# ld-version-script.m4 serial 1
  2 +dnl Copyright (C) 2008, 2009 Free Software Foundation, Inc.
  3 +dnl This file is free software; the Free Software Foundation
  4 +dnl gives unlimited permission to copy and/or distribute it,
  5 +dnl with or without modifications, as long as this notice is preserved.
  6 +
  7 +dnl From Simon Josefsson
  8 +
  9 +# FIXME: The test below returns a false positive for mingw
  10 +# cross-compiles, 'local:' statements does not reduce number of
  11 +# exported symbols in a DLL. Use --disable-ld-version-script to work
  12 +# around the problem.
  13 +
  14 +# gl_LD_VERSION_SCRIPT
  15 +# --------------------
  16 +# Check if LD supports linker scripts, and define automake conditional
  17 +# HAVE_LD_VERSION_SCRIPT if so.
  18 +AC_DEFUN([gl_LD_VERSION_SCRIPT],
  19 +[
  20 + AC_ARG_ENABLE([ld-version-script],
  21 + AS_HELP_STRING([--enable-ld-version-script],
  22 + [enable linker version script (default is enabled when possible)]),
  23 + [have_ld_version_script=$enableval], [])
  24 + if test -z "$have_ld_version_script"; then
  25 + AC_MSG_CHECKING([if LD -Wl,--version-script works])
  26 + save_LDFLAGS="$LDFLAGS"
  27 + LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
  28 + cat > conftest.map <<EOF
  29 +VERS_1 {
  30 + global: sym;
  31 +};
  32 +
  33 +VERS_2 {
  34 + global: sym;
  35 +} VERS_1;
  36 +EOF
  37 + AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
  38 + [have_ld_version_script=yes], [have_ld_version_script=no])
  39 + rm -f conftest.map
  40 + LDFLAGS="$save_LDFLAGS"
  41 + AC_MSG_RESULT($have_ld_version_script)
  42 + fi
  43 + AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
  44 +])

0 comments on commit 57ffb88

Please sign in to comment.
Something went wrong with that request. Please try again.