public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v3 2/2] Fix --enable-libctf, --disable-static, and tests sans CTF-capable toolchain
  2019-10-16 19:10 [PATCH v3 1/2] binutils, ld: work with --disable-libctf Nick Alcock
@ 2019-10-16 19:10 ` Nick Alcock
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Alcock @ 2019-10-16 19:10 UTC (permalink / raw)
  To: binutils, gdb-patches; +Cc: Nick Alcock

This fixes test runs with a non-CTF-capable toolchain, and test runs
and compilation when --disable-libctf, --disable-static, or
--enable-shared are passed.

Changes since v2: Use GCC_ENABLE and fix indentation.  Fix prototype
using 'void'.  Use 'unsupported' and gdb_caching_proc.

gdb/ChangeLog
	* configure.ac: Add --enable-libctf: handle --disable-static
	properly.
	* acinclude.m4: sinclude ../config/enable.m4.
	* Makefile.in (aclocal_m4_deps): Adjust accordingly.
	(LIBCTF): Substitute in.
	(CTF_DEPS): New, likewise.
	(CLIBS): libctf needs symbols from libbfd: move earlier.
	(CDEPS): Use CTF_DEPS, not LIBCTF, now LIBCTF can include rpath
	flags.
	* ctfread.c: Surround in ENABLE_LIBCTF.
	_initialize_ctfread [ENABLE_LIBCTF]: Fix declaration to use ().
	_initialize_ctfread [!ENABLE_LIBCTF]: New stub.
	elfctf_build_psymtabs [!ENABLE_LIBCTF]: Likewise.
	* configure: Regenerate.
	* config.in: Likewise.

gdb/testsuite/ChangeLog
	* configure.ac: Add --enable-libctf.
	* Makefile.in (site.exp): Add enable_libctf to site.exp.
	* aclocal.m4: sinclude ../config/enable.m4.
	* lib/gdb.exp (skip_ctf_tests): New.
	* gdb.base/ctf-constvars.exp: Use it.
	* gdb.base/ctf-cvexpr.exp: Likewise.
	* gdb.base/ctf-ptype.exp: Likewise.
	* gdb.base/ctf-whatis.exp: Likewise.
	* configure: Regenerate.
---
 gdb/Makefile.in                          |  8 +++--
 gdb/acinclude.m4                         |  3 ++
 gdb/config.in                            |  3 ++
 gdb/configure                            | 37 ++++++++++++++++++++++++
 gdb/configure.ac                         | 18 ++++++++++++
 gdb/ctfread.c                            | 20 ++++++++++++-
 gdb/testsuite/Makefile.in                |  2 ++
 gdb/testsuite/aclocal.m4                 |  1 +
 gdb/testsuite/configure                  | 18 ++++++++++++
 gdb/testsuite/configure.ac               |  3 ++
 gdb/testsuite/gdb.base/ctf-constvars.exp |  5 ++++
 gdb/testsuite/gdb.base/ctf-cvexpr.exp    |  5 ++++
 gdb/testsuite/gdb.base/ctf-ptype.exp     |  5 ++++
 gdb/testsuite/gdb.base/ctf-whatis.exp    |  5 ++++
 gdb/testsuite/lib/gdb.exp                | 17 +++++++++++
 15 files changed, 146 insertions(+), 4 deletions(-)

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index af4b14d6e6..db9f99d5ea 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -154,7 +154,8 @@ INCLUDE_CFLAGS = -I$(INCLUDE_DIR)
 LIBIBERTY = ../libiberty/libiberty.a
 
 # Where is the CTF library?  Typically in ../libctf.
-LIBCTF = ../libctf/.libs/libctf.a
+LIBCTF = @LIBCTF@
+CTF_DEPS = @CTF_DEPS@
 
 # Where is the BFD library?  Typically in ../bfd.
 BFD_DIR = ../bfd
@@ -591,14 +592,14 @@ INTERNAL_LDFLAGS = \
 # Libraries and corresponding dependencies for compiling gdb.
 # XM_CLIBS, defined in *config files, have host-dependent libs.
 # LIBIBERTY appears twice on purpose.
-CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(LIBCTF) $(ZLIB) \
+CLIBS = $(SIM) $(READLINE) $(OPCODES) $(LIBCTF) $(BFD) $(ZLIB) \
         $(INTL) $(LIBIBERTY) $(LIBDECNUMBER) \
 	$(XM_CLIBS) $(GDBTKLIBS) \
 	@LIBS@ @GUILE_LIBS@ @PYTHON_LIBS@ \
 	$(LIBEXPAT) $(LIBLZMA) $(LIBBABELTRACE) $(LIBIPT) \
 	$(LIBIBERTY) $(WIN32LIBS) $(LIBGNU) $(LIBICONV) $(LIBMPFR) \
 	$(SRCHIGH_LIBS)
-CDEPS = $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE_DEPS) $(LIBCTF) \
+CDEPS = $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE_DEPS) $(CTF_DEPS) \
 	$(OPCODES) $(INTL_DEPS) $(LIBIBERTY) $(CONFIG_DEPS) $(LIBGNU)
 
 DIST = gdb
@@ -2045,6 +2046,7 @@ aclocal_m4_deps = \
 	transform.m4 \
 	../bfd/bfd.m4 \
 	../config/acinclude.m4 \
+	../config/enable.m4 \
 	../config/plugins.m4 \
 	../config/lead-dot.m4 \
 	../config/override.m4 \
diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
index 6e81aaed3b..991a3983f4 100644
--- a/gdb/acinclude.m4
+++ b/gdb/acinclude.m4
@@ -24,6 +24,9 @@ sinclude(../bfd/bfd.m4)
 dnl This gets the standard macros.
 sinclude(../config/acinclude.m4)
 
+dnl This gets GCC_ENABLE.
+sinclude(../config/enable.m4)
+
 dnl This gets AC_PLUGINS, needed by ACX_LARGEFILE.
 sinclude(../config/plugins.m4)
 
diff --git a/gdb/config.in b/gdb/config.in
index 26ca02f6a3..5d6737b874 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -33,6 +33,9 @@
 /* Define to BFD's default target vector. */
 #undef DEFAULT_BFD_VEC
 
+/* 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/gdb/configure b/gdb/configure
index 22a5f6051d..353d5569e7 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -627,6 +627,9 @@ GCORE_TRANSFORM_NAME
 GDB_TRANSFORM_NAME
 XSLTPROC
 GDB_NM_FILE
+CTF_DEPS
+LIBCTF
+ENABLE_LIBCTF
 LTLIBBABELTRACE
 LIBBABELTRACE
 HAVE_LIBBABELTRACE
@@ -897,6 +900,7 @@ enable_sim
 enable_gdbserver
 with_babeltrace
 with_libbabeltrace_prefix
+enable_libctf
 enable_unit_tests
 '
       ac_precious_vars='build_alias
@@ -1564,6 +1568,7 @@ Optional Features:
   --enable-sim            link gdb with simulator
   --enable-gdbserver      automatically build gdbserver (yes/no/auto, default
                           is auto)
+  --enable-libctf         Handle .ctf type-info sections [default=yes]
   --enable-unit-tests     Enable the inclusion of unit tests when compiling
                           GDB
 
@@ -17556,6 +17561,38 @@ $as_echo "$as_me: WARNING: babeltrace is missing or unusable; GDB is unable to r
   fi
 fi
 
+ # 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 x${enable_static} = xno; then
+  LIBCTF="-Wl,--rpath,../libctf/.libs ../libctf/.libs/libctf.so"
+  CTF_DEPS="../libctf/.libs/libctf.so"
+else
+  LIBCTF="../libctf/.libs/libctf.a"
+  CTF_DEPS="$LIBCTF"
+fi
+if test "${enable_libctf}" = yes; then
+
+$as_echo "#define ENABLE_LIBCTF 1" >>confdefs.h
+
+else
+    LIBCTF=
+    CTF_DEPS=
+fi
+
+
+
+
 # If nativefile (NAT_FILE) is not set in configure.nat, we link to an
 # empty version.
 
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 9da8818fb5..c16bb0dd2f 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -2217,6 +2217,24 @@ else
   fi
 fi
 
+GCC_ENABLE([libctf], [yes], [], [Handle .ctf type-info sections])
+if test x${enable_static} = xno; then
+  LIBCTF="-Wl,--rpath,../libctf/.libs ../libctf/.libs/libctf.so"
+  CTF_DEPS="../libctf/.libs/libctf.so"
+else
+  LIBCTF="../libctf/.libs/libctf.a"
+  CTF_DEPS="$LIBCTF"
+fi
+if test "${enable_libctf}" = yes; then
+  AC_DEFINE(ENABLE_LIBCTF, 1, [Handle .ctf type-info sections])
+else
+  LIBCTF=
+  CTF_DEPS=
+fi
+AC_SUBST(ENABLE_LIBCTF)
+AC_SUBST(LIBCTF)
+AC_SUBST(CTF_DEPS)
+
 # If nativefile (NAT_FILE) is not set in configure.nat, we link to an
 # empty version.
 
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index 44ccff62ae..2b73d58c68 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -81,6 +81,9 @@
 #include "block.h"
 #include "ctfread.h"
 #include "psympriv.h"
+
+#if ENABLE_LIBCTF
+
 #include "ctf.h"
 #include "ctf-api.h"
 
@@ -1479,8 +1482,23 @@ elfctf_build_psymtabs (struct objfile *of)
 }
 
 void
-_initialize_ctfread (void)
+_initialize_ctfread ()
 {
   ctf_file_key
     = register_objfile_data_with_cleanup (NULL, ctf_close_objfile);
 }
+
+#else
+
+void
+_initialize_ctfread ()
+{
+}
+
+void
+elfctf_build_psymtabs (struct objfile *of)
+{
+  /* Nothing to do if CTF is disabled.  */
+}
+
+#endif /* ENABLE_LIBCTF */
diff --git a/gdb/testsuite/Makefile.in b/gdb/testsuite/Makefile.in
index 2beba053ee..42de3d6f22 100644
--- a/gdb/testsuite/Makefile.in
+++ b/gdb/testsuite/Makefile.in
@@ -28,6 +28,7 @@ program_transform_name = @program_transform_name@
 build_canonical = @build@
 host_canonical = @host@
 target_canonical = @target@
+enable_libctf = @enable_libctf@
 
 SHELL = @SHELL@
 EXEEXT = @EXEEXT@
@@ -131,6 +132,7 @@ $(abs_builddir)/site.exp site.exp: ./config.status Makefile
 	@echo "set build_triplet ${build_canonical}" >> ./tmp0
 	@echo "set srcdir ${abs_srcdir}" >> ./tmp0
 	@echo "set tool gdb" >> ./tmp0
+	@echo "set enable_libctf ${enable_libctf}" >> ./tmp0
 	@echo 'source $${srcdir}/lib/append_gdb_boards_dir.exp' >> ./tmp0
 	@echo "## All variables above are generated by configure. Do Not Edit ##" >> ./tmp0
 		@cat ./tmp0 > site.exp
diff --git a/gdb/testsuite/aclocal.m4 b/gdb/testsuite/aclocal.m4
index d40c3a9fc6..a7320620aa 100644
--- a/gdb/testsuite/aclocal.m4
+++ b/gdb/testsuite/aclocal.m4
@@ -1,5 +1,6 @@
 sinclude(../../config/acx.m4)
 sinclude(../../config/override.m4)
+sinclude(../../config/enable.m4)
 sinclude(../transform.m4)
 
 # AM_CONDITIONAL                                            -*- Autoconf -*-
diff --git a/gdb/testsuite/configure b/gdb/testsuite/configure
index cc00f8dfa8..0de6074460 100755
--- a/gdb/testsuite/configure
+++ b/gdb/testsuite/configure
@@ -638,6 +638,7 @@ LDFLAGS
 CFLAGS
 CC
 RPATH_ENVVAR
+enable_libctf
 subdirs
 target_noncanonical
 target_os
@@ -694,6 +695,7 @@ ac_subst_files=''
 ac_user_opts='
 enable_option_checking
 enable_gdbtk
+enable_libctf
 enable_shared
 '
       ac_precious_vars='build_alias
@@ -1323,6 +1325,7 @@ Optional Features:
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
   --enable-gtk            enable gdbtk graphical user interface (GUI)
+  --enable-libctf         Handle .ctf type-info sections [default=yes]
   --enable-shared         build shared libraries deault=yes
 
 Some influential environment variables:
@@ -2189,6 +2192,21 @@ subdirs="$subdirs gdb.gdbtk"
 
 fi
 
+ # 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
+
+
+
+
 # Enable shared libraries.
 # Check whether --enable-shared was given.
 if test "${enable_shared+set}" = set; then :
diff --git a/gdb/testsuite/configure.ac b/gdb/testsuite/configure.ac
index 1c4dc99c47..284e498a67 100644
--- a/gdb/testsuite/configure.ac
+++ b/gdb/testsuite/configure.ac
@@ -43,6 +43,9 @@ if test $enable_gdbtk = yes; then
    AC_CONFIG_SUBDIRS(gdb.gdbtk)
 fi
 
+GCC_ENABLE([libctf], [yes], [], [Handle .ctf type-info sections])
+AC_SUBST(enable_libctf)
+
 # Enable shared libraries.
 AC_ARG_ENABLE(shared,
 [  --enable-shared         build shared libraries [deault=yes]],,
diff --git a/gdb/testsuite/gdb.base/ctf-constvars.exp b/gdb/testsuite/gdb.base/ctf-constvars.exp
index 4a81a94ddb..08dd12ceb5 100644
--- a/gdb/testsuite/gdb.base/ctf-constvars.exp
+++ b/gdb/testsuite/gdb.base/ctf-constvars.exp
@@ -32,6 +32,11 @@
 standard_testfile .c
 set opts "additional_flags=-gt"
 
+if {[skip_ctf_tests]} {
+    unsupported "No compiler CTF support, or CTF disabled in GDB"
+    return
+}
+
 if { [prepare_for_testing "failed to prepare" ${testfile} \
 	  [list $srcfile] [list $opts nowarnings]] } {
     return 0
diff --git a/gdb/testsuite/gdb.base/ctf-cvexpr.exp b/gdb/testsuite/gdb.base/ctf-cvexpr.exp
index 67ceb21f52..ab72980ebe 100644
--- a/gdb/testsuite/gdb.base/ctf-cvexpr.exp
+++ b/gdb/testsuite/gdb.base/ctf-cvexpr.exp
@@ -27,6 +27,11 @@
 standard_testfile cvexpr.c
 set opts "additional_flags=-gt"
 
+if {[skip_ctf_tests]} {
+    unsupported "No compiler CTF support, or CTF disabled in GDB"
+    return
+}
+
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
      untested "failed to compile"
      return -1
diff --git a/gdb/testsuite/gdb.base/ctf-ptype.exp b/gdb/testsuite/gdb.base/ctf-ptype.exp
index 9f54582422..c3861032e8 100644
--- a/gdb/testsuite/gdb.base/ctf-ptype.exp
+++ b/gdb/testsuite/gdb.base/ctf-ptype.exp
@@ -23,6 +23,11 @@
 standard_testfile .c
 set opts "additional_flags=-gt"
 
+if {[skip_ctf_tests]} {
+    unsupported "No compiler CTF support, or CTF disabled in GDB"
+    return
+}
+
 if { [prepare_for_testing "failed to prepare" ${testfile} \
 	  [list $srcfile] [list $opts nowarnings]] } {
     return 0
diff --git a/gdb/testsuite/gdb.base/ctf-whatis.exp b/gdb/testsuite/gdb.base/ctf-whatis.exp
index 3f26fc326e..f30e0d9793 100644
--- a/gdb/testsuite/gdb.base/ctf-whatis.exp
+++ b/gdb/testsuite/gdb.base/ctf-whatis.exp
@@ -23,6 +23,11 @@
 standard_testfile .c
 set opts "additional_flags=-gt"
 
+if {[skip_ctf_tests]} {
+    unsupported "No compiler CTF support, or CTF disabled in GDB"
+    return
+}
+
 if { [prepare_for_testing "failed to prepare" ${testfile} \
           [list $srcfile] [list $opts nowarnings]] } {
     return 0
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index fed46ec83c..00d4e077b5 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2017,6 +2017,23 @@ proc skip_tui_tests {} {
     return 0
 }
 
+# Return 1 if we should skip CTF-related tests.
+
+gdb_caching_proc skip_ctf_tests {
+    set me "skip_ctf_tests"
+    set src { int main () {return 0;} }
+    set compile_flags "additional_flags=-gt"
+    global enable_libctf
+
+    if {$enable_libctf eq "no"} {
+	return 1
+    }
+    if {![gdb_simple_compile $me $src executable $compile_flags]} {
+	return 1
+    }
+    return 0
+}
+
 # Test files shall make sure all the test result lines in gdb.sum are
 # unique in a test run, so that comparing the gdb.sum files of two
 # test runs gives correct results.  Test files that exercise
-- 
2.23.0.239.g28aa4420fd

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH v3 1/2] binutils, ld: work with --disable-libctf
@ 2019-10-16 19:10 Nick Alcock
  2019-10-16 19:10 ` [PATCH v3 2/2] Fix --enable-libctf, --disable-static, and tests sans CTF-capable toolchain Nick Alcock
  0 siblings, 1 reply; 2+ messages in thread
