From 5abacce031acfb8269552b21022a9e466d6b50cf Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Mon, 19 Oct 2020 12:26:36 -0400 Subject: [PATCH] port: add 'notext' keyword linker support Check if the linker support the 'notext' keyword to allow relocations against read-only segments. GNU ld defaults to notext but LLVM's ld does not, both linkers support the keyword. This is required for the plugins section symbols. Signed-off-by: Michael Jeanson Change-Id: I952586447a837ce48711a218a2d03050ef3deb1a --- configure.ac | 5 +++++ src/plugins/ctf/Makefile.am | 2 +- src/plugins/lttng-utils/Makefile.am | 2 +- src/plugins/text/Makefile.am | 2 +- src/plugins/utils/Makefile.am | 2 +- tests/lib/test-plugin-plugins/Makefile.am | 4 ++-- 6 files changed, 11 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index ee22576f..f5b0d392 100644 --- a/configure.ac +++ b/configure.ac @@ -195,6 +195,11 @@ AX_CHECK_LINK_FLAG([-Wl,--whole-archive,--no-whole-archive], # Initialize and configure libtool LT_INIT([win32-dll]) +# Check if the linker supports the "notext" keyword +AX_CHECK_LINK_FLAG([-Wl,-z,notext],[ + AC_SUBST([LD_NOTEXT], [-Wl,-z,notext]) +]) + ## ## ## Programs checks ## diff --git a/src/plugins/ctf/Makefile.am b/src/plugins/ctf/Makefile.am index 783a06dd..ec711cb8 100644 --- a/src/plugins/ctf/Makefile.am +++ b/src/plugins/ctf/Makefile.am @@ -11,7 +11,7 @@ babeltrace_plugin_ctf_la_SOURCES = plugin.c babeltrace_plugin_ctf_la_LDFLAGS = \ $(LT_NO_UNDEFINED) \ - -avoid-version -module + -avoid-version -module $(LD_NOTEXT) babeltrace_plugin_ctf_la_LIBADD = \ common/libbabeltrace2-plugin-ctf-common.la \ diff --git a/src/plugins/lttng-utils/Makefile.am b/src/plugins/lttng-utils/Makefile.am index 52939803..68e90647 100644 --- a/src/plugins/lttng-utils/Makefile.am +++ b/src/plugins/lttng-utils/Makefile.am @@ -16,7 +16,7 @@ babeltrace_plugin_lttng_utils_la_SOURCES = \ babeltrace_plugin_lttng_utils_la_LDFLAGS = \ $(LT_NO_UNDEFINED) \ - -avoid-version -module \ + -avoid-version -module $(LD_NOTEXT) \ $(ELFUTILS_LIBS) if !ENABLE_BUILT_IN_PLUGINS diff --git a/src/plugins/text/Makefile.am b/src/plugins/text/Makefile.am index 7ba00371..f04f20ab 100644 --- a/src/plugins/text/Makefile.am +++ b/src/plugins/text/Makefile.am @@ -6,7 +6,7 @@ plugin_LTLIBRARIES = babeltrace-plugin-text.la babeltrace_plugin_text_la_SOURCES = plugin.c babeltrace_plugin_text_la_LDFLAGS = \ $(LT_NO_UNDEFINED) \ - -avoid-version -module + -avoid-version -module $(LD_NOTEXT) babeltrace_plugin_text_la_LIBADD = \ pretty/libbabeltrace2-plugin-text-pretty-cc.la \ diff --git a/src/plugins/utils/Makefile.am b/src/plugins/utils/Makefile.am index 3b525afe..aedf2dcb 100644 --- a/src/plugins/utils/Makefile.am +++ b/src/plugins/utils/Makefile.am @@ -6,7 +6,7 @@ plugin_LTLIBRARIES = babeltrace-plugin-utils.la babeltrace_plugin_utils_la_SOURCES = plugin.c babeltrace_plugin_utils_la_LDFLAGS = \ $(LT_NO_UNDEFINED) \ - -avoid-version -module + -avoid-version -module $(LD_NOTEXT) babeltrace_plugin_utils_la_LIBADD = \ dummy/libbabeltrace2-plugin-dummy-cc.la \ muxer/libbabeltrace2-plugin-muxer.la \ diff --git a/tests/lib/test-plugin-plugins/Makefile.am b/tests/lib/test-plugin-plugins/Makefile.am index d6c940b2..613a9107 100644 --- a/tests/lib/test-plugin-plugins/Makefile.am +++ b/tests/lib/test-plugin-plugins/Makefile.am @@ -4,7 +4,7 @@ noinst_LTLIBRARIES = plugin-minimal.la plugin-sfs.la plugin_minimal_la_SOURCES = minimal.c plugin_minimal_la_LDFLAGS = \ $(LT_NO_UNDEFINED) \ - -rpath / -avoid-version -module + -rpath / -avoid-version -module $(LD_NOTEXT) plugin_minimal_la_LIBADD = \ $(top_builddir)/src/lib/libbabeltrace2.la \ $(top_builddir)/src/common/libbabeltrace2-common.la \ @@ -14,7 +14,7 @@ plugin_minimal_la_LIBADD = \ plugin_sfs_la_SOURCES = sfs.c plugin_sfs_la_LDFLAGS = \ $(LT_NO_UNDEFINED) \ - -rpath / -avoid-version -module + -rpath / -avoid-version -module $(LD_NOTEXT) plugin_sfs_la_LIBADD = \ $(top_builddir)/src/lib/libbabeltrace2.la \ $(top_builddir)/src/common/libbabeltrace2-common.la \ -- 2.34.1