aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2019-09-30 15:04:05 +0100
committerNick Alcock <nick.alcock@oracle.com>2020-06-26 15:56:39 +0100
commit094e34f22146ad53eb93da22e480cab428bd23b5 (patch)
tree67dcb4257f8436adcde9d021bd8f99c774de47d8 /ld
parent1776e3e59ca6200dff981894361b8b49cb453766 (diff)
downloadgdb-094e34f22146ad53eb93da22e480cab428bd23b5.zip
gdb-094e34f22146ad53eb93da22e480cab428bd23b5.tar.gz
gdb-094e34f22146ad53eb93da22e480cab428bd23b5.tar.bz2
binutils, ld: work with --disable-libctf
This unfortunately means conditionalizing out all the libctf code, but the result is not too unbearably ugly, if a bit repetitive. I have stubbed out code in the !ENABLE_LIBCTF path to avoid extra redundant ifdefs where it seems that might be helpful. (The stubs are not too disruptive, but I've tried to keep them on one line where possible to avoid filling up the screen with stubs that nobody would care about. If this is too much of a coding style violation I can change it.) Changes since v2: use GCC_ENABLE rather than repeating all the AC_ARG_ENABLE stuff over and over again. ld/ * configure.ac [--enable-libctf]: New, default yes. Set ENABLE_LIBCTF accordingly. * Makefile.am [!ENABLE_LIBCTF]: Empty LIBCTF. * configure: Regenerate. * config.in: Regenerate. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * ldlang.c (ctf_output): Conditionalize on ENABLE_LIBCTF. (ldlang_open_ctf): Likewise. (lang_merge_ctf): Likewise. (ldlang_ctf_apply_strsym): Likewise. (lang_write_ctf): Likewise. (ldlang_write_ctf_late): Likewise. (ldlang_open_ctf) [!ENABLE_LIBCTF]: Warn about the presence of CTF sections. (lang_merge_ctf) [!ENABLE_LIBCTF]: New stub. (ldlang_ctf_apply_strsym) [!ENABLE_LIBCTF]: Likewise. (lang_write_ctf) [!ENABLE_LIBCTF]: Likewise. (ldlang_write_ctf_late) [!ENABLE_LIBCTF]: Likewise. * ldelfgen.c (ldelf_emit_ctf_early): Conditionalize on ENABLE_LIBCTF. (struct ctf_strsym_iter_cb_arg): Likewise. (ldelf_ctf_strtab_iter_cb): Likewise. (ldelf_ctf_symbols_iter_cb): Likewise. (ldelf_examine_strtab_for_ctf): Likewise. (ldelf_emit_ctf_early) [!ENABLE_LIBCTF]: New stub. (ldelf_examine_strtab_for_ctf) [!ENABLE_LIBCTF]: New stub. binutils/ * configure.ac [--enable-libctf]: New, default yes. Set ENABLE_LIBCTF accordingly. * Makefile.am [!ENABLE_LIBCTF]: Empty LIBCTF and LIBCTF_NOBFD. * configure: Regenerate. * config.in: Regenerate. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * objdump.c (usage): Conditionalize portions on ENABLE_LIBCTF. (option_values): Likewise. (long_options): Likewise. (main): Likewise. (dump_ctf_indent_lines): Conditionalize out when !ENABLE_LIBCTF. (make_ctfsect): Likewise. (dump_ctf_archive_member): Likewise. (dump_ctf) [ENABLE_LIBCTF]: Likewise. (dump_ctf) [!ENABLE_LIBCTF]: New empty stub. * readelf.c (options): Conditionalize portions on ENABLE_LIBCTF. (usage): Likewise. (process_section_contents): Likewise. (shdr_to_ctf_sect): Conditionalize out when !ENABLE_LIBCTF. (dump_ctf_indent_lines): Likewise. (dump_section_as_ctf) [ENABLE_LIBCTF]: Likewise.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog30
-rw-r--r--ld/Makefile.am4
-rw-r--r--ld/Makefile.in5
-rw-r--r--ld/aclocal.m41
-rw-r--r--ld/config.in3
-rwxr-xr-xld/configure42
-rw-r--r--ld/configure.ac9
-rw-r--r--ld/ldelfgen.c14
-rw-r--r--ld/ldlang.c35
9 files changed, 140 insertions, 3 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 1a06dc9..4cf1204 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,33 @@
+2020-06-26 Nick Alcock <nick.alcock@oracle.com>
+
+ * configure.ac [--enable-libctf]: New, default yes.
+ Set ENABLE_LIBCTF accordingly.
+ * Makefile.am [!ENABLE_LIBCTF]: Empty LIBCTF.
+ * configure: Regenerate.
+ * config.in: Regenerate.
+ * Makefile.in: Regenerate.
+ * aclocal.m4: Regenerate.
+ * ldlang.c (ctf_output): Conditionalize on ENABLE_LIBCTF.
+ (ldlang_open_ctf): Likewise.
+ (lang_merge_ctf): Likewise.
+ (ldlang_ctf_apply_strsym): Likewise.
+ (lang_write_ctf): Likewise.
+ (ldlang_write_ctf_late): Likewise.
+ (ldlang_open_ctf) [!ENABLE_LIBCTF]: Warn about the presence of CTF
+ sections.
+ (lang_merge_ctf) [!ENABLE_LIBCTF]: New stub.
+ (ldlang_ctf_apply_strsym) [!ENABLE_LIBCTF]: Likewise.
+ (lang_write_ctf) [!ENABLE_LIBCTF]: Likewise.
+ (ldlang_write_ctf_late) [!ENABLE_LIBCTF]: Likewise.
+ * ldelfgen.c (ldelf_emit_ctf_early): Conditionalize on
+ ENABLE_LIBCTF.
+ (struct ctf_strsym_iter_cb_arg): Likewise.
+ (ldelf_ctf_strtab_iter_cb): Likewise.
+ (ldelf_ctf_symbols_iter_cb): Likewise.
+ (ldelf_examine_strtab_for_ctf): Likewise.
+ (ldelf_emit_ctf_early) [!ENABLE_LIBCTF]: New stub.
+ (ldelf_examine_strtab_for_ctf) [!ENABLE_LIBCTF]: New stub.
+
2020-06-26 Jan Beulich <jbeulich@suse.com>
* testsuite/ld-x86-64/x86-64.exp: Run K1OM tests.
diff --git a/ld/Makefile.am b/ld/Makefile.am
index f0767f2..5035c5d 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -144,7 +144,11 @@ AM_CPPFLAGS = -I. -I$(srcdir) -I../bfd -I$(BFDDIR) -I$(INCDIR) @zlibinc@ \
BFDLIB = ../bfd/libbfd.la
LIBIBERTY = ../libiberty/libiberty.a
+if ENABLE_LIBCTF
LIBCTF = ../libctf/libctf.la
+else
+LIBCTF =
+endif
# These all start with e so 'make clean' can find them.
ALL_EMULATION_SOURCES = \
diff --git a/ld/Makefile.in b/ld/Makefile.in
index be0291c..49e1f85 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -113,6 +113,7 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \
$(top_srcdir)/../bfd/warning.m4 $(top_srcdir)/../config/acx.m4 \
$(top_srcdir)/../config/depstand.m4 \
+ $(top_srcdir)/../config/enable.m4 \
$(top_srcdir)/../config/gettext-sister.m4 \
$(top_srcdir)/../config/largefile.m4 \
$(top_srcdir)/../config/lcmessage.m4 \
@@ -180,6 +181,7 @@ am_ld_new_OBJECTS = ldgram.$(OBJEXT) ldlex-wrapper.$(OBJEXT) \
plugin.$(OBJEXT) ldbuildid.$(OBJEXT)
ld_new_OBJECTS = $(am_ld_new_OBJECTS)
am__DEPENDENCIES_1 =
+@ENABLE_LIBCTF_TRUE@am__DEPENDENCIES_2 = ../libctf/libctf.la
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
@@ -628,7 +630,8 @@ AM_CPPFLAGS = -I. -I$(srcdir) -I../bfd -I$(BFDDIR) -I$(INCDIR) @zlibinc@ \
BFDLIB = ../bfd/libbfd.la
LIBIBERTY = ../libiberty/libiberty.a
-LIBCTF = ../libctf/libctf.la
+@ENABLE_LIBCTF_FALSE@LIBCTF =
+@ENABLE_LIBCTF_TRUE@LIBCTF = ../libctf/libctf.la
# These all start with e so 'make clean' can find them.
ALL_EMULATION_SOURCES = \
diff --git a/ld/aclocal.m4 b/ld/aclocal.m4
index 7df8bf6..f6e87a2 100644
--- a/ld/aclocal.m4
+++ b/ld/aclocal.m4
@@ -1189,6 +1189,7 @@ m4_include([../bfd/acinclude.m4])
m4_include([../bfd/warning.m4])
m4_include([../config/acx.m4])
m4_include([../config/depstand.m4])
+m4_include([../config/enable.m4])
m4_include([../config/gettext-sister.m4])
m4_include([../config/largefile.m4])
m4_include([../config/lcmessage.m4])
diff --git a/ld/config.in b/ld/config.in
index 8cadcba..f171210 100644
--- a/ld/config.in
+++ b/ld/config.in
@@ -33,6 +33,9 @@
*/
#undef DEFAULT_NEW_DTAGS
+/* Handle .ctf type-info sections */
+#undef ENABLE_LIBCTF
+
/* Define to 1 if translation of program messages to the user's native
language is requested. */
#undef ENABLE_NLS
diff --git a/ld/configure b/ld/configure
index fba65c5..11c69be 100755
--- a/ld/configure
+++ b/ld/configure
@@ -678,6 +678,8 @@ WARN_WRITE_STRINGS
NO_WERROR
WARN_CFLAGS_FOR_BUILD
WARN_CFLAGS
+ENABLE_LIBCTF_FALSE
+ENABLE_LIBCTF_TRUE
installed_linker
install_as_default
TARGET_SYSTEM_ROOT_DEFINE
@@ -832,6 +834,7 @@ enable_relro
enable_textrel_check
enable_separate_code
enable_default_hash_style
+enable_libctf
enable_werror
enable_build_warnings
enable_nls
@@ -1502,6 +1505,7 @@ Optional Features:
--enable-separate-code enable -z separate-code in ELF linker by default
--enable-default-hash-style={sysv,gnu,both}
use this default hash style
+ --enable-libctf Handle .ctf type-info sections [default=yes]
--enable-werror treat compile warnings as errors
--enable-build-warnings enable build-time compiler warnings
--disable-nls do not use Native Language Support
@@ -12033,7 +12037,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12036 "configure"
+#line 12040 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12139,7 +12143,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12142 "configure"
+#line 12146 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -15926,6 +15930,33 @@ case "${enable_default_hash_style}" in
*) ac_default_emit_gnu_hash=0 ;;
esac
+ # Check whether --enable-libctf was given.
+if test "${enable_libctf+set}" = set; then :
+ enableval=$enable_libctf;
+ case "$enableval" in
+ yes|no) ;;
+ *) as_fn_error $? "Argument to enable/disable libctf must be yes or no" "$LINENO" 5 ;;
+ esac
+
+else
+ enable_libctf=yes
+fi
+
+
+if test "${enable_libctf}" = yes; then
+
+$as_echo "#define ENABLE_LIBCTF 1" >>confdefs.h
+
+fi
+ if test "${enable_libctf}" = yes; then
+ ENABLE_LIBCTF_TRUE=
+ ENABLE_LIBCTF_FALSE='#'
+else
+ ENABLE_LIBCTF_TRUE='#'
+ ENABLE_LIBCTF_FALSE=
+fi
+
+
# Set the 'development' global.
. $srcdir/../bfd/development.sh
@@ -17700,6 +17731,9 @@ else
TESTBFDLIB="../bfd/.libs/libbfd.a"
TESTCTFLIB="../libctf/.libs/libctf.a"
fi
+if test "${enable_libctf}" = no; then
+ TESTCTFLIB=
+fi
@@ -17872,6 +17906,10 @@ if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
as_fn_error $? "conditional \"am__fastdepCXX\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+if test -z "${ENABLE_LIBCTF_TRUE}" && test -z "${ENABLE_LIBCTF_FALSE}"; then
+ as_fn_error $? "conditional \"ENABLE_LIBCTF\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
diff --git a/ld/configure.ac b/ld/configure.ac
index 2b6c048..5a4938a 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -221,6 +221,12 @@ case "${enable_default_hash_style}" in
*) ac_default_emit_gnu_hash=0 ;;
esac
+GCC_ENABLE([libctf], [yes], [], [Handle .ctf type-info sections])
+if test "${enable_libctf}" = yes; then
+ AC_DEFINE(ENABLE_LIBCTF, 1, [Handle .ctf type-info sections])
+fi
+AM_CONDITIONAL(ENABLE_LIBCTF, test "${enable_libctf}" = yes)
+
AM_BINUTILS_WARNINGS
AM_LC_MESSAGES
@@ -524,6 +530,9 @@ else
TESTBFDLIB="../bfd/.libs/libbfd.a"
TESTCTFLIB="../libctf/.libs/libctf.a"
fi
+if test "${enable_libctf}" = no; then
+ TESTCTFLIB=
+fi
AC_SUBST(TESTBFDLIB)
AC_SUBST(TESTCTFLIB)
diff --git a/ld/ldelfgen.c b/ld/ldelfgen.c
index c0568f1..3a56194 100644
--- a/ld/ldelfgen.c
+++ b/ld/ldelfgen.c
@@ -88,6 +88,7 @@ ldelf_map_segments (bfd_boolean need_layout)
}
}
+#ifdef ENABLE_LIBCTF
/* We want to emit CTF early if and only if we are not targetting ELF with this
invocation. */
@@ -197,3 +198,16 @@ ldelf_examine_strtab_for_ctf
"cost: %s\n"), ctf_errmsg (ctf_errno (ctf_output)));
}
}
+#else
+extern int ldelf_emit_ctf_early (void)
+{
+ return 0;
+}
+
+extern void ldelf_examine_strtab_for_ctf
+ (struct ctf_file *ctf_output ATTRIBUTE_UNUSED,
+ struct elf_sym_strtab *syms ATTRIBUTE_UNUSED,
+ bfd_size_type symcount ATTRIBUTE_UNUSED,
+ struct elf_strtab_hash *symstrtab ATTRIBUTE_UNUSED)
+{}
+#endif
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 38ed83a..23e787a 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -131,7 +131,9 @@ bfd_boolean delete_output_file_on_failure = FALSE;
struct lang_phdr *lang_phdr_list;
struct lang_nocrossrefs *nocrossref_list;
struct asneeded_minfo **asneeded_list_tail;
+#ifdef ENABLE_LIBCTF
static ctf_file_t *ctf_output;
+#endif
/* Functions that traverse the linker script and might evaluate
DEFINED() need to increment this at the start of the traversal. */
@@ -3669,6 +3671,7 @@ open_input_bfds (lang_statement_union_type *s, enum open_bfd_mode mode)
einfo ("%F");
}
+#ifdef ENABLE_LIBCTF
/* Open the CTF sections in the input files with libctf: if any were opened,
create a fake input file that we'll write the merged CTF data to later
on. */
@@ -3848,6 +3851,38 @@ ldlang_write_ctf_late (void)
lang_write_ctf (1);
}
+#else
+static void
+ldlang_open_ctf (void)
+{
+ LANG_FOR_EACH_INPUT_STATEMENT (file)
+ {
+ asection *sect;
+
+ /* If built without CTF, warn and delete all CTF sections from the output.
+ (The alternative would be to simply concatenate them, which does not
+ yield a valid CTF section.) */
+
+ if ((sect = bfd_get_section_by_name (file->the_bfd, ".ctf")) != NULL)
+ {
+ einfo (_("%P: warning: CTF section in `%pI' not linkable: "
+ "%P was built without support for CTF\n"), file);
+ sect->size = 0;
+ sect->flags |= SEC_EXCLUDE;
+ }
+ }
+}
+
+static void lang_merge_ctf (void) {}
+void
+ldlang_ctf_apply_strsym (struct elf_sym_strtab *syms ATTRIBUTE_UNUSED,
+ bfd_size_type symcount ATTRIBUTE_UNUSED,
+ struct elf_strtab_hash *symstrtab ATTRIBUTE_UNUSED)
+{
+}
+static void lang_write_ctf (int late ATTRIBUTE_UNUSED) {}
+void ldlang_write_ctf_late (void) {}
+#endif
/* Add the supplied name to the symbol table as an undefined reference.
This is a two step process as the symbol table doesn't even exist at