From: Nick Alcock @ 2019-10-16 19:10 UTC (permalink / raw)
  To: binutils, gdb-patches; +Cc: Nick Alcock

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.
---
 binutils/Makefile.am     |  5 +++++
 binutils/Makefile.in     |  9 +++++++--
 binutils/aclocal.m4      |  1 +
 binutils/config.in       |  3 +++
 binutils/configure       | 39 +++++++++++++++++++++++++++++++++++--
 binutils/configure.ac    |  6 ++++++
 binutils/doc/Makefile.in |  1 +
 binutils/objdump.c       | 27 +++++++++++++++++++++++---
 binutils/readelf.c       |  8 ++++++++
 ld/Makefile.am           |  4 ++++
 ld/Makefile.in           |  5 ++++-
 ld/aclocal.m4            |  1 +
 ld/config.in             |  3 +++
 ld/configure             | 42 ++++++++++++++++++++++++++++++++++++++--
 ld/configure.ac          |  9 +++++++++
 ld/ldelfgen.c            | 14 ++++++++++++++
 ld/ldlang.c              | 35 +++++++++++++++++++++++++++++++++
 17 files changed, 202 insertions(+), 10 deletions(-)

diff --git a/binutils/Makefile.am b/binutils/Makefile.am
index 4c90a0bef3..40e4e6d35d 100644
--- a/binutils/Makefile.am
+++ b/binutils/Makefile.am
@@ -162,8 +162,13 @@ BFDLIB = ../bfd/libbfd.la
 
 OPCODES = ../opcodes/libopcodes.la
 
