Skip to content

Commit 8a7cebf

Browse files
committed
build: add versioned symbol support
Among other uses, versioned symbols function as a kind of append-only API changelog, offering a hint to human users and to package managers indicating the minimum version of a library needed to run an executable Signed-off-by: Gordon Messmer <gmessmer@redhat.com>
1 parent 4b0bf50 commit 8a7cebf

File tree

4 files changed

+103
-1
lines changed

4 files changed

+103
-1
lines changed

configure.ac

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ dnl libtool configuration
5858
dnl ####
5959
LT_INIT([shared pic-only])
6060

61+
dnl ####
62+
dnl linker version script support
63+
dnl ####
64+
gl_LD_VERSION_SCRIPT
65+
6166
dnl ####
6267
dnl enable silent builds by default
6368
dnl ####

m4/ld-version-script.m4

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# ld-version-script.m4
2+
# serial 7
3+
dnl Copyright (C) 2008-2026 Free Software Foundation, Inc.
4+
dnl This file is free software; the Free Software Foundation
5+
dnl gives unlimited permission to copy and/or distribute it,
6+
dnl with or without modifications, as long as this notice is preserved.
7+
dnl This file is offered as-is, without any warranty.
8+
9+
dnl From Simon Josefsson
10+
11+
# FIXME: The test below returns a false positive for mingw
12+
# cross-compiles, 'local:' statements does not reduce number of
13+
# exported symbols in a DLL. Use --disable-ld-version-script to work
14+
# around the problem.
15+
16+
# gl_LD_VERSION_SCRIPT
17+
# --------------------
18+
# Check if LD supports linker scripts, and define automake conditional
19+
# HAVE_LD_VERSION_SCRIPT if so.
20+
AC_DEFUN([gl_LD_VERSION_SCRIPT],
21+
[
22+
AC_ARG_ENABLE([ld-version-script],
23+
[AS_HELP_STRING([[--enable-ld-version-script]],
24+
[enable linker version script (default is enabled when possible)])],
25+
[have_ld_version_script=$enableval],
26+
[AC_CACHE_CHECK([if LD -Wl,--version-script works],
27+
[gl_cv_sys_ld_version_script],
28+
[gl_cv_sys_ld_version_script=no
29+
saved_LDFLAGS=$LDFLAGS
30+
LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
31+
echo foo >conftest.map
32+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
33+
[],
34+
[cat > conftest.map <<EOF
35+
VERS_1 {
36+
global: sym;
37+
};
38+
39+
VERS_2 {
40+
global: sym;
41+
} VERS_1;
42+
EOF
43+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
44+
[gl_cv_sys_ld_version_script=yes])])
45+
rm -f conftest.map
46+
LDFLAGS=$saved_LDFLAGS])
47+
have_ld_version_script=$gl_cv_sys_ld_version_script])
48+
AM_CONDITIONAL([HAVE_LD_VERSION_SCRIPT],
49+
[test "$have_ld_version_script" = yes])
50+
])

src/Makefile.am

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ SOURCES_ALL = \
4949

5050
EXTRA_DIST = \
5151
arch-syscall-validate arch-syscall-check \
52-
arch-gperf-generate syscalls.csv syscalls.perf.template
52+
arch-gperf-generate syscalls.csv syscalls.perf.template \
53+
libseccomp.map
5354

5455
TESTS = arch-syscall-check
5556

@@ -65,6 +66,9 @@ libseccomp_la_CFLAGS = ${AM_CFLAGS} ${CODE_COVERAGE_CFLAGS} ${CFLAGS} \
6566
-fPIC -DPIC -fvisibility=hidden
6667
libseccomp_la_LDFLAGS = ${AM_LDFLAGS} ${CODE_COVERAGE_LDFLAGS} ${LDFLAGS} \
6768
-version-number ${VERSION_MAJOR}:${VERSION_MINOR}:${VERSION_MICRO}
69+
if HAVE_LD_VERSION_SCRIPT
70+
libseccomp_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libseccomp.map
71+
endif
6872

6973
EXTRA_DIST += syscalls.perf.c syscalls.perf
7074
CLEANFILES = syscalls.perf.c syscalls.perf

src/libseccomp.map

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* Avoid modifying a symbol set after it has been released
2+
When adding features in a new release, add a new set
3+
Removing features is a breaking change */
4+
LIBSECCOMP_1.0 {
5+
global:
6+
seccomp_api_get;
7+
seccomp_api_set;
8+
seccomp_arch_add;
9+
seccomp_arch_exist;
10+
seccomp_arch_native;
11+
seccomp_arch_remove;
12+
seccomp_arch_resolve_name;
13+
seccomp_attr_get;
14+
seccomp_attr_set;
15+
seccomp_export_bpf;
16+
seccomp_export_bpf_mem;
17+
seccomp_export_pfc;
18+
seccomp_init;
19+
seccomp_load;
20+
seccomp_merge;
21+
seccomp_notify_alloc;
22+
seccomp_notify_fd;
23+
seccomp_notify_free;
24+
seccomp_notify_id_valid;
25+
seccomp_notify_receive;
26+
seccomp_notify_respond;
27+
seccomp_precompute;
28+
seccomp_release;
29+
seccomp_reset;
30+
seccomp_rule_add;
31+
seccomp_rule_add_array;
32+
seccomp_rule_add_exact;
33+
seccomp_rule_add_exact_array;
34+
seccomp_syscall_priority;
35+
seccomp_syscall_resolve_name;
36+
seccomp_syscall_resolve_name_arch;
37+
seccomp_syscall_resolve_name_rewrite;
38+
seccomp_syscall_resolve_num_arch;
39+
seccomp_transaction_commit;
40+
seccomp_transaction_reject;
41+
seccomp_transaction_start;
42+
seccomp_version;
43+
};

0 commit comments

Comments
 (0)