• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revision094e34f22146ad53eb93da22e480cab428bd23b5 (tree)
Time2020-06-26 23:56:39
AuthorNick Alcock <nick.alcock@orac...>
CommiterNick Alcock

Log Message

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.

Change Summary

Incremental Difference

--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,28 @@
1+2020-06-26 Nick Alcock <nick.alcock@oracle.com>
2+
3+ * configure.ac [--enable-libctf]: New, default yes.
4+ Set ENABLE_LIBCTF accordingly.
5+ * Makefile.am [!ENABLE_LIBCTF]: Empty LIBCTF and LIBCTF_NOBFD.
6+ * configure: Regenerate.
7+ * config.in: Regenerate.
8+ * Makefile.in: Regenerate.
9+ * aclocal.m4: Regenerate.
10+ * objdump.c (usage): Conditionalize portions on ENABLE_LIBCTF.
11+ (option_values): Likewise.
12+ (long_options): Likewise.
13+ (main): Likewise.
14+ (dump_ctf_indent_lines): Conditionalize out when !ENABLE_LIBCTF.
15+ (make_ctfsect): Likewise.
16+ (dump_ctf_archive_member): Likewise.
17+ (dump_ctf) [ENABLE_LIBCTF]: Likewise.
18+ (dump_ctf) [!ENABLE_LIBCTF]: New empty stub.
19+ * readelf.c (options): Conditionalize portions on ENABLE_LIBCTF.
20+ (usage): Likewise.
21+ (process_section_contents): Likewise.
22+ (shdr_to_ctf_sect): Conditionalize out when !ENABLE_LIBCTF.
23+ (dump_ctf_indent_lines): Likewise.
24+ (dump_section_as_ctf) [ENABLE_LIBCTF]: Likewise.
25+
126 2020-06-26 Jan Beulich <jbeulich@suse.com>
227
328 * doc/binutils.texi: Adjust description of x86's -Msuffix. Drop
--- a/binutils/Makefile.am
+++ b/binutils/Makefile.am
@@ -164,8 +164,13 @@ BFDLIB = ../bfd/libbfd.la
164164
165165 OPCODES = ../opcodes/libopcodes.la
166166
167+if ENABLE_LIBCTF
167168 LIBCTF = ../libctf/libctf.la
168169 LIBCTF_NOBFD = ../libctf/libctf-nobfd.la
170+else
171+LIBCTF =
172+LIBCTF_NOBFD =
173+endif
169174
170175 LIBIBERTY = ../libiberty/libiberty.a
171176
--- a/binutils/Makefile.in
+++ b/binutils/Makefile.in
@@ -122,6 +122,7 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
122122 am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \
123123 $(top_srcdir)/../bfd/warning.m4 $(top_srcdir)/../config/acx.m4 \
124124 $(top_srcdir)/../config/depstand.m4 \
125+ $(top_srcdir)/../config/enable.m4 \
125126 $(top_srcdir)/../config/gettext-sister.m4 \
126127 $(top_srcdir)/../config/iconv.m4 \
127128 $(top_srcdir)/../config/largefile.m4 \
@@ -222,6 +223,7 @@ objcopy_LDADD = $(LDADD)
222223 am_objdump_OBJECTS = objdump.$(OBJEXT) dwarf.$(OBJEXT) prdbg.$(OBJEXT) \
223224 $(am__objects_3) $(am__objects_1) $(am__objects_2)
224225 objdump_OBJECTS = $(am_objdump_OBJECTS)
226+@ENABLE_LIBCTF_TRUE@am__DEPENDENCIES_2 = ../libctf/libctf.la
225227 am_ranlib_OBJECTS = ar.$(OBJEXT) is-ranlib.$(OBJEXT) arparse.$(OBJEXT) \
226228 arlex.$(OBJEXT) arsup.$(OBJEXT) rename.$(OBJEXT) \
227229 binemul.$(OBJEXT) emul_$(EMULATION).$(OBJEXT) $(am__objects_1)
@@ -229,6 +231,7 @@ ranlib_OBJECTS = $(am_ranlib_OBJECTS)
229231 am_readelf_OBJECTS = readelf.$(OBJEXT) version.$(OBJEXT) \
230232 unwind-ia64.$(OBJEXT) dwarf.$(OBJEXT) $(am__objects_2)
231233 readelf_OBJECTS = $(am_readelf_OBJECTS)
234+@ENABLE_LIBCTF_TRUE@am__DEPENDENCIES_3 = ../libctf/libctf-nobfd.la
232235 am_size_OBJECTS = size.$(OBJEXT) $(am__objects_1)
233236 size_OBJECTS = $(am_size_OBJECTS)
234237 size_LDADD = $(LDADD)
@@ -658,8 +661,10 @@ BULIBS = bucomm.c version.c filemode.c
658661 ELFLIBS = elfcomm.c
659662 BFDLIB = ../bfd/libbfd.la
660663 OPCODES = ../opcodes/libopcodes.la
661-LIBCTF = ../libctf/libctf.la
662-LIBCTF_NOBFD = ../libctf/libctf-nobfd.la
664+@ENABLE_LIBCTF_FALSE@LIBCTF =
665+@ENABLE_LIBCTF_TRUE@LIBCTF = ../libctf/libctf.la
666+@ENABLE_LIBCTF_FALSE@LIBCTF_NOBFD =
667+@ENABLE_LIBCTF_TRUE@LIBCTF_NOBFD = ../libctf/libctf-nobfd.la
663668 LIBIBERTY = ../libiberty/libiberty.a
664669 POTFILES = $(CFILES) $(DEBUG_SRCS) $(HFILES)
665670 EXPECT = expect
--- a/binutils/aclocal.m4
+++ b/binutils/aclocal.m4
@@ -1189,6 +1189,7 @@ m4_include([../bfd/acinclude.m4])
11891189 m4_include([../bfd/warning.m4])
11901190 m4_include([../config/acx.m4])
11911191 m4_include([../config/depstand.m4])
1192+m4_include([../config/enable.m4])
11921193 m4_include([../config/gettext-sister.m4])
11931194 m4_include([../config/iconv.m4])
11941195 m4_include([../config/largefile.m4])
--- a/binutils/config.in
+++ b/binutils/config.in
@@ -21,6 +21,9 @@
2121 /* Should strings use -a behavior by default? */
2222 #undef DEFAULT_STRINGS_ALL
2323
24+/* Handle .ctf type-info sections */
25+#undef ENABLE_LIBCTF
26+
2427 /* Define to 1 if translation of program messages to the user's native
2528 language is requested. */
2629 #undef ENABLE_NLS
--- a/binutils/configure
+++ b/binutils/configure
@@ -684,6 +684,8 @@ WARN_WRITE_STRINGS
684684 NO_WERROR
685685 WARN_CFLAGS_FOR_BUILD
686686 WARN_CFLAGS
687+ENABLE_LIBCTF_FALSE
688+ENABLE_LIBCTF_TRUE
687689 LIBDEBUGINFOD
688690 OTOOL64
689691 OTOOL
@@ -815,6 +817,7 @@ enable_targets
815817 enable_deterministic_archives
816818 enable_default_strings_all
817819 with_debuginfod
820+enable_libctf
818821 enable_werror
819822 enable_build_warnings
820823 enable_nls
@@ -1472,6 +1475,7 @@ Optional Features:
14721475 ar and ranlib default to -D behavior
14731476 --disable-default-strings-all
14741477 strings defaults to --data behavior
1478+ --enable-libctf Handle .ctf type-info sections [default=yes]
14751479 --enable-werror treat compile warnings as errors
14761480 --enable-build-warnings enable build-time compiler warnings
14771481 --disable-nls do not use Native Language Support
@@ -11529,7 +11533,7 @@ else
1152911533 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1153011534 lt_status=$lt_dlunknown
1153111535 cat > conftest.$ac_ext <<_LT_EOF
11532-#line 11532 "configure"
11536+#line 11536 "configure"
1153311537 #include "confdefs.h"
1153411538
1153511539 #if HAVE_DLFCN_H
@@ -11635,7 +11639,7 @@ else
1163511639 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1163611640 lt_status=$lt_dlunknown
1163711641 cat > conftest.$ac_ext <<_LT_EOF
11638-#line 11638 "configure"
11642+#line 11642 "configure"
1163911643 #include "confdefs.h"
1164011644
1164111645 #if HAVE_DLFCN_H
@@ -12331,6 +12335,33 @@ cat >>confdefs.h <<_ACEOF
1233112335 _ACEOF
1233212336
1233312337
12338+ # Check whether --enable-libctf was given.
12339+if test "${enable_libctf+set}" = set; then :
12340+ enableval=$enable_libctf;
12341+ case "$enableval" in
12342+ yes|no) ;;
12343+ *) as_fn_error $? "Argument to enable/disable libctf must be yes or no" "$LINENO" 5 ;;
12344+ esac
12345+
12346+else
12347+ enable_libctf=yes
12348+fi
12349+
12350+
12351+if test "${enable_libctf}" = yes; then
12352+
12353+$as_echo "#define ENABLE_LIBCTF 1" >>confdefs.h
12354+
12355+fi
12356+ if test "${enable_libctf}" = yes; then
12357+ ENABLE_LIBCTF_TRUE=
12358+ ENABLE_LIBCTF_FALSE='#'
12359+else
12360+ ENABLE_LIBCTF_TRUE='#'
12361+ ENABLE_LIBCTF_FALSE=
12362+fi
12363+
12364+
1233412365
1233512366 # Set the 'development' global.
1233612367 . $srcdir/../bfd/development.sh
@@ -15413,6 +15444,10 @@ else
1541315444 am__EXEEXT_FALSE=
1541415445 fi
1541515446
15447+if test -z "${ENABLE_LIBCTF_TRUE}" && test -z "${ENABLE_LIBCTF_FALSE}"; then
15448+ as_fn_error $? "conditional \"ENABLE_LIBCTF\" was never defined.
15449+Usually this means the macro was only invoked conditionally." "$LINENO" 5
15450+fi
1541615451 if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
1541715452 as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
1541815453 Usually this means the macro was only invoked conditionally." "$LINENO" 5
--- a/binutils/configure.ac
+++ b/binutils/configure.ac
@@ -69,6 +69,12 @@ AC_DEBUGINFOD
6969 AC_DEFINE_UNQUOTED(DEFAULT_STRINGS_ALL, $default_strings_all,
7070 [Should strings use -a behavior by default?])
7171
72+GCC_ENABLE([libctf], [yes], [], [Handle .ctf type-info sections])
73+if test "${enable_libctf}" = yes; then
74+ AC_DEFINE(ENABLE_LIBCTF, 1, [Handle .ctf type-info sections])
75+fi
76+AM_CONDITIONAL(ENABLE_LIBCTF, test "${enable_libctf}" = yes)
77+
7278 AM_BINUTILS_WARNINGS
7379
7480 AC_CONFIG_HEADERS(config.h:config.in)
--- a/binutils/doc/Makefile.in
+++ b/binutils/doc/Makefile.in
@@ -111,6 +111,7 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
111111 am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \
112112 $(top_srcdir)/../bfd/warning.m4 $(top_srcdir)/../config/acx.m4 \
113113 $(top_srcdir)/../config/depstand.m4 \
114+ $(top_srcdir)/../config/enable.m4 \
114115 $(top_srcdir)/../config/gettext-sister.m4 \
115116 $(top_srcdir)/../config/iconv.m4 \
116117 $(top_srcdir)/../config/largefile.m4 \
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -235,7 +235,13 @@ usage (FILE *stream, int status)
235235 =gdb_index,=trace_info,=trace_abbrev,=trace_aranges,\n\
236236 =addr,=cu_index,=links,=follow-links]\n\
237237 Display DWARF info in the file\n\
238+"));
239+#ifdef ENABLE_LIBCTF
240+ fprintf (stream, _("\
238241 --ctf=SECTION Display CTF info from SECTION\n\
242+"));
243+#endif
244+ fprintf (stream, _("\
239245 -t, --syms Display the contents of the symbol table(s)\n\
240246 -T, --dynamic-syms Display the contents of the dynamic symbol table\n\
241247 -r, --reloc Display the relocation entries in the file\n\
@@ -284,9 +290,12 @@ usage (FILE *stream, int status)
284290 --dwarf-depth=N Do not display DIEs at depth N or greater\n\
285291 --dwarf-start=N Display DIEs starting with N, at the same depth\n\
286292 or deeper\n\
287- --dwarf-check Make additional dwarf internal consistency checks.\
288- \n\
289- --ctf-parent=SECTION Use SECTION as the CTF parent\n\
293+ --dwarf-check Make additional dwarf internal consistency checks.\n"));
294+#ifdef ENABLE_LIBCTF
295+ fprintf (stream, _("\
296+ --ctf-parent=SECTION Use SECTION as the CTF parent\n"));
297+#endif
298+ fprintf (stream, _("\
290299 --visualize-jumps Visualize jumps by drawing ASCII art lines\n\
291300 --visualize-jumps=color Use colors in the ASCII art\n\
292301 --visualize-jumps=extended-color Use extended 8-bit color codes\n\
@@ -328,8 +337,10 @@ enum option_values
328337 OPTION_NO_RECURSE_LIMIT,
329338 OPTION_INLINES,
330339 OPTION_SOURCE_COMMENT,
340+#ifdef ENABLE_LIBCTF
331341 OPTION_CTF,
332342 OPTION_CTF_PARENT,
343+#endif
333344 OPTION_VISUALIZE_JUMPS
334345 };
335346
@@ -375,8 +386,10 @@ static struct option long_options[]=
375386 {"special-syms", no_argument, &dump_special_syms, 1},
376387 {"include", required_argument, NULL, 'I'},
377388 {"dwarf", optional_argument, NULL, OPTION_DWARF},
389+#ifdef ENABLE_LIBCTF
378390 {"ctf", required_argument, NULL, OPTION_CTF},
379391 {"ctf-parent", required_argument, NULL, OPTION_CTF_PARENT},
392+#endif
380393 {"stabs", no_argument, NULL, 'G'},
381394 {"start-address", required_argument, NULL, OPTION_START_ADDRESS},
382395 {"stop-address", required_argument, NULL, OPTION_STOP_ADDRESS},
@@ -4026,6 +4039,7 @@ dump_bfd_header (bfd *abfd)
40264039 }
40274040
40284041
4042+#ifdef ENABLE_LIBCTF
40294043 /* Formatting callback function passed to ctf_dump. Returns either the pointer
40304044 it is passed, or a pointer to newly-allocated storage, in which case
40314045 dump_ctf() will free it when it no longer needs it. */
@@ -4167,6 +4181,11 @@ dump_ctf (bfd *abfd, const char *sect_name, const char *parent_name)
41674181 free (parentdata);
41684182 free (ctfdata);
41694183 }
4184+#else
4185+static void
4186+dump_ctf (bfd *abfd ATTRIBUTE_UNUSED, const char *sect_name ATTRIBUTE_UNUSED,
4187+ const char *parent_name ATTRIBUTE_UNUSED) {}
4188+#endif
41704189
41714190
41724191 static void
@@ -5348,6 +5367,7 @@ main (int argc, char **argv)
53485367 case OPTION_DWARF_CHECK:
53495368 dwarf_check = TRUE;
53505369 break;
5370+#ifdef ENABLE_LIBCTF
53515371 case OPTION_CTF:
53525372 dump_ctf_section_info = TRUE;
53535373 dump_ctf_section_name = xstrdup (optarg);
@@ -5356,6 +5376,7 @@ main (int argc, char **argv)
53565376 case OPTION_CTF_PARENT:
53575377 dump_ctf_parent_name = xstrdup (optarg);
53585378 break;
5379+#endif
53595380 case 'G':
53605381 dump_stab_section_info = TRUE;
53615382 seenflag = TRUE;
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -4502,11 +4502,13 @@ static struct option options[] =
45024502 {"dwarf-start", required_argument, 0, OPTION_DWARF_START},
45034503 {"dwarf-check", no_argument, 0, OPTION_DWARF_CHECK},
45044504
4505+#ifdef ENABLE_LIBCTF
45054506 {"ctf", required_argument, 0, OPTION_CTF_DUMP},
45064507
45074508 {"ctf-symbols", required_argument, 0, OPTION_CTF_SYMBOLS},
45084509 {"ctf-strings", required_argument, 0, OPTION_CTF_STRINGS},
45094510 {"ctf-parent", required_argument, 0, OPTION_CTF_PARENT},
4511+#endif
45104512
45114513 {"version", no_argument, 0, 'v'},
45124514 {"wide", no_argument, 0, 'W'},
@@ -4558,6 +4560,7 @@ usage (FILE * stream)
45584560 --dwarf-depth=N Do not display DIEs at depth N or greater\n\
45594561 --dwarf-start=N Display DIEs starting with N, at the same depth\n\
45604562 or deeper\n"));
4563+#ifdef ENABLE_LIBCTF
45614564 fprintf (stream, _("\
45624565 --ctf=<number|name> Display CTF info from section <number|name>\n\
45634566 --ctf-parent=<number|name>\n\
@@ -4566,6 +4569,7 @@ usage (FILE * stream)
45664569 Use section <number|name> as the CTF external symtab\n\n\
45674570 --ctf-strings=<number|name>\n\
45684571 Use section <number|name> as the CTF external strtab\n\n"));
4572+#endif
45694573
45704574 #ifdef SUPPORT_DISASSEMBLY
45714575 fprintf (stream, _("\
@@ -14132,6 +14136,7 @@ dump_section_as_bytes (Elf_Internal_Shdr * section,
1413214136 return FALSE;
1413314137 }
1413414138
14139+#ifdef ENABLE_LIBCTF
1413514140 static ctf_sect_t *
1413614141 shdr_to_ctf_sect (ctf_sect_t *buf, Elf_Internal_Shdr *shdr, Filedata *filedata)
1413714142 {
@@ -14292,6 +14297,7 @@ dump_section_as_ctf (Elf_Internal_Shdr * section, Filedata * filedata)
1429214297 free (strdata);
1429314298 return ret;
1429414299 }
14300+#endif
1429514301
1429614302 static bfd_boolean
1429714303 load_specific_debug_section (enum dwarf_section_display_enum debug,
@@ -14777,11 +14783,13 @@ process_section_contents (Filedata * filedata)
1477714783 res = FALSE;
1477814784 }
1477914785
14786+#ifdef ENABLE_LIBCTF
1478014787 if (dump & CTF_DUMP)
1478114788 {
1478214789 if (! dump_section_as_ctf (section, filedata))
1478314790 res = FALSE;
1478414791 }
14792+#endif
1478514793 }
1478614794
1478714795 /* Check to see if the user requested a
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,33 @@
1+2020-06-26 Nick Alcock <nick.alcock@oracle.com>
2+
3+ * configure.ac [--enable-libctf]: New, default yes.
4+ Set ENABLE_LIBCTF accordingly.
5+ * Makefile.am [!ENABLE_LIBCTF]: Empty LIBCTF.
6+ * configure: Regenerate.
7+ * config.in: Regenerate.
8+ * Makefile.in: Regenerate.
9+ * aclocal.m4: Regenerate.
10+ * ldlang.c (ctf_output): Conditionalize on ENABLE_LIBCTF.
11+ (ldlang_open_ctf): Likewise.
12+ (lang_merge_ctf): Likewise.
13+ (ldlang_ctf_apply_strsym): Likewise.
14+ (lang_write_ctf): Likewise.
15+ (ldlang_write_ctf_late): Likewise.
16+ (ldlang_open_ctf) [!ENABLE_LIBCTF]: Warn about the presence of CTF
17+ sections.
18+ (lang_merge_ctf) [!ENABLE_LIBCTF]: New stub.
19+ (ldlang_ctf_apply_strsym) [!ENABLE_LIBCTF]: Likewise.
20+ (lang_write_ctf) [!ENABLE_LIBCTF]: Likewise.
21+ (ldlang_write_ctf_late) [!ENABLE_LIBCTF]: Likewise.
22+ * ldelfgen.c (ldelf_emit_ctf_early): Conditionalize on
23+ ENABLE_LIBCTF.
24+ (struct ctf_strsym_iter_cb_arg): Likewise.
25+ (ldelf_ctf_strtab_iter_cb): Likewise.
26+ (ldelf_ctf_symbols_iter_cb): Likewise.
27+ (ldelf_examine_strtab_for_ctf): Likewise.
28+ (ldelf_emit_ctf_early) [!ENABLE_LIBCTF]: New stub.
29+ (ldelf_examine_strtab_for_ctf) [!ENABLE_LIBCTF]: New stub.
30+
131 2020-06-26 Jan Beulich <jbeulich@suse.com>
232
333 * testsuite/ld-x86-64/x86-64.exp: Run K1OM tests.
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -144,7 +144,11 @@ AM_CPPFLAGS = -I. -I$(srcdir) -I../bfd -I$(BFDDIR) -I$(INCDIR) @zlibinc@ \
144144
145145 BFDLIB = ../bfd/libbfd.la
146146 LIBIBERTY = ../libiberty/libiberty.a
147+if ENABLE_LIBCTF
147148 LIBCTF = ../libctf/libctf.la
149+else
150+LIBCTF =
151+endif
148152
149153 # These all start with e so 'make clean' can find them.
150154 ALL_EMULATION_SOURCES = \
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -113,6 +113,7 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
113113 am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \
114114 $(top_srcdir)/../bfd/warning.m4 $(top_srcdir)/../config/acx.m4 \
115115 $(top_srcdir)/../config/depstand.m4 \
116+ $(top_srcdir)/../config/enable.m4 \
116117 $(top_srcdir)/../config/gettext-sister.m4 \
117118 $(top_srcdir)/../config/largefile.m4 \
118119 $(top_srcdir)/../config/lcmessage.m4 \
@@ -180,6 +181,7 @@ am_ld_new_OBJECTS = ldgram.$(OBJEXT) ldlex-wrapper.$(OBJEXT) \
180181 plugin.$(OBJEXT) ldbuildid.$(OBJEXT)
181182 ld_new_OBJECTS = $(am_ld_new_OBJECTS)
182183 am__DEPENDENCIES_1 =
184+@ENABLE_LIBCTF_TRUE@am__DEPENDENCIES_2 = ../libctf/libctf.la
183185 AM_V_P = $(am__v_P_@AM_V@)
184186 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
185187 am__v_P_0 = false
@@ -628,7 +630,8 @@ AM_CPPFLAGS = -I. -I$(srcdir) -I../bfd -I$(BFDDIR) -I$(INCDIR) @zlibinc@ \
628630
629631 BFDLIB = ../bfd/libbfd.la
630632 LIBIBERTY = ../libiberty/libiberty.a
631-LIBCTF = ../libctf/libctf.la
633+@ENABLE_LIBCTF_FALSE@LIBCTF =
634+@ENABLE_LIBCTF_TRUE@LIBCTF = ../libctf/libctf.la
632635
633636 # These all start with e so 'make clean' can find them.
634637 ALL_EMULATION_SOURCES = \
--- a/ld/aclocal.m4
+++ b/ld/aclocal.m4
@@ -1189,6 +1189,7 @@ m4_include([../bfd/acinclude.m4])
11891189 m4_include([../bfd/warning.m4])
11901190 m4_include([../config/acx.m4])
11911191 m4_include([../config/depstand.m4])
1192+m4_include([../config/enable.m4])
11921193 m4_include([../config/gettext-sister.m4])
11931194 m4_include([../config/largefile.m4])
11941195 m4_include([../config/lcmessage.m4])
--- a/ld/config.in
+++ b/ld/config.in
@@ -33,6 +33,9 @@
3333 */
3434 #undef DEFAULT_NEW_DTAGS
3535
36+/* Handle .ctf type-info sections */
37+#undef ENABLE_LIBCTF
38+
3639 /* Define to 1 if translation of program messages to the user's native
3740 language is requested. */
3841 #undef ENABLE_NLS
--- a/ld/configure
+++ b/ld/configure
@@ -678,6 +678,8 @@ WARN_WRITE_STRINGS
678678 NO_WERROR
679679 WARN_CFLAGS_FOR_BUILD
680680 WARN_CFLAGS
681+ENABLE_LIBCTF_FALSE
682+ENABLE_LIBCTF_TRUE
681683 installed_linker
682684 install_as_default
683685 TARGET_SYSTEM_ROOT_DEFINE
@@ -832,6 +834,7 @@ enable_relro
832834 enable_textrel_check
833835 enable_separate_code
834836 enable_default_hash_style
837+enable_libctf
835838 enable_werror
836839 enable_build_warnings
837840 enable_nls
@@ -1502,6 +1505,7 @@ Optional Features:
15021505 --enable-separate-code enable -z separate-code in ELF linker by default
15031506 --enable-default-hash-style={sysv,gnu,both}
15041507 use this default hash style
1508+ --enable-libctf Handle .ctf type-info sections [default=yes]
15051509 --enable-werror treat compile warnings as errors
15061510 --enable-build-warnings enable build-time compiler warnings
15071511 --disable-nls do not use Native Language Support
@@ -12033,7 +12037,7 @@ else
1203312037 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1203412038 lt_status=$lt_dlunknown
1203512039 cat > conftest.$ac_ext <<_LT_EOF
12036-#line 12036 "configure"
12040+#line 12040 "configure"
1203712041 #include "confdefs.h"
1203812042
1203912043 #if HAVE_DLFCN_H
@@ -12139,7 +12143,7 @@ else
1213912143 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1214012144 lt_status=$lt_dlunknown
1214112145 cat > conftest.$ac_ext <<_LT_EOF
12142-#line 12142 "configure"
12146+#line 12146 "configure"
1214312147 #include "confdefs.h"
1214412148
1214512149 #if HAVE_DLFCN_H
@@ -15926,6 +15930,33 @@ case "${enable_default_hash_style}" in
1592615930 *) ac_default_emit_gnu_hash=0 ;;
1592715931 esac
1592815932
15933+ # Check whether --enable-libctf was given.
15934+if test "${enable_libctf+set}" = set; then :
15935+ enableval=$enable_libctf;
15936+ case "$enableval" in
15937+ yes|no) ;;
15938+ *) as_fn_error $? "Argument to enable/disable libctf must be yes or no" "$LINENO" 5 ;;
15939+ esac
15940+
15941+else
15942+ enable_libctf=yes
15943+fi
15944+
15945+
15946+if test "${enable_libctf}" = yes; then
15947+
15948+$as_echo "#define ENABLE_LIBCTF 1" >>confdefs.h
15949+
15950+fi
15951+ if test "${enable_libctf}" = yes; then
15952+ ENABLE_LIBCTF_TRUE=
15953+ ENABLE_LIBCTF_FALSE='#'
15954+else
15955+ ENABLE_LIBCTF_TRUE='#'
15956+ ENABLE_LIBCTF_FALSE=
15957+fi
15958+
15959+
1592915960
1593015961 # Set the 'development' global.
1593115962 . $srcdir/../bfd/development.sh
@@ -17700,6 +17731,9 @@ else
1770017731 TESTBFDLIB="../bfd/.libs/libbfd.a"
1770117732 TESTCTFLIB="../libctf/.libs/libctf.a"
1770217733 fi
17734+if test "${enable_libctf}" = no; then
17735+ TESTCTFLIB=
17736+fi
1770317737
1770417738
1770517739
@@ -17872,6 +17906,10 @@ if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
1787217906 as_fn_error $? "conditional \"am__fastdepCXX\" was never defined.
1787317907 Usually this means the macro was only invoked conditionally." "$LINENO" 5
1787417908 fi
17909+if test -z "${ENABLE_LIBCTF_TRUE}" && test -z "${ENABLE_LIBCTF_FALSE}"; then
17910+ as_fn_error $? "conditional \"ENABLE_LIBCTF\" was never defined.
17911+Usually this means the macro was only invoked conditionally." "$LINENO" 5
17912+fi
1787517913 if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
1787617914 as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
1787717915 Usually this means the macro was only invoked conditionally." "$LINENO" 5
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -221,6 +221,12 @@ case "${enable_default_hash_style}" in
221221 *) ac_default_emit_gnu_hash=0 ;;
222222 esac
223223
224+GCC_ENABLE([libctf], [yes], [], [Handle .ctf type-info sections])
225+if test "${enable_libctf}" = yes; then
226+ AC_DEFINE(ENABLE_LIBCTF, 1, [Handle .ctf type-info sections])
227+fi
228+AM_CONDITIONAL(ENABLE_LIBCTF, test "${enable_libctf}" = yes)
229+
224230 AM_BINUTILS_WARNINGS
225231
226232 AM_LC_MESSAGES
@@ -524,6 +530,9 @@ else
524530 TESTBFDLIB="../bfd/.libs/libbfd.a"
525531 TESTCTFLIB="../libctf/.libs/libctf.a"
526532 fi
533+if test "${enable_libctf}" = no; then
534+ TESTCTFLIB=
535+fi
527536 AC_SUBST(TESTBFDLIB)
528537 AC_SUBST(TESTCTFLIB)
529538
--- a/ld/ldelfgen.c
+++ b/ld/ldelfgen.c
@@ -88,6 +88,7 @@ ldelf_map_segments (bfd_boolean need_layout)
8888 }
8989 }
9090
91+#ifdef ENABLE_LIBCTF
9192 /* We want to emit CTF early if and only if we are not targetting ELF with this
9293 invocation. */
9394
@@ -197,3 +198,16 @@ ldelf_examine_strtab_for_ctf
197198 "cost: %s\n"), ctf_errmsg (ctf_errno (ctf_output)));
198199 }
199200 }
201+#else
202+extern int ldelf_emit_ctf_early (void)
203+{
204+ return 0;
205+}
206+
207+extern void ldelf_examine_strtab_for_ctf
208+ (struct ctf_file *ctf_output ATTRIBUTE_UNUSED,
209+ struct elf_sym_strtab *syms ATTRIBUTE_UNUSED,
210+ bfd_size_type symcount ATTRIBUTE_UNUSED,
211+ struct elf_strtab_hash *symstrtab ATTRIBUTE_UNUSED)
212+{}
213+#endif
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -131,7 +131,9 @@ bfd_boolean delete_output_file_on_failure = FALSE;
131131 struct lang_phdr *lang_phdr_list;
132132 struct lang_nocrossrefs *nocrossref_list;
133133 struct asneeded_minfo **asneeded_list_tail;
134+#ifdef ENABLE_LIBCTF
134135 static ctf_file_t *ctf_output;
136+#endif
135137
136138 /* Functions that traverse the linker script and might evaluate
137139 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)
36693671 einfo ("%F");
36703672 }
36713673
3674+#ifdef ENABLE_LIBCTF
36723675 /* Open the CTF sections in the input files with libctf: if any were opened,
36733676 create a fake input file that we'll write the merged CTF data to later
36743677 on. */
@@ -3848,6 +3851,38 @@ ldlang_write_ctf_late (void)
38483851
38493852 lang_write_ctf (1);
38503853 }
3854+#else
3855+static void
3856+ldlang_open_ctf (void)
3857+{
3858+ LANG_FOR_EACH_INPUT_STATEMENT (file)
3859+ {
3860+ asection *sect;
3861+
3862+ /* If built without CTF, warn and delete all CTF sections from the output.
3863+ (The alternative would be to simply concatenate them, which does not
3864+ yield a valid CTF section.) */
3865+
3866+ if ((sect = bfd_get_section_by_name (file->the_bfd, ".ctf")) != NULL)
3867+ {
3868+ einfo (_("%P: warning: CTF section in `%pI' not linkable: "
3869+ "%P was built without support for CTF\n"), file);
3870+ sect->size = 0;
3871+ sect->flags |= SEC_EXCLUDE;
3872+ }
3873+ }
3874+}
3875+
3876+static void lang_merge_ctf (void) {}
3877+void
3878+ldlang_ctf_apply_strsym (struct elf_sym_strtab *syms ATTRIBUTE_UNUSED,
3879+ bfd_size_type symcount ATTRIBUTE_UNUSED,
3880+ struct elf_strtab_hash *symstrtab ATTRIBUTE_UNUSED)
3881+{
3882+}
3883+static void lang_write_ctf (int late ATTRIBUTE_UNUSED) {}
3884+void ldlang_write_ctf_late (void) {}
3885+#endif
38513886
38523887 /* Add the supplied name to the symbol table as an undefined reference.
38533888 This is a two step process as the symbol table doesn't even exist at