+if ENABLE_LIBCTF
 LIBCTF = ../libctf/libctf.la
 LIBCTF_NOBFD = ../libctf/libctf-nobfd.la
+else
+LIBCTF =
+LIBCTF_NOBFD =
+endif
 
 LIBIBERTY = ../libiberty/libiberty.a
 
diff --git a/binutils/Makefile.in b/binutils/Makefile.in
index be96d2db0e..d8da0feda0 100644
--- a/binutils/Makefile.in
+++ b/binutils/Makefile.in
@@ -122,6 +122,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/iconv.m4 \
 	$(top_srcdir)/../config/largefile.m4 \
@@ -220,6 +221,7 @@ objcopy_LDADD = $(LDADD)
 am_objdump_OBJECTS = objdump.$(OBJEXT) dwarf.$(OBJEXT) prdbg.$(OBJEXT) \
 	$(am__objects_3) $(am__objects_1) $(am__objects_2)
 objdump_OBJECTS = $(am_objdump_OBJECTS)
+@ENABLE_LIBCTF_TRUE@am__DEPENDENCIES_2 = ../libctf/libctf.la
 am_ranlib_OBJECTS = ar.$(OBJEXT) is-ranlib.$(OBJEXT) arparse.$(OBJEXT) \
 	arlex.$(OBJEXT) arsup.$(OBJEXT) rename.$(OBJEXT) \
 	binemul.$(OBJEXT) emul_$(EMULATION).$(OBJEXT) $(am__objects_1)
