diff --git a/binutils-2.38.tar.xz b/binutils-2.39.tar.xz similarity index 68% rename from binutils-2.38.tar.xz rename to binutils-2.39.tar.xz index b53abfc3b024418e8fb0c21b0a19b2cb4f088029..b6bde31eb74a777f6641e4dfd41a8057c2a6b279 100644 Binary files a/binutils-2.38.tar.xz and b/binutils-2.39.tar.xz differ diff --git a/binutils-CVE-2019-1010204.patch b/binutils-CVE-2019-1010204.patch deleted file mode 100644 index 56434b10d91ce8e21a29ccfd44e92226817963aa..0000000000000000000000000000000000000000 --- a/binutils-CVE-2019-1010204.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- binutils.orig/gold/fileread.cc 2019-08-06 14:22:08.669313110 +0100 -+++ binutils-2.32/gold/fileread.cc 2019-08-06 14:22:28.799177543 +0100 -@@ -381,6 +381,12 @@ File_read::do_read(off_t start, section_ - ssize_t bytes; - if (this->whole_file_view_ != NULL) - { -+ // See PR 23765 for an example of a testcase that triggers this error. -+ if (((ssize_t) start) < 0) -+ gold_fatal(_("%s: read failed, starting offset (%#llx) less than zero"), -+ this->filename().c_str(), -+ static_cast(start)); -+ - bytes = this->size_ - start; - if (static_cast(bytes) >= size) - { diff --git a/binutils-CVE-2022-4285.patch b/binutils-CVE-2022-4285.patch new file mode 100644 index 0000000000000000000000000000000000000000..191e6f1501d4840c38b03f2e5fc05333374df762 --- /dev/null +++ b/binutils-CVE-2022-4285.patch @@ -0,0 +1,13 @@ +--- binutils.orig/bfd/elf.c 2022-12-13 15:21:20.040233487 +0000 ++++ binutils-2.39/bfd/elf.c 2022-12-13 15:22:33.580986232 +0000 +@@ -8868,7 +8868,9 @@ _bfd_elf_slurp_version_tables (bfd *abfd + bfd_set_error (bfd_error_file_too_big); + goto error_return_verref; + } +- elf_tdata (abfd)->verref = (Elf_Internal_Verneed *) bfd_alloc (abfd, amt); ++ if (amt == 0) ++ goto error_return_verref; ++ elf_tdata (abfd)->verref = (Elf_Internal_Verneed *) bfd_zalloc (abfd, amt); + if (elf_tdata (abfd)->verref == NULL) + goto error_return_verref; + diff --git a/binutils-CVE-38128-dwarf-abbrev-parsing.patch b/binutils-CVE-38128-dwarf-abbrev-parsing.patch new file mode 100644 index 0000000000000000000000000000000000000000..a175bb7f7bd024266998585a6b482f015460b1b1 --- /dev/null +++ b/binutils-CVE-38128-dwarf-abbrev-parsing.patch @@ -0,0 +1,15 @@ +--- binutils.orig/binutils/dwarf.c 2022-08-31 11:58:08.918685348 +0100 ++++ binutils-2.39/binutils/dwarf.c 2022-08-31 15:24:13.881865797 +0100 +@@ -6365,7 +6365,11 @@ display_debug_abbrev (struct dwarf_secti + list->start_of_next_abbrevs = start; + } + else +- start = list->start_of_next_abbrevs; ++ { ++ if (start == list->start_of_next_abbrevs) ++ break; ++ start = list->start_of_next_abbrevs; ++ } + + if (list->first_abbrev == NULL) + continue; diff --git a/binutils-gas-dwarf-skip-empty-functions.patch b/binutils-gas-dwarf-skip-empty-functions.patch new file mode 100644 index 0000000000000000000000000000000000000000..6d75c0bf5e6b7ac6a7b1566994512965bc2f0f07 --- /dev/null +++ b/binutils-gas-dwarf-skip-empty-functions.patch @@ -0,0 +1,93 @@ +From b53c44bfe31fb036f212275b6d70edd5eee7b088 Mon Sep 17 00:00:00 2001 +From: Jan Beulich via Binutils +Date: Tue, 9 Aug 2022 13:12:03 +0200 +Subject: [PATCH] gas/Dwarf: properly skip zero-size functions + +PR gas/29451 + +While out_debug_abbrev() properly skips such functions, out_debug_info() +mistakenly didn't. It needs to calculate the high_pc expression ahead of +time, in order to skip emitting any data for the function if the value +is zero. + +The one case which would still leave a zero-size entry is when +symbol_get_obj(symp)->size ends up evaluating to zero. I hope we can +expect that to not be the case, otherwise we'd need to have a way to +post-process .debug_info contents between resolving expressions and +actually writing the data out to the file. Even then it wouldn't be +entirely obvious in which way to alter the data. +--- + gas/dwarf2dbg.c | 39 ++++++++++++++++++++------------------- + 1 file changed, 20 insertions(+), 19 deletions(-) + +diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c +index 868ec79ee2c..f346bd6a412 100644 +--- a/gas/dwarf2dbg.c ++++ b/gas/dwarf2dbg.c +@@ -2882,6 +2882,7 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT str_seg, + { + const char *name; + size_t len; ++ expressionS size = { .X_op = O_constant }; + + /* Skip warning constructs (see above). */ + if (symbol_get_bfdsym (symp)->flags & BSF_WARNING) +@@ -2895,6 +2896,18 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT str_seg, + if (!S_IS_DEFINED (symp) || !S_IS_FUNCTION (symp)) + continue; + ++#if defined (OBJ_ELF) /* || defined (OBJ_MAYBE_ELF) */ ++ size.X_add_number = S_GET_SIZE (symp); ++ if (size.X_add_number == 0 && IS_ELF ++ && symbol_get_obj (symp)->size != NULL) ++ { ++ size.X_op = O_add; ++ size.X_op_symbol = make_expr_symbol (symbol_get_obj (symp)->size); ++ } ++#endif ++ if (size.X_op == O_constant && size.X_add_number == 0) ++ continue; ++ + subseg_set (str_seg, 0); + name_sym = symbol_temp_new_now_octets (); + name = S_GET_NAME (symp); +@@ -2920,29 +2933,17 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT str_seg, + emit_expr (&exp, sizeof_address); + + /* DW_AT_high_pc */ +- exp.X_op = O_constant; +-#if defined (OBJ_ELF) /* || defined (OBJ_MAYBE_ELF) */ +- exp.X_add_number = S_GET_SIZE (symp); +- if (exp.X_add_number == 0 && IS_ELF +- && symbol_get_obj (symp)->size != NULL) +- { +- exp.X_op = O_add; +- exp.X_op_symbol = make_expr_symbol (symbol_get_obj (symp)->size); +- } +-#else +- exp.X_add_number = 0; +-#endif + if (DWARF2_VERSION < 4) + { +- if (exp.X_op == O_constant) +- exp.X_op = O_symbol; +- exp.X_add_symbol = symp; +- emit_expr (&exp, sizeof_address); ++ if (size.X_op == O_constant) ++ size.X_op = O_symbol; ++ size.X_add_symbol = symp; ++ emit_expr (&size, sizeof_address); + } +- else if (exp.X_op == O_constant) +- out_uleb128 (exp.X_add_number); ++ else if (size.X_op == O_constant) ++ out_uleb128 (size.X_add_number); + else +- emit_leb128_expr (symbol_get_value_expression (exp.X_op_symbol), 0); ++ emit_leb128_expr (symbol_get_value_expression (size.X_op_symbol), 0); + } + + /* End of children. */ +-- +2.37.1 + diff --git a/binutils-libiberty-configure-compile-warnings.patch b/binutils-libiberty-configure-compile-warnings.patch new file mode 100644 index 0000000000000000000000000000000000000000..29ec5fa4168dc311684add344cb53b16fbbd1ca6 --- /dev/null +++ b/binutils-libiberty-configure-compile-warnings.patch @@ -0,0 +1,283 @@ +diff -rup binutils.orig/libiberty/acinclude.m4 binutils-2.39/libiberty/acinclude.m4 +--- binutils.orig/libiberty/acinclude.m4 2022-11-23 14:41:57.639262100 +0000 ++++ binutils-2.39/libiberty/acinclude.m4 2022-11-23 14:43:07.139042148 +0000 +@@ -24,6 +24,8 @@ AC_CACHE_CHECK([for working strncmp], ac + [AC_TRY_RUN([ + /* Test by Jim Wilson and Kaveh Ghazi. + Check whether strncmp reads past the end of its string parameters. */ ++#include ++#include + #include + + #ifdef HAVE_FCNTL_H +@@ -51,7 +53,8 @@ AC_CACHE_CHECK([for working strncmp], ac + + #define MAP_LEN 0x10000 + +-main () ++int ++main (void) + { + #if defined(HAVE_MMAP) || defined(HAVE_MMAP_ANYWHERE) + char *p; +@@ -157,7 +160,10 @@ if test $ac_cv_os_cray = yes; then + fi + + AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction, +-[AC_TRY_RUN([find_stack_direction () ++[AC_TRY_RUN([#include ++ ++int ++find_stack_direction (void) + { + static char *addr = 0; + auto char dummy; +@@ -169,7 +175,9 @@ AC_CACHE_CHECK(stack direction for C all + else + return (&dummy > addr) ? 1 : -1; + } +-main () ++ ++int ++main (void) + { + exit (find_stack_direction() < 0); + }], +diff -rup binutils.orig/libiberty/configure binutils-2.39/libiberty/configure +--- binutils.orig/libiberty/configure 2022-11-23 14:41:57.652262059 +0000 ++++ binutils-2.39/libiberty/configure 2022-11-23 14:46:31.556395168 +0000 +@@ -1766,7 +1766,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ + /* end confdefs.h. */ + $4 + int +-main () ++main (void) + { + static int test_array [1 - 2 * !(($2) >= 0)]; + test_array [0] = 0; +@@ -1783,7 +1783,7 @@ if ac_fn_c_try_compile "$LINENO"; then : + /* end confdefs.h. */ + $4 + int +-main () ++main (void) + { + static int test_array [1 - 2 * !(($2) <= $ac_mid)]; + test_array [0] = 0; +@@ -1810,7 +1810,7 @@ else + /* end confdefs.h. */ + $4 + int +-main () ++main (void) + { + static int test_array [1 - 2 * !(($2) < 0)]; + test_array [0] = 0; +@@ -1827,7 +1827,7 @@ if ac_fn_c_try_compile "$LINENO"; then : + /* end confdefs.h. */ + $4 + int +-main () ++main (void) + { + static int test_array [1 - 2 * !(($2) >= $ac_mid)]; + test_array [0] = 0; +@@ -1862,7 +1862,7 @@ while test "x$ac_lo" != "x$ac_hi"; do + /* end confdefs.h. */ + $4 + int +-main () ++main (void) + { + static int test_array [1 - 2 * !(($2) <= $ac_mid)]; + test_array [0] = 0; +@@ -1892,7 +1892,7 @@ static unsigned long int ulongval () { r + #include + #include + int +-main () ++main (void) + { + + FILE *f = fopen ("conftest.val", "w"); +@@ -1952,7 +1952,7 @@ else + /* end confdefs.h. */ + $4 + int +-main () ++main (void) + { + if (sizeof ($2)) + return 0; +@@ -1965,7 +1965,7 @@ if ac_fn_c_try_compile "$LINENO"; then : + /* end confdefs.h. */ + $4 + int +-main () ++main (void) + { + if (sizeof (($2))) + return 0; +@@ -2037,7 +2037,7 @@ choke me + #endif + + int +-main () ++main (void) + { + return $2 (); + ; +@@ -2077,7 +2077,7 @@ else + /* end confdefs.h. */ + $4 + int +-main () ++main (void) + { + #ifndef $as_decl_name + #ifdef __cplusplus +@@ -3459,7 +3459,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ + /* end confdefs.h. */ + #include + int +-main () ++main (void) + { + printf ("hello world\n"); + ; +@@ -3487,7 +3487,7 @@ else + /* end confdefs.h. */ + + int +-main () ++main (void) + { + + ; +@@ -3627,7 +3627,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ + /* end confdefs.h. */ + #include + int +-main () ++main (void) + { + FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; +@@ -3692,7 +3692,7 @@ else + /* end confdefs.h. */ + + int +-main () ++main (void) + { + + ; +@@ -3743,7 +3743,7 @@ else + /* end confdefs.h. */ + + int +-main () ++main (void) + { + #ifndef __GNUC__ + choke me +@@ -3784,7 +3784,7 @@ else + /* end confdefs.h. */ + + int +-main () ++main (void) + { + + ; +@@ -3799,7 +3799,7 @@ else + /* end confdefs.h. */ + + int +-main () ++main (void) + { + + ; +@@ -3815,7 +3815,7 @@ else + /* end confdefs.h. */ + + int +-main () ++main (void) + { + + ; +@@ -3901,7 +3901,7 @@ int pairnames (int, char **, FILE *(*)(s + int argc; + char **argv; + int +-main () ++main (void) + { + return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; +@@ -6919,7 +6919,10 @@ else + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +-find_stack_direction () ++#include ++ ++int ++find_stack_direction (void) + { + static char *addr = 0; + auto char dummy; +@@ -6931,7 +6934,9 @@ find_stack_direction () + else + return (&dummy > addr) ? 1 : -1; + } +-main () ++ ++int ++main (int) + { + exit (find_stack_direction() < 0); + } +@@ -7756,6 +7761,8 @@ else + + /* Test by Jim Wilson and Kaveh Ghazi. + Check whether strncmp reads past the end of its string parameters. */ ++#include ++#include + #include + + #ifdef HAVE_FCNTL_H +@@ -7783,7 +7790,8 @@ else + + #define MAP_LEN 0x10000 + +-main () ++int ++main (void) + { + #if defined(HAVE_MMAP) || defined(HAVE_MMAP_ANYWHERE) + char *p; +diff -rup binutils.orig/gas/acinclude.m4 binutils-2.39/gas/acinclude.m4 +--- binutils.orig/gas/acinclude.m4 2022-11-23 14:56:11.793442492 +0000 ++++ binutils-2.39/gas/acinclude.m4 2022-11-23 14:59:17.778057190 +0000 +@@ -23,6 +23,7 @@ AC_DEFUN([GAS_WORKING_ASSERT], + [AC_MSG_CHECKING([for working assert macro]) + AC_CACHE_VAL(gas_cv_assert_ok, + AC_TRY_LINK([#include ++#include + #include ], [ + /* check for requoting problems */ + static int a, b, c, d; +diff -rup binutils.orig/gas/configure binutils-2.39/gas/configure +--- binutils.orig/gas/configure 2022-11-23 14:56:12.402441231 +0000 ++++ binutils-2.39/gas/configure 2022-11-23 14:59:37.266016817 +0000 +@@ -13758,6 +13758,7 @@ else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + #include ++#include + #include + int + main () diff --git a/binutils-package-metadata.patch b/binutils-package-metadata.patch new file mode 100644 index 0000000000000000000000000000000000000000..d2925b0546f624c9842a3f266eeee50b177990b3 --- /dev/null +++ b/binutils-package-metadata.patch @@ -0,0 +1,197 @@ +diff -rup binutils.orig/gold/Makefile.am binutils-2.38/gold/Makefile.am +--- binutils.orig/gold/Makefile.am 2022-08-04 11:11:01.788495165 +0100 ++++ binutils-2.38/gold/Makefile.am 2022-08-04 11:12:26.124013955 +0100 +@@ -35,7 +35,7 @@ THREADFLAGS = @PTHREAD_CFLAGS@ + THREADLIBS = @PTHREAD_LIBS@ + + AM_CFLAGS = $(WARN_CFLAGS) $(LFS_CFLAGS) $(RANDOM_SEED_CFLAGS) $(ZLIBINC) $(THREADFLAGS) +-AM_CXXFLAGS = $(WARN_CXXFLAGS) $(LFS_CFLAGS) $(RANDOM_SEED_CFLAGS) $(ZLIBINC) $(THREADFLAGS) ++AM_CXXFLAGS = $(WARN_CXXFLAGS) $(LFS_CFLAGS) $(RANDOM_SEED_CFLAGS) $(ZLIBINC) $(THREADFLAGS) $(JANSSON_CFLAGS) + AM_LDFLAGS = $(THREADFLAGS) + + AM_CPPFLAGS = \ +@@ -187,7 +187,7 @@ libgold_a_LIBADD = $(LIBOBJS) + sources_var = main.cc + deps_var = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(LIBINTL_DEP) + ldadd_var = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(GOLD_LDADD) $(LIBINTL) \ +- $(THREADLIBS) $(LIBDL) $(ZLIB) ++ $(THREADLIBS) $(LIBDL) $(ZLIB) $(JANSSON_LIBS) + ldflags_var = $(GOLD_LDFLAGS) + + ld_new_SOURCES = $(sources_var) +@@ -201,12 +201,12 @@ incremental_dump_SOURCES = incremental-d + incremental_dump_DEPENDENCIES = $(TARGETOBJS) libgold.a $(LIBIBERTY) \ + $(LIBINTL_DEP) + incremental_dump_LDADD = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(LIBINTL) \ +- $(THREADLIBS) $(LIBDL) $(ZLIB) ++ $(THREADLIBS) $(LIBDL) $(ZLIB) $(JANSSON_LIBS) + + dwp_SOURCES = dwp.cc + dwp_DEPENDENCIES = libgold.a $(LIBIBERTY) $(LIBINTL_DEP) + dwp_LDADD = libgold.a $(LIBIBERTY) $(GOLD_LDADD) $(LIBINTL) $(THREADLIBS) \ +- $(LIBDL) $(ZLIB) ++ $(LIBDL) $(ZLIB) $(JANSSON_LIBS) + dwp_LDFLAGS = $(GOLD_LDFLAGS) + + CONFIG_STATUS_DEPENDENCIES = $(srcdir)/../bfd/development.sh +diff -rup binutils.orig/gold/configure.ac binutils-2.38/gold/configure.ac +--- binutils.orig/gold/configure.ac 2022-08-04 11:11:01.783495194 +0100 ++++ binutils-2.38/gold/configure.ac 2022-08-04 11:12:26.124013955 +0100 +@@ -591,6 +591,32 @@ if test "$threads" = "yes"; then + fi + AM_CONDITIONAL(THREADS, test "$threads" = "yes") + ++# Used to validate --package-metadata= input. Disabled by default. ++AC_ARG_ENABLE([jansson], ++ [AS_HELP_STRING([--enable-jansson], ++ [enable jansson [default=no]])], ++ [enable_jansson=$enableval], ++ [enable_jansson="no"]) ++ ++if test "x$enable_jansson" != "xno"; then ++ PKG_PROG_PKG_CONFIG ++ AS_IF([test -n "$PKG_CONFIG"], ++ [ ++ PKG_CHECK_MODULES(JANSSON, [jansson], ++ [ ++ AC_DEFINE(HAVE_JANSSON, 1, [The jansson library is to be used]) ++ AC_SUBST([JANSSON_CFLAGS]) ++ AC_SUBST([JANSSON_LIBS]) ++ ], ++ [ ++ AC_MSG_ERROR([Cannot find jansson library]) ++ ]) ++ ], ++ [ ++ AC_MSG_ERROR([Cannot find pkg-config]) ++ ]) ++fi ++ + dnl We have to check these in C, not C++, because autoconf generates + dnl tests which have no type information, and current glibc provides + dnl multiple declarations of functions like basename when compiling +diff -rup binutils.orig/gold/layout.cc binutils-2.38/gold/layout.cc +--- binutils.orig/gold/layout.cc 2022-08-04 11:11:01.783495194 +0100 ++++ binutils-2.38/gold/layout.cc 2022-08-04 11:12:26.125013949 +0100 +@@ -38,6 +38,9 @@ + #include + #include + #endif ++#ifdef HAVE_JANSSON ++#include ++#endif + + #include "parameters.h" + #include "options.h" +@@ -2439,6 +2442,7 @@ Layout::create_notes() + this->create_gold_note(); + this->create_stack_segment(); + this->create_build_id(); ++ this->create_package_metadata(); + } + + // Create the dynamic sections which are needed before we read the +@@ -3536,6 +3540,52 @@ Layout::create_build_id() + } + } + ++// If --package-metadata was used, set up the package metadata note. ++// https://systemd.io/ELF_PACKAGE_METADATA/ ++ ++void ++Layout::create_package_metadata() ++{ ++ if (!parameters->options().user_set_package_metadata()) ++ return; ++ ++ const char* desc = parameters->options().package_metadata(); ++ if (strcmp(desc, "") == 0) ++ return; ++ ++#ifdef HAVE_JANSSON ++ json_error_t json_error; ++ json_t *json = json_loads(desc, 0, &json_error); ++ if (json) ++ json_decref(json); ++ else ++ { ++ gold_fatal(_("error: --package-metadata=%s does not contain valid " ++ "JSON: %s\n"), ++ desc, json_error.text); ++ } ++#endif ++ ++ // Create the note. ++ size_t trailing_padding; ++ // Ensure the trailing NULL byte is always included, as per specification. ++ size_t descsz = strlen(desc) + 1; ++ Output_section* os = this->create_note("FDO", elfcpp::FDO_PACKAGING_METADATA, ++ ".note.package", descsz, true, ++ &trailing_padding); ++ if (os == NULL) ++ return; ++ ++ Output_section_data* posd = new Output_data_const(desc, descsz, 4); ++ os->add_output_section_data(posd); ++ ++ if (trailing_padding != 0) ++ { ++ posd = new Output_data_zero_fill(trailing_padding, 0); ++ os->add_output_section_data(posd); ++ } ++} ++ + // If we have both .stabXX and .stabXXstr sections, then the sh_link + // field of the former should point to the latter. I'm not sure who + // started this, but the GNU linker does it, and some tools depend +diff -rup binutils.orig/gold/layout.h binutils-2.38/gold/layout.h +--- binutils.orig/gold/layout.h 2022-08-04 11:11:01.788495165 +0100 ++++ binutils-2.38/gold/layout.h 2022-08-04 11:12:26.125013949 +0100 +@@ -1107,6 +1107,10 @@ class Layout + void + create_build_id(); + ++ // Create a package metadata note if needed. ++ void ++ create_package_metadata(); ++ + // Link .stab and .stabstr sections. + void + link_stabs_sections(); +@@ -1453,6 +1457,8 @@ class Layout + Gdb_index* gdb_index_data_; + // The space for the build ID checksum if there is one. + Output_section_data* build_id_note_; ++ // The space for the package metadata JSON if there is one. ++ Output_section_data* package_metadata_note_; + // The output section containing dwarf abbreviations + Output_reduced_debug_abbrev_section* debug_abbrev_; + // The output section containing the dwarf debug info tree +diff -rup binutils.orig/gold/options.h binutils-2.38/gold/options.h +--- binutils.orig/gold/options.h 2022-08-04 11:11:01.785495182 +0100 ++++ binutils-2.38/gold/options.h 2022-08-04 11:12:26.125013949 +0100 +@@ -1102,6 +1102,10 @@ class General_options + DEFINE_bool(p, options::ONE_DASH, 'p', false, + N_("Ignored for ARM compatibility"), NULL); + ++ DEFINE_optional_string(package_metadata, options::TWO_DASHES, '\0', NULL, ++ N_("Generate package metadata note"), ++ N_("[=JSON]")); ++ + DEFINE_bool(pie, options::ONE_DASH, '\0', false, + N_("Create a position independent executable"), + N_("Do not create a position independent executable")); +diff -rup binutils.orig/elfcpp/elfcpp.h binutils-2.38/elfcpp/elfcpp.h +--- binutils.orig/elfcpp/elfcpp.h 2022-08-04 11:11:00.940500003 +0100 ++++ binutils-2.38/elfcpp/elfcpp.h 2022-08-04 11:12:26.124013955 +0100 +@@ -999,7 +999,9 @@ enum + // string. + NT_GNU_GOLD_VERSION = 4, + // Program property note, as described in "Linux Extensions to the gABI". +- NT_GNU_PROPERTY_TYPE_0 = 5 ++ NT_GNU_PROPERTY_TYPE_0 = 5, ++ // FDO .note.package notes as defined on https://systemd.io/ELF_PACKAGE_METADATA/ ++ FDO_PACKAGING_METADATA = 0xcafe1a7e + }; + + // The OS values which may appear in word 0 of a NT_GNU_ABI_TAG note. diff --git a/binutils-readelf-no-sections.patch b/binutils-readelf-no-sections.patch new file mode 100644 index 0000000000000000000000000000000000000000..728d9c0d76b54201666058be0a2eb07026b3d5d6 --- /dev/null +++ b/binutils-readelf-no-sections.patch @@ -0,0 +1,29 @@ +--- binutils.orig/binutils/readelf.c 2022-10-03 13:20:42.707527855 +0100 ++++ binutils-2.39/binutils/readelf.c 2022-10-03 13:21:25.785436781 +0100 +@@ -6357,6 +6357,13 @@ get_32bit_section_headers (Filedata * fi + /* PR binutils/17531: Cope with unexpected section header sizes. */ + if (size == 0 || num == 0) + return false; ++ ++ /* The section header cannot be at the start of the file - that is ++ where the ELF file header is located. A file with absolutely no ++ sections in it will use a shoff of 0. */ ++ if (filedata->file_header.e_shoff == 0) ++ return false; ++ + if (size < sizeof * shdrs) + { + if (! probe) +@@ -6421,6 +6428,12 @@ get_64bit_section_headers (Filedata * fi + if (size == 0 || num == 0) + return false; + ++ /* The section header cannot be at the start of the file - that is ++ where the ELF file header is located. A file with absolutely no ++ sections in it will use a shoff of 0. */ ++ if (filedata->file_header.e_shoff == 0) ++ return false; ++ + if (size < sizeof * shdrs) + { + if (! probe) diff --git a/binutils-section-type.patch b/binutils-section-type.patch deleted file mode 100644 index b8ebfa7abb1a026b7c9e2476b33ba7d88528c1b2..0000000000000000000000000000000000000000 --- a/binutils-section-type.patch +++ /dev/null @@ -1,369 +0,0 @@ -diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h -index 3b2a4f49a9b..78a0a1dea42 100644 ---- a/bfd/bfd-in2.h -+++ b/bfd/bfd-in2.h -@@ -1170,6 +1170,9 @@ typedef struct bfd_section - This is used when support for non-contiguous memory regions is enabled. */ - struct bfd_section *already_assigned; - -+ /* Explicitly specified section type, if non-zero. */ -+ unsigned int type; -+ - } asection; - - /* Relax table contains information about instructions which can -@@ -1352,8 +1355,8 @@ discarded_section (const asection *sec) - /* symbol, symbol_ptr_ptr, */ \ - (struct bfd_symbol *) SYM, &SEC.symbol, \ - \ -- /* map_head, map_tail, already_assigned */ \ -- { NULL }, { NULL }, NULL \ -+ /* map_head, map_tail, already_assigned, type */ \ -+ { NULL }, { NULL }, NULL, 0 \ - \ - } - -diff --git a/bfd/elf.c b/bfd/elf.c -index a67415e76e1..82b53be99f9 100644 ---- a/bfd/elf.c -+++ b/bfd/elf.c -@@ -3280,7 +3280,9 @@ elf_fake_sections (bfd *abfd, asection *asect, void *fsarg) - - /* If the section type is unspecified, we set it based on - asect->flags. */ -- if ((asect->flags & SEC_GROUP) != 0) -+ if (asect->type != 0) -+ sh_type = asect->type; -+ else if ((asect->flags & SEC_GROUP) != 0) - sh_type = SHT_GROUP; - else - sh_type = bfd_elf_get_default_section_type (asect->flags); -diff --git a/bfd/section.c b/bfd/section.c -index 899438a1c5e..2de7dbf661a 100644 ---- a/bfd/section.c -+++ b/bfd/section.c -@@ -737,8 +737,8 @@ CODE_FRAGMENT - . {* symbol, symbol_ptr_ptr, *} \ - . (struct bfd_symbol *) SYM, &SEC.symbol, \ - . \ --. {* map_head, map_tail, already_assigned *} \ --. { NULL }, { NULL }, NULL \ -+. {* map_head, map_tail, already_assigned, type *} \ -+. { NULL }, { NULL }, NULL, 0 \ - . \ - . } - . -diff --git a/ld/NEWS b/ld/NEWS -index dbb402d1f8a..a498abaf0f9 100644 ---- a/ld/NEWS -+++ b/ld/NEWS -@@ -1,5 +1,8 @@ - -*- text -*- - -+* TYPE= is now supported in an output section description to set the -+ section type value. -+ - Changes in 2.38: - - * Add -z pack-relative-relocs/-z no pack-relative-relocs to x86 ELF -diff --git a/ld/ld.texi b/ld/ld.texi -index fc75e9b3625..d57e9221410 100644 ---- a/ld/ld.texi -+++ b/ld/ld.texi -@@ -5483,13 +5483,23 @@ loaded into memory when the program is run. - @item READONLY - The section should be marked as read-only. - @item DSECT --@itemx COPY --@itemx INFO --@itemx OVERLAY -+@item COPY -+@item INFO -+@item OVERLAY - These type names are supported for backward compatibility, and are - rarely used. They all have the same effect: the section should be - marked as not allocatable, so that no memory is allocated for the - section when the program is run. -+@item TYPE = @var{type} -+Set the section type to the integer @var{type}. When generating an ELF -+output file, type names @code{SHT_PROGBITS}, @code{SHT_STRTAB}, -+@code{SHT_NOTE}, @code {SHT_NOBITS}, @code{SHT_INIT_ARRAY}, -+@code{SHT_FINI_ARRAY}, and @code{SHT_PREINIT_ARRAY} are also allowed -+for @var{type}. It is the user's responsibility to ensure that any -+special requirements of the section type are met. -+@item READONLY ( TYPE = @var{type} ) -+This form of the syntax combines the @var{READONLY} type with the -+type specified by @var{type}. - @end table - - @kindex NOLOAD -diff --git a/ld/ldgram.y b/ld/ldgram.y -index 11c2f219c05..3a904e39482 100644 ---- a/ld/ldgram.y -+++ b/ld/ldgram.y -@@ -47,6 +47,7 @@ - #endif - - static enum section_type sectype; -+static etree_type *sectype_value; - static lang_memory_region_type *region; - - static bool ldgram_had_keep = false; -@@ -139,6 +140,7 @@ static int error_index; - %token LD_FEATURE - %token NOLOAD DSECT COPY INFO OVERLAY - %token READONLY -+%token TYPE - %token DEFINED TARGET_K SEARCH_DIR MAP ENTRY - %token NEXT - %token SIZEOF ALIGNOF ADDR LOADADDR MAX_K MIN_K -@@ -1058,9 +1060,8 @@ section: NAME - { - ldlex_popstate (); - ldlex_wild (); -- lang_enter_output_section_statement($1, $3, sectype, -- $5, $7, $4, -- $8, $6); -+ lang_enter_output_section_statement ($1, $3, sectype, -+ sectype_value, $5, $7, $4, $8, $6); - } - '{' - statement_list_opt -@@ -1130,8 +1131,10 @@ type: - | COPY { sectype = noalloc_section; } - | INFO { sectype = noalloc_section; } - | OVERLAY { sectype = noalloc_section; } -+ | READONLY '(' TYPE '=' exp ')' { sectype = typed_readonly_section; sectype_value = $5; } - | READONLY { sectype = readonly_section; } -- ; -+ | TYPE '=' exp { sectype = type_section; sectype_value = $3; } -+ ; - - atype: - '(' type ')' -diff --git a/ld/ldlang.c b/ld/ldlang.c -index 474784c874a..1733f8e65c4 100644 ---- a/ld/ldlang.c -+++ b/ld/ldlang.c -@@ -1891,8 +1891,8 @@ lang_insert_orphan (asection *s, - address = exp_intop (0); - - os_tail = (lang_output_section_statement_type **) lang_os_list.tail; -- os = lang_enter_output_section_statement (secname, address, normal_section, -- NULL, NULL, NULL, constraint, 0); -+ os = lang_enter_output_section_statement ( -+ secname, address, normal_section, 0, NULL, NULL, NULL, constraint, 0); - - if (add_child == NULL) - add_child = &os->children; -@@ -2635,10 +2635,12 @@ lang_add_section (lang_statement_list_type *ptr, - case normal_section: - case overlay_section: - case first_overlay_section: -+ case type_section: - break; - case noalloc_section: - flags &= ~SEC_ALLOC; - break; -+ case typed_readonly_section: - case readonly_section: - flags |= SEC_READONLY; - break; -@@ -4209,6 +4211,7 @@ map_input_to_output_sections - { - lang_output_section_statement_type *tos; - flagword flags; -+ unsigned int type = 0; - - switch (s->header.type) - { -@@ -4264,6 +4267,42 @@ map_input_to_output_sections - case readonly_section: - flags |= SEC_READONLY; - break; -+ case typed_readonly_section: -+ flags |= SEC_READONLY; -+ /* Fall through. */ -+ case type_section: -+ if (os->sectype_value->type.node_class == etree_name -+ && os->sectype_value->type.node_code == NAME) -+ { -+ const char *name = os->sectype_value->name.name; -+ if (strcmp (name, "SHT_PROGBITS") == 0) -+ type = SHT_PROGBITS; -+ else if (strcmp (name, "SHT_STRTAB") == 0) -+ type = SHT_STRTAB; -+ else if (strcmp (name, "SHT_NOTE") == 0) -+ type = SHT_NOTE; -+ else if (strcmp (name, "SHT_NOBITS") == 0) -+ type = SHT_NOBITS; -+ else if (strcmp (name, "SHT_INIT_ARRAY") == 0) -+ type = SHT_INIT_ARRAY; -+ else if (strcmp (name, "SHT_FINI_ARRAY") == 0) -+ type = SHT_FINI_ARRAY; -+ else if (strcmp (name, "SHT_PREINIT_ARRAY") == 0) -+ type = SHT_PREINIT_ARRAY; -+ else -+ einfo (_ ("%F%P: invalid type for output section `%s'\n"), -+ os->name); -+ } -+ else -+ { -+ exp_fold_tree_no_dot (os->sectype_value); -+ if (expld.result.valid_p) -+ type = expld.result.value; -+ else -+ einfo (_ ("%F%P: invalid type for output section `%s'\n"), -+ os->name); -+ } -+ break; - case noload_section: - if (bfd_get_flavour (link_info.output_bfd) - == bfd_target_elf_flavour) -@@ -4276,6 +4315,7 @@ map_input_to_output_sections - init_os (os, flags | SEC_READONLY); - else - os->bfd_section->flags |= flags; -+ os->bfd_section->type = type; - break; - case lang_input_section_enum: - break; -@@ -7506,6 +7546,7 @@ lang_output_section_statement_type * - lang_enter_output_section_statement (const char *output_section_statement_name, - etree_type *address_exp, - enum section_type sectype, -+ etree_type *sectype_value, - etree_type *align, - etree_type *subalign, - etree_type *ebase, -@@ -7523,10 +7564,12 @@ lang_enter_output_section_statement (const char *output_section_statement_name, - os->addr_tree = address_exp; - } - os->sectype = sectype; -- if (sectype != noload_section) -- os->flags = SEC_NO_FLAGS; -- else -+ if (sectype == type_section || sectype == typed_readonly_section) -+ os->sectype_value = sectype_value; -+ else if (sectype == noload_section) - os->flags = SEC_NEVER_LOAD; -+ else -+ os->flags = SEC_NO_FLAGS; - os->block_value = 1; - - /* Make next things chain into subchain of this. */ -@@ -8842,7 +8885,7 @@ lang_enter_overlay_section (const char *name) - etree_type *size; - - lang_enter_output_section_statement (name, overlay_vma, overlay_section, -- 0, overlay_subalign, 0, 0, 0); -+ 0, 0, overlay_subalign, 0, 0, 0); - - /* If this is the first section, then base the VMA of future - sections on this one. This will work correctly even if `.' is -diff --git a/ld/ldlang.h b/ld/ldlang.h -index 0d057c9bee9..95f6e468b30 100644 ---- a/ld/ldlang.h -+++ b/ld/ldlang.h -@@ -122,7 +122,9 @@ enum section_type - overlay_section, - noload_section, - noalloc_section, -- readonly_section -+ type_section, -+ readonly_section, -+ typed_readonly_section - }; - - /* This structure holds a list of program headers describing -@@ -166,6 +168,7 @@ typedef struct lang_output_section_statement_struct - int constraint; - flagword flags; - enum section_type sectype; -+ etree_type *sectype_value; - unsigned int processed_vma : 1; - unsigned int processed_lma : 1; - unsigned int all_input_readonly : 1; -@@ -545,7 +548,7 @@ extern void lang_add_output - (const char *, int from_script); - extern lang_output_section_statement_type *lang_enter_output_section_statement - (const char *, etree_type *, enum section_type, etree_type *, etree_type *, -- etree_type *, int, int); -+ etree_type *, etree_type *, int, int); - extern void lang_final - (void); - extern void lang_relax_sections -diff --git a/ld/ldlex.l b/ld/ldlex.l -index 78db16e3a48..c38b46b9336 100644 ---- a/ld/ldlex.l -+++ b/ld/ldlex.l -@@ -323,6 +323,7 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)* - "DSECT" { RTOKEN(DSECT); } - "COPY" { RTOKEN(COPY); } - "INFO" { RTOKEN(INFO); } -+"TYPE" { RTOKEN(TYPE); } - "ONLY_IF_RO" { RTOKEN(ONLY_IF_RO); } - "ONLY_IF_RW" { RTOKEN(ONLY_IF_RW); } - "SPECIAL" { RTOKEN(SPECIAL); } -diff --git a/ld/mri.c b/ld/mri.c -index b428ab0d0bf..5749870ef1e 100644 ---- a/ld/mri.c -+++ b/ld/mri.c -@@ -210,8 +210,8 @@ mri_draw_tree (void) - base = p->vma ? p->vma : exp_nameop (NAME, "."); - - lang_enter_output_section_statement (p->name, base, -- p->ok_to_load ? normal_section : noload_section, -- align, subalign, NULL, 0, 0); -+ p->ok_to_load ? normal_section : noload_section, 0, -+ align, subalign, NULL, 0, 0); - base = 0; - tmp = (struct wildcard_list *) xmalloc (sizeof *tmp); - tmp->next = NULL; -diff --git a/ld/testsuite/ld-scripts/output-section-types.d b/ld/testsuite/ld-scripts/output-section-types.d -index ab124fa4dd7..2ecacaba57d 100644 ---- a/ld/testsuite/ld-scripts/output-section-types.d -+++ b/ld/testsuite/ld-scripts/output-section-types.d -@@ -1,13 +1,17 @@ - #ld: -Toutput-section-types.t - #source: align2a.s --#objdump: -h -+#readelf: -S --wide - #target: [is_elf_format] - - #... -- . \.rom.* --[ ]+ALLOC, READONLY -- . \.ro.* --[ ]+CONTENTS, ALLOC, LOAD, READONLY, DATA -- . \.over.* --[ ]+CONTENTS, READONLY -+.* .rom +NOBITS +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +00 +A +0 +0 +[1248] -+.* .ro +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +00 +A +0 +0 +[1248] -+.* .over +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +00 + +0 +0 +[1248] -+.* progbits +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +00 +A +0 +0 +[1248] -+.* strtab +STRTAB +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +00 +A +0 +0 +[1248] -+.* note +NOTE +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +00 +A +0 +0 +[1248] -+.* init_array +INIT_ARRAY +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +0[48] +A +0 +0 +[1248] -+.* fini_array +FINI_ARRAY +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +0[48] +A +0 +0 +[1248] -+.* preinit_array +PREINIT_ARRAY +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +0[48] +A +0 +0 +[1248] -+.* .ro.note +NOTE +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +00 +A +0 +0 +[1248] - #pass -diff --git a/ld/testsuite/ld-scripts/output-section-types.t b/ld/testsuite/ld-scripts/output-section-types.t -index d8fdfda1a03..18fc5c11980 100644 ---- a/ld/testsuite/ld-scripts/output-section-types.t -+++ b/ld/testsuite/ld-scripts/output-section-types.t -@@ -2,6 +2,13 @@ SECTIONS { - .rom (NOLOAD) : { LONG(1234); } - .ro (READONLY) : { LONG(5678); } - .over (OVERLAY) : { LONG(0123); } -+ progbits (TYPE=SHT_PROGBITS) : { BYTE(1) } -+ strtab (TYPE = SHT_STRTAB) : { BYTE(0) } -+ note (TYPE =SHT_NOTE) : { BYTE(8) } -+ init_array (TYPE= 14) : { QUAD(14) } -+ fini_array ( TYPE=SHT_FINI_ARRAY) : { QUAD(15) } -+ preinit_array (TYPE=SHT_PREINIT_ARRAY ) : { QUAD(16) } -+ .ro.note (READONLY (TYPE=SHT_NOTE)) : { LONG(5678); } - /DISCARD/ : { *(*) } - - } diff --git a/binutils-update-linker-manual.patch b/binutils-update-linker-manual.patch new file mode 100644 index 0000000000000000000000000000000000000000..69392141c0d4b4fb09bdf3c67d48d6dc3cfc3274 --- /dev/null +++ b/binutils-update-linker-manual.patch @@ -0,0 +1,36 @@ +diff -rup binutils.orig/ld/ld.1 binutils-2.38/ld/ld.1 +--- binutils.orig/ld/ld.1 2022-05-27 10:56:44.937044892 +0100 ++++ binutils-2.38/ld/ld.1 2022-05-27 11:10:50.311802310 +0100 +@@ -2595,7 +2595,7 @@ systems may not understand them. If you + \&\fB\-\-enable\-new\-dtags\fR, the new dynamic tags will be created as needed + and older dynamic tags will be omitted. + If you specify \fB\-\-disable\-new\-dtags\fR, no new dynamic tags will be +-created. By default, the new dynamic tags are not created. Note that ++created. By default, the new dynamic tags are created. Note that + those options are only available for \s-1ELF\s0 systems. + .IP "\fB\-\-hash\-size=\fR\fInumber\fR" 4 + .IX Item "--hash-size=number" +diff -rup binutils.orig/ld/ld.info binutils-2.38/ld/ld.info +--- binutils.orig/ld/ld.info 2022-05-27 11:01:12.286346357 +0100 ++++ binutils-2.38/ld/ld.info 2022-05-27 11:11:24.585709176 +0100 +@@ -2236,7 +2236,7 @@ GNU linker: + '--enable-new-dtags', the new dynamic tags will be created as + needed and older dynamic tags will be omitted. If you specify + '--disable-new-dtags', no new dynamic tags will be created. By +- default, the new dynamic tags are not created. Note that those ++ default, the new dynamic tags are created. Note that those + options are only available for ELF systems. + + '--hash-size=NUMBER' +diff -rup binutils.orig/ld/ld.texi binutils-2.38/ld/ld.texi +--- binutils.orig/ld/ld.texi 2022-05-27 11:01:24.081314960 +0100 ++++ binutils-2.38/ld/ld.texi 2022-05-27 11:10:05.608923798 +0100 +@@ -2796,7 +2796,7 @@ systems may not understand them. If you + @option{--enable-new-dtags}, the new dynamic tags will be created as needed + and older dynamic tags will be omitted. + If you specify @option{--disable-new-dtags}, no new dynamic tags will be +-created. By default, the new dynamic tags are not created. Note that ++created. By default, the new dynamic tags are created. Note that + those options are only available for ELF systems. + + @kindex --hash-size=@var{number} diff --git a/binutils-use-long-long.patch b/binutils-use-long-long.patch deleted file mode 100644 index 1ea741811a83ca511dc0d6a76c3e0c2d951ac0d4..0000000000000000000000000000000000000000 --- a/binutils-use-long-long.patch +++ /dev/null @@ -1,38 +0,0 @@ -diff -up binutils-2.25.orig/bfd/configure.ac binutils-2.25/bfd/configure.ac ---- binutils-2.25.orig/bfd/configure.ac 2014-12-24 10:34:45.590491143 +0000 -+++ binutils-2.25/bfd/configure.ac 2014-12-24 10:36:12.997981992 +0000 -@@ -183,11 +183,13 @@ if test "x${ac_cv_sizeof_long}" = "x8"; - BFD_HOST_64BIT_LONG=1 - test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long" - test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long" --elif test "x${ac_cv_sizeof_long_long}" = "x8"; then -+fi -+if test "x${ac_cv_sizeof_long_long}" = "x8"; then - BFD_HOST_64BIT_LONG_LONG=1 - test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long long" - test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long long" -- if test "x${ac_cv_sizeof_void_p}" = "x8"; then -+ if test "x${ac_cv_sizeof_void_p}" = "x8" \ -+ -a "x${ac_cv_sizeof_long}" != "x8"; then - BFD_HOSTPTR_T="unsigned long long" - fi - fi -diff -up ../binutils-2.20.51.0.7.original/bfd/configure ./bfd/configure ---- a/bfd/configure 2010-04-08 15:23:58.000000000 +0100 -+++ b/bfd/configure 2010-04-08 15:24:06.000000000 +0100 -@@ -12819,11 +12819,13 @@ - BFD_HOST_64BIT_LONG=1 - test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long" - test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long" --elif test "x${ac_cv_sizeof_long_long}" = "x8"; then -+fi -+if test "x${ac_cv_sizeof_long_long}" = "x8"; then - BFD_HOST_64BIT_LONG_LONG=1 - test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long long" - test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long long" -- if test "x${ac_cv_sizeof_void_p}" = "x8"; then -+ if test "x${ac_cv_sizeof_void_p}" = "x8" \ -+ -a "x${ac_cv_sizeof_long}" != "x8"; then - BFD_HOSTPTR_T="unsigned long long" - fi - fi diff --git a/binutils.spec b/binutils.spec index 7763817ca2d746a407ab45f57ccb288bd367f473..71abe63a28cebe990af4be1fe2d60c4f1b5b9bdd 100644 --- a/binutils.spec +++ b/binutils.spec @@ -1,4 +1,4 @@ -%define anolis_release 3 +%define anolis_release 1 # Determine if this is a native build or a cross build. # # For a cross build add --define "binutils_target " to the command @@ -38,7 +38,7 @@ Summary: A GNU collection of binary utilities Name: binutils%{?name_cross}%{?_with_debug:-debug} -Version: 2.38 +Version: 2.39 Release: %{anolis_release}%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -120,6 +120,8 @@ URL: https://sourceware.org/binutils %bcond_without testsuite # Default: support debuginfod. %bcond_without debuginfod +# Default: build binutils-gprofng package. +%bcond_without gprofng # Use the system supplied version of the zlib compress library. # Change this to use the binutils builtin version instead. @@ -142,12 +144,18 @@ URL: https://sourceware.org/binutils %if %{with bootstrap} %undefine with_docs %undefine with_testsuite +%undefine with_gprofng %endif %if %{with debug} %undefine with_testsuite %endif +# GprofNG currenly onlly supports the x86 and AArch64 architectures. +%ifnarch x86_64 aarch64 +%undefine with_gprofng +%endif + # The opcodes library needs a few functions defined in the bfd # library, but these symbols are not defined in the stub bfd .so # that is available at link time. (They are present in the real @@ -240,7 +248,7 @@ Patch09: binutils-do-not-link-with-static-libstdc++.patch Patch10: binutils-special-sections-in-groups.patch # Purpose: Fix linker testsuite failures. -# Lifetime: Fixed in 2.37 (maybe) +# Lifetime: Fixed in 2.39 (maybe) Patch11: binutils-fix-testsuite-failures.patch # Purpose: Stop gold from aborting when input sections with the same name @@ -248,46 +256,55 @@ Patch11: binutils-fix-testsuite-failures.patch # Lifetime: Fixed in 2.38 (maybe) Patch12: binutils-gold-mismatched-section-flags.patch -# Purpose: Add a check to the GOLD linker for a corrupt input file -# with a fuzzed section offset. -# Lifetime: Fixed in 2.38 (maybe) -Patch13: binutils-CVE-2019-1010204.patch - # Purpose: Change the gold configuration script to only warn about # unsupported targets. This allows the binutils to be built with # BPF support enabled. # Lifetime: Permanent. Patch14: binutils-gold-warn-unsupported.patch -# Purpose: Use the "unsigned long long" type for pointers on hosts where -# long is a 32-bit type but pointers are a 64-bit type. Necessary -# because users expect to be able to install both the i686- and -# x86_64 versions of binutils-devel on the same machine, so they -# need to identical versions of the bfd.h header file. -# Lifetime: Permanent. -Patch15: binutils-use-long-long.patch - -# Purpose: Fix testsuite failures due to the patches applied here. -# Lifetime: Permanent, but varying with each new rebase. -Patch16: binutils-testsuite-fixes.patch - # Purpose: Enable the creation of .note.gnu.property sections by the GOLD # linker for x86 binaries. # Lifetime: Fixed in 2.38 maybe -Patch17: binutils-gold-i386-gnu-property-notes.patch +Patch15: binutils-gold-i386-gnu-property-notes.patch # Purpose: Allow the binutils to be configured with any (recent) version of # autoconf. # Lifetime: Fixed in 2.39 (maybe ?) -Patch18: binutils-autoconf-version.patch +Patch16: binutils-autoconf-version.patch # Purpose: Stop libtool from inserting useless runpaths into binaries. # Lifetime: Who knows. -Patch19: gcc12-libtool-no-rpath.patch +Patch17: gcc12-libtool-no-rpath.patch -# Purpose: Add support for specifying section types in linker scripts. -# Lifetime: Fixed in 2.39 -Patch20: binutils-section-type.patch +%if %{enable_new_dtags} +# Purpose: Change ld man page so that it says that --enable-new-dtags is the default. +# Lifetime: Permanent +Patch18: binutils-update-linker-manual.patch +%endif + +# Purpose: Add a --package-metadata option to the linkers. +# Lifetime: Fixed in 2.40 +Patch19: binutils-package-metadata.patch + +# Purpose: Stop the assembler from generating DIE information for zero-sized functions. +# Lifetime: Fixed in 2.40 +Patch20: binutils-gas-dwarf-skip-empty-functions.patch + +# Purpose: Stop an infinite loop in the binutils DWARF decoder. (CVE 2022-38128) +# Lifetime: Fixed in 2.40 +Patch21: binutils-CVE-38128-dwarf-abbrev-parsing.patch + +# Purpose: Stop readelf from incorrectly decoding ELF files with no sections. +# Lifetime: Fixed in 2.40 +Patch22: binutils-readelf-no-sections.patch + +# Purpose: Stop compile time warnings from configure test files in the libiberty directory. +# Lifetime: Fixed in 2.40 +Patch23: binutils-libiberty-configure-compile-warnings.patch + +# Purpose: Fix a potential reference of a NULL pointer. +# Lifetime: Fixed in 2.40 +Patch24: binutils-CVE-2022-4285.patch #---------------------------------------------------------------------------- @@ -325,7 +342,7 @@ BuildRequires: gcc %endif %if %{without bootstrap} -BuildRequires: gettext, flex, zlib-devel +BuildRequires: gettext, flex, zlib-devel, jansson-devel %endif %if %{with docs} @@ -442,6 +459,21 @@ Conflicts: gcc-c++ < 4.0.0 %{!?ld_bfd_priority: %global ld_bfd_priority 50} +#---------------------------------------------------------------------------- + +%if %{with gprofng} + +%package gprofng +Summary: Next Generating code profiling tool +Provides: gprofng = %{version}-%{release} +Requires: binutils >= %{version} +Conflicts: binutils < 2.39 + +%description gprofng +Gprofng is the GNU Next Generation profiler for analyzing the performance +of Linux applications. Gprofng allows you to: +%endif + #---------------------------------------------------------------------------- %prep @@ -559,6 +591,11 @@ CARGS="$CARGS --enable-targets=x86_64-pep,bpf-unknown-none" %if %{with systemzlib} --with-system-zlib \ %endif +%if %{with gprofng} + --enable-gprofng=yes \ +%else + --enable-gprofng=no \ +%endif %if %{enable_shared} --enable-shared \ %else @@ -593,6 +630,9 @@ CARGS="$CARGS --enable-targets=x86_64-pep,bpf-unknown-none" %endif %if %{enable_separate_code} --enable-separate-code=yes \ +%endif +%if %{without bootstrap} + --enable-jansson=yes \ %endif $CARGS \ --enable-plugins \ @@ -695,9 +735,6 @@ chmod +x %{buildroot}%{_libdir}/lib*.so* # dynamically, as they are changed far too often. rm -f %{buildroot}%{_libdir}/lib{bfd,opcodes}.so -# Remove libtool files, which reference the .so libs -rm -f %{buildroot}%{_libdir}/*.la - # Fix multilib conflicts of generated values by __WORDSIZE-based expressions. %ifarch x86_64 # Sanity check --enable-64-bit-bfd really works. @@ -749,12 +786,9 @@ rm -rf %{buildroot}%{_infodir} #rm -rf {buildroot}{_prefix}/share/locale #rm -rf {buildroot}{_mandir} rm -rf %{buildroot}%{_libdir}/libiberty.a -# Remove libtool files, which reference the .so libs -rm -f %{buildroot}%{_libdir}/*.la %endif # This one comes from gcc -rm -f %{buildroot}%{_infodir}/dir rm -rf %{buildroot}%{_prefix}/%{binutils_target} %find_lang %{?cross}binutils @@ -794,10 +828,6 @@ fi # Do not run "alternatives --auto ld" here. Leave the setting to # however the user previously had it set. See BZ 1592069 for more details. -%if %{isnative} -%ldconfig_post -%endif - exit 0 #---------------------------------------------------------------------------- @@ -816,17 +846,12 @@ exit 0 #---------------------------------------------------------------------------- -%if %{isnative} -%postun -%ldconfig_postun -%endif - -#---------------------------------------------------------------------------- - %files -f %{?cross}binutils.lang %dir %{abidir} %license COPYING COPYING3 COPYING3.LIB COPYING.LIB %{_bindir}/%{?cross}[!l]* +%exclude %{_bindir}/gp-* +%exclude %{_bindir}/gprofng # %%verify(symlink) does not work for some reason, so using "owner" instead. %verify(owner) %{_bindir}/%{?cross}ld %{_bindir}/%{?cross}ld.bfd @@ -835,7 +860,9 @@ exit 0 %{abidir}/%{?cross}ld.bfd-option.list %if %{with docs} -%{_mandir}/man1/ +%{_mandir}/man1/* +%exclude %{_mandir}/man1/gp-* +%exclude %{_mandir}/man1/gprofng* %if %{isnative} %{_infodir}/as.info.* %{_infodir}/binutils.info.* @@ -874,10 +901,28 @@ exit 0 %{abidir}/%{?cross}ld.gold-option.list %endif +%if %{with gprofng} +%files gprofng +%{_bindir}/gp-* +%{_bindir}/gprofng +%{_mandir}/man1/gp-* +%{_mandir}/man1/gprofng* +%{_infodir}/gprofng.info.* +%dir %{_libdir}/gprofng +%{_libdir}/gprofng/* +%{abidir}/libgp*.dump +%dir %{_exec_prefix}/lib/debug/%{_libdir}/gprofng +%{_exec_prefix}/lib/debug/%{_libdir}/gprofng/libgp* +%{_sysconfdir}/gprofng.rc +%endif + %files doc %doc README %changelog +* Tue Dec 20 2022 Funda Wang - 2.39-1 +- New version 2.39 + * Tue Nov 01 2022 mgb01105731 - 2.38-3 - optimise spec file & add doc package