From 4f5993c3f48d6f5454f72aeb10b4642fde758076 Mon Sep 17 00:00:00 2001 From: Felipe Sateler Date: Mon, 28 Aug 2017 13:49:03 -0300 Subject: [PATCH] shared: Add a linker script so that all functions are tagget @SD_SHARED instead of @Base (#6669) This helps prevent symbol collisions with other programs and libraries. In particular, because PAM modules are loaded into the process that is creating the session, and systemd creates PAM sessions, the potential for collisions is high. Disambiguate all systemd calls by tagging a 'version' SD_SHARED. Fixes #6624 --- src/shared/libshared.sym | 3 +++ src/shared/meson.build | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 src/shared/libshared.sym diff --git a/src/shared/libshared.sym b/src/shared/libshared.sym new file mode 100644 index 00000000000..e4ae17eede6 --- /dev/null +++ b/src/shared/libshared.sym @@ -0,0 +1,3 @@ +SD_SHARED { + global: *; +}; diff --git a/src/shared/meson.build b/src/shared/meson.build index 2eaef11a2d4..ce84d007d16 100644 --- a/src/shared/meson.build +++ b/src/shared/meson.build @@ -136,6 +136,8 @@ libshared_deps = [threads, liblz4, libblkid] +libshared_sym_path = '@0@/libshared.sym'.format(meson.current_source_dir()) + libshared = shared_library( libshared_name, shared_sources, @@ -144,7 +146,8 @@ libshared = shared_library( libsystemd_internal_sources, libudev_sources, include_directories : includes, - link_args : ['-shared'], + link_args : ['-shared', + '-Wl,--version-script=' + libshared_sym_path], c_args : ['-fvisibility=default'], dependencies : libshared_deps, install : true, -- 2.47.3