@@ -227,6 +229,7 @@ ranlib_OBJECTS = $(am_ranlib_OBJECTS)
 am_readelf_OBJECTS = readelf.$(OBJEXT) version.$(OBJEXT) \
 	unwind-ia64.$(OBJEXT) dwarf.$(OBJEXT) $(am__objects_2)
 readelf_OBJECTS = $(am_readelf_OBJECTS)
+@ENABLE_LIBCTF_TRUE@am__DEPENDENCIES_3 = ../libctf/libctf-nobfd.la
 am_size_OBJECTS = size.$(OBJEXT) $(am__objects_1)
 size_OBJECTS = $(am_size_OBJECTS)
 size_LDADD = $(LDADD)
@@ -655,8 +658,10 @@ BULIBS = bucomm.c version.c filemode.c
 ELFLIBS = elfcomm.c
 BFDLIB = ../bfd/libbfd.la
 OPCODES = ../opcodes/libopcodes.la
-LIBCTF = ../libctf/libctf.la
-LIBCTF_NOBFD = ../libctf/libctf-nobfd.la
+@ENABLE_LIBCTF_FALSE@LIBCTF = 
+@ENABLE_LIBCTF_TRUE@LIBCTF = ../libctf/libctf.la
+@ENABLE_LIBCTF_FALSE@LIBCTF_NOBFD = 
+@ENABLE_LIBCTF_TRUE@LIBCTF_NOBFD = ../libctf/libctf-nobfd.la
 LIBIBERTY = ../libiberty/libiberty.a
 POTFILES = $(CFILES) $(DEBUG_SRCS) $(HFILES)
 EXPECT = expect
