From 5e8a0751ae0c418a615025d1da10bc84f91b3d97 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 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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. Change-Id: I2b5f5c77865267e35c529dd17a0298cd4405303d Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- 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 7f92c465..85677c83 100644 --- a/configure.ac +++ b/configure.ac @@ -175,6 +175,11 @@ AX_CHECK_LINK_FLAG([-Wl,--whole-archive,--no-whole-archive], ] ) +# 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 398b5267..104229d2 100644 --- a/src/plugins/ctf/Makefile.am +++ b/src/plugins/ctf/Makefile.am @@ -13,7 +13,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 19cecac3..d01e36fa 100644 --- a/src/plugins/lttng-utils/Makefile.am +++ b/src/plugins/lttng-utils/Makefile.am @@ -18,7 +18,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 575baac3..9d8ed88d 100644 --- a/src/plugins/text/Makefile.am +++ b/src/plugins/text/Makefile.am @@ -8,7 +8,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 4631d950..5cacc961 100644 --- a/src/plugins/utils/Makefile.am +++ b/src/plugins/utils/Makefile.am @@ -8,7 +8,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 c1826939..62e48f7e 100644 --- a/tests/lib/test-plugin-plugins/Makefile.am +++ b/tests/lib/test-plugin-plugins/Makefile.am @@ -6,7 +6,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 \ @@ -16,7 +16,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