From patchwork Wed Oct 9 18:26:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Alcock X-Patchwork-Id: 34888 Received: (qmail 64055 invoked by alias); 9 Oct 2019 18:27:08 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 64030 invoked by uid 89); 9 Oct 2019 18:27:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 spammy=filling X-HELO: userp2120.oracle.com Received: from userp2120.oracle.com (HELO userp2120.oracle.com) (156.151.31.85) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 09 Oct 2019 18:27:04 +0000 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x99I48Vi092377; Wed, 9 Oct 2019 18:27:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=4Uw8TWG/5llb/Bh0cr+sTQVIj5qH4yJUS17r7tmm3gc=; b=eGvrQyIhoSOkgbvwvwZ4kZtoYj/pAgath2jeGOy4si+UTpi3Kiw1jQEFooCkD9uyyMYL RJdyBNIYebuAq89D7ioYxnS2E/3in4nK+LMhn/x7S+mME6BVx3u3j+N64C1XMde25li9 SqUOowy0XRnNJas37ofxObQa8qssa5g6G0dBnVR5xoqMqU6xuMmAh8u6Kq+Odi4vK9Zp ODp3hl8htFNtAGrMDoqRM+b2ZYN8/nk2Cx/pg+51uwvMUN7ttg/qaa7+1+uiBu6JfNSw FgB2xmf7v+ajT9hqfcwK6/Xi2NZ7CXluVb0GG3JeJ+NrUsLTg/0P64Q2TW/qkEBBo2Yp jQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2vektrp9dd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Oct 2019 18:27:02 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x99I7g2W193035; Wed, 9 Oct 2019 18:27:01 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2vhhsn33s6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Oct 2019 18:27:01 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x99IQxaR019488; Wed, 9 Oct 2019 18:27:00 GMT Received: from loom.srvr.nix (/81.187.191.129) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 09 Oct 2019 11:26:58 -0700 From: Nick Alcock To: binutils@sourceware.org, gdb-patches@sourceware.org Cc: Nick Alcock Subject: [PATCH v2 1/2] binutils, ld: work with --disable-libctf Date: Wed, 9 Oct 2019 19:26:47 +0100 Message-Id: <20191009182648.274292-1-nick.alcock@oracle.com> MIME-Version: 1.0 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.) 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. * 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. * 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 | 8 ++++++-- binutils/config.in | 3 +++ binutils/configure | 38 ++++++++++++++++++++++++++++++++++++-- binutils/configure.ac | 12 ++++++++++++ binutils/objdump.c | 27 ++++++++++++++++++++++++--- binutils/readelf.c | 8 ++++++++ ld/Makefile.am | 4 ++++ ld/Makefile.in | 4 +++- ld/config.in | 3 +++ ld/configure | 41 +++++++++++++++++++++++++++++++++++++++-- ld/configure.ac | 15 +++++++++++++++ ld/ldelfgen.c | 14 ++++++++++++++ ld/ldlang.c | 35 +++++++++++++++++++++++++++++++++++ 14 files changed, 207 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..82fdd992e0 100644 --- a/binutils/Makefile.in +++ b/binutils/Makefile.in @@ -220,6 +220,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 +228,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 +657,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/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..186abffd9e 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 --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,32 @@ cat >>confdefs.h <<_ACEOF _ACEOF +# Check whether --enable-libctf was given. +if test "${enable_libctf+set}" = set; then : + enableval=$enable_libctf; +if test "${enableval}" = no; then + enable_libctf=no +else + enable_libctf=yes +fi +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 +15338,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..9a73d35d1a 100644 --- a/binutils/configure.ac +++ b/binutils/configure.ac @@ -66,6 +66,18 @@ fi], [default_strings_all=1]) AC_DEFINE_UNQUOTED(DEFAULT_STRINGS_ALL, $default_strings_all, [Should strings use -a behavior by default?]) +AC_ARG_ENABLE(libctf, +[AS_HELP_STRING([--enable-libctf], [Handle .ctf type-info sections])], [ +if test "${enableval}" = no; then + enable_libctf=no +else + enable_libctf=yes +fi], [enable_libctf=yes]) +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/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) } +#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 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= Display CTF info from section \n\ --ctf-parent=\n\ @@ -4528,6 +4531,7 @@ usage (FILE * stream) Use section as the CTF external symtab\n\n\ --ctf-strings=\n\ Use section 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..4b734199bc 100644 --- a/ld/Makefile.in +++ b/ld/Makefile.in @@ -189,6 +189,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 +648,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/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..e46fd9ea8e 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 --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,32 @@ 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; +if test "${enableval}" = no; then + enable_libctf=no +else + enable_libctf=yes +fi +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 +17703,9 @@ else TESTBFDLIB="../bfd/.libs/libbfd.a" TESTCTFLIB="../libctf/.libs/libctf.a" fi +if test "${enable_libctf}" = no; then + TESTCTFLIB= +fi @@ -17845,6 +17878,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..5f950b8d85 100644 --- a/ld/configure.ac +++ b/ld/configure.ac @@ -212,6 +212,18 @@ case "${enable_default_hash_style}" in *) ac_default_emit_gnu_hash=0 ;; esac +AC_ARG_ENABLE(libctf, +[AS_HELP_STRING([--enable-libctf], [Handle .ctf type-info sections])], [ +if test "${enableval}" = no; then + enable_libctf=no +else + enable_libctf=yes +fi], [enable_libctf=yes]) +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 +508,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 2f72a7cdfd..7a68aaa792 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