diff --git a/binutils/aclocal.m4 b/binutils/aclocal.m4
index 4fa32fffd8..8bf2e9e242 100644
--- a/binutils/aclocal.m4
+++ b/binutils/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/iconv.m4])
 m4_include([../config/largefile.m4])
diff --git a/binutils/config.in b/binutils/config.in
index 72ead4eb61..a3bb053bc6 100644
--- a/binutils/config.in
+++ b/binutils/config.in
@@ -21,6 +21,9 @@
 /* Should strings use -a behavior by default? */
 #undef DEFAULT_STRINGS_ALL
 
+/* 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/binutils/configure b/binutils/configure
index 50f8d5b1a2..dba33d312f 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -684,6 +684,8 @@ WARN_WRITE_STRINGS
 NO_WERROR
 WARN_CFLAGS_FOR_BUILD
 WARN_CFLAGS
+ENABLE_LIBCTF_FALSE
+ENABLE_LIBCTF_TRUE
 OTOOL64
 OTOOL
 LIPO
@@ -813,6 +815,7 @@ enable_largefile
 enable_targets
 enable_deterministic_archives
 enable_default_strings_all
+enable_libctf
 enable_werror
 enable_build_warnings
 enable_nls
@@ -1469,6 +1472,7 @@ Optional Features:
                           ar and ranlib default to -D behavior
   --disable-default-strings-all
                           strings defaults to --data behavior
+  --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
@@ -11523,7 +11527,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11526 "configure"
+#line 11530 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11629,7 +11633,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11632 "configure"
+#line 11636 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12241,6 +12245,33 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+ # 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
@@ -15308,6 +15339,10 @@ else
   am__EXEEXT_FALSE=
 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/binutils/configure.ac b/binutils/configure.ac
index b1cd4552f2..a043bc3be4 100644
--- a/binutils/configure.ac
+++ b/binutils/configure.ac
@@ -66,6 +66,12 @@ fi], [default_strings_all=1])
 AC_DEFINE_UNQUOTED(DEFAULT_STRINGS_ALL, $default_strings_all,
 		   [Should strings use -a behavior by default?])
 
+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
 
 AC_CONFIG_HEADERS(config.h:config.in)
diff --git a/binutils/doc/Makefile.in b/binutils/doc/Makefile.in
index 3023c7bdd3..361dff8ab1 100644
--- a/binutils/doc/Makefile.in
+++ b/binutils/doc/Makefile.in
@@ -111,6 +111,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/iconv.m4 \
 	$(top_srcdir)/../config/largefile.m4 \
diff --git a/binutils/objdump.c b/binutils/objdump.c
index a2a0645685..d3da551e60 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -229,7 +229,13 @@ usage (FILE *stream, int status)
           =gdb_index,=trace_info,=trace_abbrev,=trace_aranges,\n\
           =addr,=cu_index,=links,=follow-links]\n\
                            Display DWARF info in the file\n\
+"));
+#ifdef ENABLE_LIBCTF
+  fprintf (stream, _("\
   --ctf=SECTION            Display CTF info from SECTION\n\
+"));
+#endif
+  fprintf (stream, _("\
   -t, --syms               Display the contents of the symbol table(s)\n\
   -T, --dynamic-syms       Display the contents of the dynamic symbol table\n\
   -r, --reloc              Display the relocation entries in the file\n\
@@ -278,8 +284,11 @@ usage (FILE *stream, int status)
       --dwarf-start=N        Display DIEs starting with N, at the same depth\n\
                              or deeper\n\
       --dwarf-check          Make additional dwarf internal consistency checks.\
-      \n\
+      \n"));
+#ifdef ENABLE_LIBCTF
+      fprintf (stream, _("\
       --ctf-parent=SECTION     Use SECTION as the CTF parent\n\n"));
+#endif
       list_supported_targets (program_name, stream);
       list_supported_architectures (program_name, stream);
 
@@ -315,9 +324,11 @@ enum option_values
     OPTION_RECURSE_LIMIT,
     OPTION_NO_RECURSE_LIMIT,
     OPTION_INLINES,
-    OPTION_SOURCE_COMMENT,
-    OPTION_CTF,
+    OPTION_SOURCE_COMMENT
+#ifdef ENABLE_LIBCTF
+    ,OPTION_CTF,
     OPTION_CTF_PARENT
+#endif
   };
 
 static struct option long_options[]=
@@ -361,8 +372,10 @@ static struct option long_options[]=
   {"special-syms", no_argument, &dump_special_syms, 1},
   {"include", required_argument, NULL, 'I'},
   {"dwarf", optional_argument, NULL, OPTION_DWARF},
+#ifdef ENABLE_LIBCTF
   {"ctf", required_argument, NULL, OPTION_CTF},
   {"ctf-parent", required_argument, NULL, OPTION_CTF_PARENT},
+#endif
   {"stabs", no_argument, NULL, 'G'},
   {"start-address", required_argument, NULL, OPTION_START_ADDRESS},
   {"stop-address", required_argument, NULL, OPTION_STOP_ADDRESS},
@@ -3245,6 +3258,7 @@ dump_bfd_header (bfd *abfd)
 }
 \f
 
+#ifdef ENABLE_LIBCTF
 /* Formatting callback function passed to ctf_dump.  Returns either the pointer
    it is passed, or a pointer to newly-allocated storage, in which case
    dump_ctf() will free it when it no longer needs it.  */
