* [PATCH v2] Add conditional version script support
@ 2025-08-12 5:07 Khem Raj
0 siblings, 0 replies; only message in thread
From: Khem Raj @ 2025-08-12 5:07 UTC (permalink / raw)
To: libtirpc-devel; +Cc: linux-nfs, Khem Raj
This patch adds conditional symbol versioning to libtirpc, allowing
GSS-API, DES crypto, and RPC database symbols to be conditionally
included in the version script based on build configuration.
LLD is strict about undefined symbols referenced in a version script.
Some libtirpc symbols (rpcsec_gss, old DES helpers, rpc database
helpers) are optional and may not be built depending on configure
options or missing deps. GNU ld tolerated this; LLD errors out.
This change keeps the canonical symbol map in src/libtirpc.map, but
adds a make-time rule to generate a filtered copy
where names from disabled features are deleted. The lib is then linked
against the generated linker map file.
Fixes linking errors when these features are not available.
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
v2: Fix access to generated libtirpc.map when Srcdir != Builddir
configure.ac | 50 +++++++++++++++++++++++++++
src/Makefile.am | 23 ++++++++++--
src/{libtirpc.map => libtirpc.map.in} | 48 +++++--------------------
3 files changed, 78 insertions(+), 43 deletions(-)
rename src/{libtirpc.map => libtirpc.map.in} (84%)
diff --git a/configure.ac b/configure.ac
index e813b14..e8ff741 100644
--- a/configure.ac
+++ b/configure.ac
@@ -77,6 +77,20 @@ if test "x$enable_ipv6" != xno; then
AC_DEFINE(INET6, 1, [Define to 1 if IPv6 is available])
fi
+# RPC database support
+AC_ARG_ENABLE(rpcdb,
+ [AS_HELP_STRING([--enable-rpcdb], [Enable RPC Database support @<:@default=no@:>@])],
+ [], [enable_rpcdb=no],
+ [enable_rpcdb=auto])
+if test "x$enable_rpcdb" != "xno"; then
+ AC_CHECK_FUNCS([getrpcent getrpcbyname getrpcbynumber], [have_rpcdb=yes])
+
+ if test "x$have_rpcdb" = "xyes"; then
+ AC_DEFINE([RPCDB], [1], [Define if RPC database support is available])
+ fi
+fi
+AM_CONDITIONAL(RPCDB, test "x$enable_rpcdb" != xno)
+
AC_ARG_ENABLE(symvers,
[AS_HELP_STRING([--disable-symvers],[Disable symbol versioning @<:@default=no@:>@])],
[],[enable_symvers=maybe])
@@ -97,6 +111,33 @@ fi
AM_CONDITIONAL(SYMVERS, test "x$enable_symvers" = xyes)
+# Generate symbol lists for version script
+if test "x$enable_gssapi" = "xyes"; then
+ GSS_SYMBOLS="_svcauth_gss; authgss_create; authgss_create_default; authgss_free_private_data; authgss_get_private_data; authgss_service; gss_log_debug; gss_log_hexdump; gss_log_status; rpc_gss_get_error; rpc_gss_get_mech_info; rpc_gss_get_mechanisms; rpc_gss_get_principal_name; rpc_gss_get_versions; rpc_gss_qop_to_num; rpc_gss_seccreate; rpc_gss_set_callback; rpc_gss_set_defaults; rpc_gss_set_svc_name; rpc_gss_svc_max_data_length;"
+
+ GSS_SYMBOLS_031="svcauth_gss_get_principal; svcauth_gss_set_svc_name;"
+else
+ GSS_SYMBOLS=""
+ GSS_SYMBOLS_031=""
+fi
+
+if test "x$enable_authdes" = "xyes"; then
+ DES_SYMBOLS="cbc_crypt; ecb_crypt; xdr_authdes_cred; xdr_authdes_verf; xdr_rpc_gss_cred; xdr_rpc_gss_data; xdr_rpc_gss_init_args; xdr_rpc_gss_init_res;"
+else
+ DES_SYMBOLS=""
+fi
+
+if test "x$enable_rpcdb" = "xyes"; then
+ RPCDB_SYMBOLS="endrpcent; getrpcent; getrpcbynumber; getrpcbyname; setrpcent;"
+else
+ RPCDB_SYMBOLS=""
+fi
+
+AC_SUBST([GSS_SYMBOLS])
+AC_SUBST([GSS_SYMBOLS_031])
+AC_SUBST([DES_SYMBOLS])
+AC_SUBST([RPCDB_SYMBOLS])
+
AC_CANONICAL_BUILD
# Check for which host we are on and setup a few things
# specifically based on the host
@@ -167,7 +208,16 @@ AC_CHECK_FUNCS([getpeereid getrpcbyname getrpcbynumber setrpcent endrpcent getrp
AC_CHECK_TYPES(struct rpcent,,, [
#include <netdb.h>])
AC_CONFIG_FILES([Makefile src/Makefile man/Makefile doc/Makefile])
+AC_CONFIG_FILES([src/libtirpc.map])
AC_CONFIG_FILES([libtirpc.pc])
AC_OUTPUT
+# Configuration summary
+AC_MSG_NOTICE([
+libtirpc configuration summary:
+ GSS-API support: $enable_gssapi
+ DES crypto support: $enable_authdes
+ RPC database support: $enable_rpcdb
+ Symbol versioning: $enable_symvers
+])
diff --git a/src/Makefile.am b/src/Makefile.am
index 0cef093..bae14ca 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,6 +6,9 @@
## anything like that.
noinst_HEADERS = rpc_com.h debug.h
+EXTRA_DIST = libtirpc.map.in
+# Generated files
+BUILT_SOURCES = libtirpc.map
AM_CPPFLAGS = -I$(top_srcdir)/tirpc -include config.h -DPORTMAP -DINET6 \
-D_GNU_SOURCE -Wall -pipe
@@ -15,10 +18,19 @@ lib_LTLIBRARIES = libtirpc.la
libtirpc_la_LDFLAGS = @LDFLAG_NOUNDEFINED@ -no-undefined @PTHREAD_LIBS@
libtirpc_la_LDFLAGS += -version-info @LT_VERSION_INFO@
+# Generate version script from template
+libtirpc.map: $(srcdir)/libtirpc.map.in
+ $(AM_V_GEN)$(SED) \
+ -e 's|@GSS_SYMBOLS@|$(GSS_SYMBOLS)|g' \
+ -e 's|@GSS_SYMBOLS_031@|$(GSS_SYMBOLS_031)|g' \
+ -e 's|@DES_SYMBOLS@|$(DES_SYMBOLS)|g' \
+ -e 's|@RPCDB_SYMBOLS@|$(RPCDB_SYMBOLS)|g' \
+ < $(srcdir)/libtirpc.map.in > $@ || rm -f $@
+
libtirpc_la_SOURCES = auth_none.c auth_unix.c authunix_prot.c \
binddynport.c bindresvport.c \
clnt_bcast.c clnt_dg.c clnt_generic.c clnt_perror.c clnt_raw.c clnt_simple.c \
- clnt_vc.c rpc_dtablesize.c getnetconfig.c getnetpath.c getrpcent.c \
+ clnt_vc.c rpc_dtablesize.c getnetconfig.c getnetpath.c \
getrpcport.c mt_misc.c pmap_clnt.c pmap_getmaps.c pmap_getport.c \
pmap_prot.c pmap_prot2.c pmap_rmt.c rpc_prot.c rpc_commondata.c \
rpc_callmsg.c rpc_generic.c rpc_soc.c rpcb_clnt.c rpcb_prot.c \
@@ -34,7 +46,7 @@ endif
libtirpc_la_SOURCES += xdr.c xdr_rec.c xdr_array.c xdr_float.c xdr_mem.c xdr_reference.c xdr_stdio.c xdr_sizeof.c
if SYMVERS
- libtirpc_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libtirpc.map
+ libtirpc_la_LDFLAGS += -Wl,--version-script=$(builddir)/libtirpc.map
endif
## Secure-RPC
@@ -45,8 +57,13 @@ if GSS
libtirpc_la_CFLAGS = -DHAVE_RPCSEC_GSS $(GSSAPI_CFLAGS)
endif
+# Conditionally add RPC database sources
+if RPCDB
+ libtirpc_la_SOURCES += getrpcent.c
+endif
+
libtirpc_la_SOURCES += key_call.c key_prot_xdr.c getpublickey.c
libtirpc_la_SOURCES += netname.c netnamer.c rpcdname.c rtime.c
-CLEANFILES = cscope.* *~
+CLEANFILES = cscope.* libtirpc.map *~
DISTCLEANFILES = Makefile.in
diff --git a/src/libtirpc.map b/src/libtirpc.map.in
similarity index 84%
rename from src/libtirpc.map
rename to src/libtirpc.map.in
index 21d6065..6cf563b 100644
--- a/src/libtirpc.map
+++ b/src/libtirpc.map.in
@@ -34,16 +34,10 @@ TIRPC_0.3.0 {
_svcauth_none;
_svcauth_short;
_svcauth_unix;
- _svcauth_gss;
# a*
authdes_create;
authdes_seccreate;
- authgss_create;
- authgss_create_default;
- authgss_free_private_data;
- authgss_get_private_data;
- authgss_service;
authnone_create;
authunix_create;
authunix_create_default;
@@ -54,7 +48,6 @@ TIRPC_0.3.0 {
# c*
callrpc;
- cbc_crypt;
clnt_broadcast;
clnt_create;
clnt_create_timed;
@@ -79,10 +72,8 @@ TIRPC_0.3.0 {
clntunix_create;
# e*
- ecb_crypt;
endnetconfig;
endnetpath;
- endrpcent;
# f*
freenetconfigent;
@@ -92,13 +83,7 @@ TIRPC_0.3.0 {
getnetconfig;
getnetconfigent;
getnetpath;
- getrpcent;
- getrpcbynumber;
- getrpcbyname;
getrpcport;
- gss_log_debug;
- gss_log_hexdump;
- gss_log_status;
# n*
nc_perror;
@@ -118,21 +103,6 @@ TIRPC_0.3.0 {
rpc_call;
rpc_control;
rpc_createerr;
- rpc_gss_get_error;
- rpc_gss_get_mech_info;
- rpc_gss_get_mechanisms;
- rpc_gss_get_principal_name;
- rpc_gss_get_versions;
- rpc_gss_getcred;
- rpc_gss_is_installed;
- rpc_gss_max_data_length;
- rpc_gss_mech_to_oid;
- rpc_gss_qop_to_num;
- rpc_gss_seccreate;
- rpc_gss_set_callback;
- rpc_gss_set_defaults;
- rpc_gss_set_svc_name;
- rpc_gss_svc_max_data_length;
rpc_nullproc;
rpc_reg;
rpcb_getaddr;
@@ -147,7 +117,6 @@ TIRPC_0.3.0 {
# s*
setnetconfig;
setnetpath;
- setrpcent;
svc_auth_reg;
svc_create;
svc_dg_create;
@@ -194,8 +163,6 @@ TIRPC_0.3.0 {
# x*
xdr_accepted_reply;
xdr_array;
- xdr_authdes_cred;
- xdr_authdes_verf;
xdr_authunix_parms;
xdr_bool;
xdr_bytes;
@@ -228,10 +195,6 @@ TIRPC_0.3.0 {
xdr_replymsg;
xdr_rmtcall_args;
xdr_rmtcallres;
- xdr_rpc_gss_cred;
- xdr_rpc_gss_data;
- xdr_rpc_gss_init_args;
- xdr_rpc_gss_init_res;
xdr_rpcb;
xdr_rpcb_entry;
xdr_rpcb_entry_list_ptr;
@@ -275,14 +238,20 @@ TIRPC_0.3.0 {
xdrstdio_create;
xprt_register;
xprt_unregister;
+ # GSS-API symbols (conditionally included)
+@GSS_SYMBOLS@
+ # DES crypto symbols (conditionally included)
+@DES_SYMBOLS@
+ # RPC database symbols (conditionally included)
+@RPCDB_SYMBOLS@
local:
*;
};
TIRPC_0.3.1 {
- svcauth_gss_get_principal;
- svcauth_gss_set_svc_name;
+# GSS-API symbols (conditionally included)
+@GSS_SYMBOLS_031@
} TIRPC_0.3.0;
TIRPC_0.3.2 {
@@ -290,7 +259,6 @@ TIRPC_0.3.2 {
getpublicandprivatekey;
getpublickey;
host2netname;
- key_call_destroy;
key_decryptsession;
key_decryptsession_pk;
key_encryptsession;
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-08-12 5:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-12 5:07 [PATCH v2] Add conditional version script support Khem Raj
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).