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
This commit is contained in:
Felipe Sateler 2017-08-28 13:49:03 -03:00 committed by Lennart Poettering
parent 6c24adfd46
commit 4f5993c3f4
2 changed files with 7 additions and 1 deletions

3
src/shared/libshared.sym Normal file
View file

@ -0,0 +1,3 @@
SD_SHARED {
global: *;
};

View file

@ -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,