@@ -3386,6 +3400,11 @@ dump_ctf (bfd *abfd, const char *sect_name, const char *parent_name)
   free (parentdata);
   free (ctfdata);
 }
+#else
+static void
+dump_ctf (bfd *abfd ATTRIBUTE_UNUSED, const char *sect_name ATTRIBUTE_UNUSED,
+	  const char *parent_name ATTRIBUTE_UNUSED) {}
+#endif
 
 \f
 static void
@@ -4548,6 +4567,7 @@ main (int argc, char **argv)
 	case OPTION_DWARF_CHECK:
 	  dwarf_check = TRUE;
 	  break;
+#ifdef ENABLE_LIBCTF
 	case OPTION_CTF:
 	  dump_ctf_section_info = TRUE;
 	  dump_ctf_section_name = xstrdup (optarg);
@@ -4556,6 +4576,7 @@ main (int argc, char **argv)
 	case OPTION_CTF_PARENT:
 	  dump_ctf_parent_name = xstrdup (optarg);
 	  break;
+#endif
 	case 'G':
 	  dump_stab_section_info = TRUE;
 	  seenflag = TRUE;
diff --git a/binutils/readelf.c b/binutils/readelf.c
index de77237e0e..9bc2ff913e 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -4465,11 +4465,13 @@ static struct option options[] =
   {"dwarf-start",      required_argument, 0, OPTION_DWARF_START},
   {"dwarf-check",      no_argument, 0, OPTION_DWARF_CHECK},
 
