build: add way to keep unused symbols when linking NetworkManager
NetworkManager (and NetworkManager-all-sym) must not only contain symbols that are used by itself. Also the device and settings plugin are dlopen'd by NetworkManager and use symobls form the binary. That means, if a symbols is only used by a plugin, then we must make sure that the linker keeps it in the binary. Add a mechanism for that.
This commit is contained in:
@@ -2656,6 +2656,12 @@ $(src_core_libNetworkManagerTest_la_OBJECTS): $(src_libnm_core_public_mkenums_h)
|
|||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
# NetworkManager binary also must contain symbols that are not used by the binary
|
||||||
|
# itself, but by the plugins (that are dlopened). We need to explicitly include
|
||||||
|
# them during linking.
|
||||||
|
networkmanager_undefined_symbols = \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
noinst_PROGRAMS += src/core/NetworkManager-all-sym
|
noinst_PROGRAMS += src/core/NetworkManager-all-sym
|
||||||
|
|
||||||
src_core_NetworkManager_all_sym_CPPFLAGS = $(src_core_cppflags)
|
src_core_NetworkManager_all_sym_CPPFLAGS = $(src_core_cppflags)
|
||||||
@@ -2670,6 +2676,7 @@ src_core_NetworkManager_all_sym_LDADD = \
|
|||||||
|
|
||||||
src_core_NetworkManager_all_sym_LDFLAGS = \
|
src_core_NetworkManager_all_sym_LDFLAGS = \
|
||||||
-rdynamic \
|
-rdynamic \
|
||||||
|
$(networkmanager_undefined_symbols:%=-u %) \
|
||||||
$(SANITIZER_EXEC_LDFLAGS) \
|
$(SANITIZER_EXEC_LDFLAGS) \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
@@ -2696,6 +2703,7 @@ src_core_NetworkManager_LDADD = \
|
|||||||
src_core_NetworkManager_LDFLAGS = \
|
src_core_NetworkManager_LDFLAGS = \
|
||||||
-rdynamic \
|
-rdynamic \
|
||||||
-Wl,--version-script="src/core/NetworkManager.ver" \
|
-Wl,--version-script="src/core/NetworkManager.ver" \
|
||||||
|
$(networkmanager_undefined_symbols:%=-u %) \
|
||||||
$(SANITIZER_EXEC_LDFLAGS) \
|
$(SANITIZER_EXEC_LDFLAGS) \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
@@ -270,6 +270,14 @@ endif
|
|||||||
subdir('devices')
|
subdir('devices')
|
||||||
subdir('settings/plugins')
|
subdir('settings/plugins')
|
||||||
|
|
||||||
|
# NetworkManager binary also must contain symbols that are not used by the binary
|
||||||
|
# itself, but by the plugins (that are dlopened). We need to explicitly include
|
||||||
|
# them during linking.
|
||||||
|
networkmanager_undefined_symbols_args = []
|
||||||
|
foreach s: []
|
||||||
|
networkmanager_undefined_symbols_args += ['-u', s]
|
||||||
|
endforeach
|
||||||
|
|
||||||
# NetworkManager binary
|
# NetworkManager binary
|
||||||
|
|
||||||
# libNetworkManager.a, as built by meson doesn't contain all symbols
|
# libNetworkManager.a, as built by meson doesn't contain all symbols
|
||||||
@@ -284,7 +292,9 @@ NetworkManager_all_sym = executable(
|
|||||||
nm_deps,
|
nm_deps,
|
||||||
libudev_dep,
|
libudev_dep,
|
||||||
],
|
],
|
||||||
link_args: '-Wl,--no-gc-sections',
|
link_args: [
|
||||||
|
'-Wl,--no-gc-sections',
|
||||||
|
] + networkmanager_undefined_symbols_args,
|
||||||
link_whole: [
|
link_whole: [
|
||||||
libNetworkManager,
|
libNetworkManager,
|
||||||
libNetworkManagerBase,
|
libNetworkManagerBase,
|
||||||
@@ -345,7 +355,7 @@ NetworkManager = executable(
|
|||||||
link_args: [
|
link_args: [
|
||||||
'-rdynamic',
|
'-rdynamic',
|
||||||
'-Wl,--version-script,@0@'.format(ver_script.full_path()),
|
'-Wl,--version-script,@0@'.format(ver_script.full_path()),
|
||||||
],
|
] + networkmanager_undefined_symbols_args,
|
||||||
link_depends: ver_script,
|
link_depends: ver_script,
|
||||||
install: true,
|
install: true,
|
||||||
install_dir: nm_sbindir,
|
install_dir: nm_sbindir,
|
||||||
|
Reference in New Issue
Block a user