+#ifdef ENABLE_LIBCTF
   {"ctf",	       required_argument, 0, OPTION_CTF_DUMP},
 
   {"ctf-symbols",      required_argument, 0, OPTION_CTF_SYMBOLS},
   {"ctf-strings",      required_argument, 0, OPTION_CTF_STRINGS},
   {"ctf-parent",       required_argument, 0, OPTION_CTF_PARENT},
+#endif
 
   {"version",	       no_argument, 0, 'v'},
   {"wide",	       no_argument, 0, 'W'},
@@ -4520,6 +4522,7 @@ usage (FILE * stream)
   --dwarf-depth=N        Do not display DIEs at depth N or greater\n\
   --dwarf-start=N        Display DIEs starting with N, at the same depth\n\
                          or deeper\n"));
+#ifdef ENABLE_LIBCTF
   fprintf (stream, _("\
   --ctf=<number|name>    Display CTF info from section <number|name>\n\
   --ctf-parent=<number|name>\n\
@@ -4528,6 +4531,7 @@ usage (FILE * stream)
                          Use section <number|name> as the CTF external symtab\n\n\
   --ctf-strings=<number|name>\n\
                          Use section <number|name> as the CTF external strtab\n\n"));
+#endif
 
 #ifdef SUPPORT_DISASSEMBLY
   fprintf (stream, _("\
@@ -13891,6 +13895,7 @@ dump_section_as_bytes (Elf_Internal_Shdr *  section,
   return TRUE;
 }
 
+#ifdef ENABLE_LIBCTF
 static ctf_sect_t *
 shdr_to_ctf_sect (ctf_sect_t *buf, Elf_Internal_Shdr *shdr, Filedata *filedata)
 {
@@ -14051,6 +14056,7 @@ dump_section_as_ctf (Elf_Internal_Shdr * section, Filedata * filedata)
   free (strdata);
   return ret;
 }
+#endif
 
 static bfd_boolean
 load_specific_debug_section (enum dwarf_section_display_enum  debug,
@@ -14390,11 +14396,13 @@ process_section_contents (Filedata * filedata)
 	    res = FALSE;
 	}
 
+#ifdef ENABLE_LIBCTF
       if (dump & CTF_DUMP)
 	{
 	  if (! dump_section_as_ctf (section, filedata))
 	    res = FALSE;
 	}
+#endif
     }
 
   /* Check to see if the user requested a
diff --git a/ld/Makefile.am b/ld/Makefile.am
index 2790838994..74cff8c1a6 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -157,7 +157,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 395bef155c..d0df0ec47d 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 \
@@ -189,6 +190,7 @@ am_ld_new_OBJECTS = ldgram.$(OBJEXT) ldlex-wrapper.$(OBJEXT) \
 	$(am__objects_1) 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
@@ -647,7 +649,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 7df8bf68f1..f6e87a228a 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 d93c9b0830..c302b2e250 100644
--- a/ld/config.in
+++ b/ld/config.in
@@ -27,6 +27,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 2e5e10dbf3..a262d0a0f0 100755
--- a/ld/configure
+++ b/ld/configure
@@ -680,6 +680,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
@@ -833,6 +835,7 @@ enable_new_dtags
 enable_relro
 enable_separate_code
 enable_default_hash_style
+enable_libctf
 enable_werror
 enable_build_warnings
 enable_nls
@@ -1501,6 +1504,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
@@ -12032,7 +12036,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12035 "configure"
+#line 12039 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12138,7 +12142,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12141 "configure"
+#line 12145 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -15915,6 +15919,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
@@ -17673,6 +17704,9 @@ else
   TESTBFDLIB="../bfd/.libs/libbfd.a"
   TESTCTFLIB="../libctf/.libs/libctf.a"
 fi
+if test "${enable_libctf}" = no; then
+    TESTCTFLIB=
+fi
 
 
 
@@ -17845,6 +17879,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 bdc167769e..0ef93dd9d8 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -212,6 +212,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
@@ -496,6 +502,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 682872f9dc..d5de1eb10c 100644
--- a/ld/ldelfgen.c
+++ b/ld/ldelfgen.c
@@ -75,6 +75,7 @@ ldelf_map_segments (bfd_boolean need_layout)
     einfo (_("%F%P: looping in map_segments"));
 }
 
+#ifdef ENABLE_LIBCTF
 /* We want to emit CTF early if and only if we are not targetting ELF with this
    invocation.  */
 
@@ -184,3 +185,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 df7f659486..ebf90f6f20 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -129,7 +129,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.  */
@@ -3605,6 +3607,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.  */
@@ -3784,6 +3787,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
-- 
2.23.0.239.g28aa4420fd

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-10-16 19:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-16 19:10 [PATCH v3 1/2] binutils, ld: work with --disable-libctf Nick Alcock
2019-10-16 19:10 ` [PATCH v3 2/2] Fix --enable-libctf, --disable-static, and tests sans CTF-capable toolchain Nick Alcock

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).