From 3cf7cfba6fbb28cc26623121e744c47b3ccd0575 Mon Sep 17 00:00:00 2001 From: liyancheng <412998149@qq.com> Date: Fri, 15 Apr 2022 10:31:01 +0800 Subject: [PATCH] [Sync] Synchronize commits from openEuler-22.03-LTS commit ac65d1c3346cb23ce4898965a4e3d3d2bba4378a fix (obs) project build fail commit 508b3a2dc0b2da6d2e7e95a341647f9098dd8db6 add binutils-extra commit be2f62e1a4996596ab2daa6950a8d3e3228b895e Fix the "malformed archive" issue when building nodejs commit e77873c5c2598a013374081ed44afb5f0bf78e69 Fix CVE-2021-42574 --- backport-0001-CVE-2021-42574.patch | 66 +++-- backport-0002-CVE-2021-42574.patch | 13 +- ...le-descriptor-if-there-is-no-archive.patch | 234 ++++++++++++++++++ binutils.spec | 54 +++- 4 files changed, 327 insertions(+), 40 deletions(-) create mode 100644 bfd-Close-the-file-descriptor-if-there-is-no-archive.patch diff --git a/backport-0001-CVE-2021-42574.patch b/backport-0001-CVE-2021-42574.patch index f94a958..34a7350 100644 --- a/backport-0001-CVE-2021-42574.patch +++ b/backport-0001-CVE-2021-42574.patch @@ -8,24 +8,24 @@ Subject: [PATCH] Add --unicode option to control how unicode characters are handled. * objdump.c: Likewise. * readelf.c: Likewise. - * strings.c: Likewise. - * binutils.texi: Document the new feature. - * NEWS: Document the new feature. - * testsuite/binutils-all/unicode.exp: New file. - * testsuite/binutils-all/nm.hex.unicode - * testsuite/binutils-all/strings.escape.unicode - * testsuite/binutils-all/objdump.highlight.unicode - * testsuite/binutils-all/readelf.invalid.unicode - + * strings.c: Likewise. + * binutils.texi: Document the new feature. + * NEWS: Document the new feature. + * testsuite/binutils-all/unicode.exp: New file. + * testsuite/binutils-all/nm.hex.unicode + * testsuite/binutils-all/strings.escape.unicode + * testsuite/binutils-all/objdump.highlight.unicode + * testsuite/binutils-all/readelf.invalid.unicode + Conflict:Context adaptation --- binutils/NEWS | 9 + binutils/doc/binutils.texi | 78 +++++ binutils/nm.c | 228 +++++++++++++- - binutils/objdump.c | 218 ++++++++++++- + binutils/objdump.c | 235 ++++++++++++-- binutils/readelf.c | 190 +++++++++++- binutils/strings.c | 757 +++++++++++++++++++++++++++++++++++++++++---- - 6 files changed, 1392 insertions(+), 88 deletions(-) + 6 files changed, 1394 insertions(+), 103 deletions(-) diff --git a/binutils/NEWS b/binutils/NEWS index 8a73387..db9114e 100644 @@ -487,7 +487,7 @@ index 82ccec6..3f8abfc 100644 show_version = 1; break; diff --git a/binutils/objdump.c b/binutils/objdump.c -index a7b8303..bb5e247 100644 +index a7b8303..149b702 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -204,6 +204,18 @@ static const struct objdump_private_desc * const objdump_private_vectors[] = @@ -574,15 +574,39 @@ index a7b8303..bb5e247 100644 {"reloc", no_argument, NULL, 'r'}, {"section", required_argument, NULL, 'j'}, {"section-headers", no_argument, NULL, 'h'}, -@@ -468,6 +496,7 @@ static struct option long_options[]= +@@ -457,28 +485,16 @@ static struct option long_options[]= + {"source", no_argument, NULL, 'S'}, + {"source-comment", optional_argument, NULL, OPTION_SOURCE_COMMENT}, + {"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}, {"syms", no_argument, NULL, 't'}, {"target", required_argument, NULL, 'b'}, + {"unicode", required_argument, NULL, 'U'}, {"version", no_argument, NULL, 'V'}, - {"wide", no_argument, NULL, 'w'}, - {"prefix", required_argument, NULL, OPTION_PREFIX}, -@@ -488,9 +517,121 @@ nonfatal (const char *msg) +- {"wide", no_argument, NULL, 'w'}, +- {"prefix", required_argument, NULL, OPTION_PREFIX}, +- {"prefix-strip", required_argument, NULL, OPTION_PREFIX_STRIP}, +- {"insn-width", required_argument, NULL, OPTION_INSN_WIDTH}, +- {"dwarf-depth", required_argument, 0, OPTION_DWARF_DEPTH}, +- {"dwarf-start", required_argument, 0, OPTION_DWARF_START}, +- {"dwarf-check", no_argument, 0, OPTION_DWARF_CHECK}, +- {"inlines", no_argument, 0, OPTION_INLINES}, + {"visualize-jumps", optional_argument, 0, OPTION_VISUALIZE_JUMPS}, +- {0, no_argument, 0, 0} ++ {"wide", no_argument, NULL, 'w'}, ++ {NULL, no_argument, NULL, 0} + }; + + static void +@@ -488,9 +504,121 @@ nonfatal (const char *msg) exit_status = 1; } @@ -705,7 +729,7 @@ index a7b8303..bb5e247 100644 static const char * sanitize_string (const char * in) -@@ -508,40 +649,50 @@ sanitize_string (const char * in) +@@ -508,40 +636,50 @@ sanitize_string (const char * in) of cases it will not be needed. */ do { @@ -763,7 +787,7 @@ index a7b8303..bb5e247 100644 } while (1); -@@ -4529,6 +4680,24 @@ dump_symbols (bfd *abfd ATTRIBUTE_UNUSED, bool dynamic) +@@ -4529,6 +4667,24 @@ dump_symbols (bfd *abfd ATTRIBUTE_UNUSED, bool dynamic) free (alloc); } } @@ -788,7 +812,7 @@ index a7b8303..bb5e247 100644 else bfd_print_symbol (cur_bfd, stdout, *current, bfd_print_symbol_all); -@@ -5212,7 +5381,7 @@ main (int argc, char **argv) +@@ -5212,7 +5368,7 @@ main (int argc, char **argv) set_default_bfd_target (); while ((c = getopt_long (argc, argv, @@ -797,7 +821,7 @@ index a7b8303..bb5e247 100644 long_options, (int *) 0)) != EOF) { -@@ -5495,6 +5664,23 @@ main (int argc, char **argv) +@@ -5495,6 +5651,23 @@ main (int argc, char **argv) seenflag = true; break; @@ -1067,7 +1091,7 @@ index a6073f7..dd8660c 100644 sym_base = 0; if (optarg != NULL) diff --git a/binutils/strings.c b/binutils/strings.c -index 44a8e1d..f50badf 100644 +index 44a8e1d..e8649a8 100644 --- a/binutils/strings.c +++ b/binutils/strings.c @@ -55,6 +55,19 @@ diff --git a/backport-0002-CVE-2021-42574.patch b/backport-0002-CVE-2021-42574.patch index 8ef5dd6..aad70c2 100644 --- a/backport-0002-CVE-2021-42574.patch +++ b/backport-0002-CVE-2021-42574.patch @@ -13,18 +13,16 @@ within binutils (besides zlib) and AFAIK it isn't a standard type. (print_unicode_stream_body, print_unicode_stream): Likewise. (print_strings): Likewise. (get_unicode_byte): Wrap long line. - -Conflict:Context adaptation --- binutils/readelf.c | 4 ++-- binutils/strings.c | 41 ++++++++++++++++++++++------------------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/binutils/readelf.c b/binutils/readelf.c -index dd8660c..cc9023a 100644 +index c71d542f051b..5a87728d3e98 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c -@@ -678,7 +678,7 @@ print_symbol (signed int width, const char * symbol) +@@ -702,7 +702,7 @@ print_symbol (signed int width, const char * symbol) /* Display unicode characters as something else. */ unsigned char bytes[4]; bool is_utf8; @@ -33,7 +31,7 @@ index dd8660c..cc9023a 100644 bytes[0] = c; -@@ -743,7 +743,7 @@ print_symbol (signed int width, const char * symbol) +@@ -767,7 +767,7 @@ print_symbol (signed int width, const char * symbol) if (unicode_display == unicode_hex || ! is_utf8) { @@ -43,7 +41,7 @@ index dd8660c..cc9023a 100644 if (width_remaining < (nbytes * 2) + 2) break; diff --git a/binutils/strings.c b/binutils/strings.c -index f50badf..e7dd534 100644 +index e8649a80d6a7..13db60f57a57 100644 --- a/binutils/strings.c +++ b/binutils/strings.c @@ -57,7 +57,7 @@ @@ -194,6 +192,3 @@ index f50badf..e7dd534 100644 long c; /* See if the next `string_min' chars are all graphic chars. */ --- -1.8.3.1 - diff --git a/bfd-Close-the-file-descriptor-if-there-is-no-archive.patch b/bfd-Close-the-file-descriptor-if-there-is-no-archive.patch new file mode 100644 index 0000000..c5bb8d3 --- /dev/null +++ b/bfd-Close-the-file-descriptor-if-there-is-no-archive.patch @@ -0,0 +1,234 @@ +From 1c611b40e6bfc8029bff7696814330b5bc0ee5c0 Mon Sep 17 00:00:00 2001 +From: "H.J. Lu" +Date: Mon, 26 Jul 2021 05:59:55 -0700 +Subject: [PATCH] bfd: Close the file descriptor if there is no archive fd + +Close the file descriptor if there is no archive plugin file descriptor +to avoid running out of file descriptors on thin archives with many +archive members. + +bfd/ + + PR ld/28138 + * plugin.c (bfd_plugin_close_file_descriptor): Close the file + descriptor there is no archive plugin file descriptor. + +ld/ + + PR ld/28138 + * testsuite/ld-plugin/lto.exp: Run tmpdir/pr28138 only for + native build. + + PR ld/28138 + * testsuite/ld-plugin/lto.exp: Run ld/28138 tests. + * testsuite/ld-plugin/pr28138.c: New file. + * testsuite/ld-plugin/pr28138-1.c: Likewise. + * testsuite/ld-plugin/pr28138-2.c: Likewise. + * testsuite/ld-plugin/pr28138-3.c: Likewise. + * testsuite/ld-plugin/pr28138-4.c: Likewise. + * testsuite/ld-plugin/pr28138-5.c: Likewise. + * testsuite/ld-plugin/pr28138-6.c: Likewise. + * testsuite/ld-plugin/pr28138-7.c: Likewise. + +(cherry picked from commit 5a98fb7513b559e20dfebdbaa2a471afda3b4742) +(cherry picked from commit 7dc37e1e1209c80e0bab784df6b6bac335e836f2) + +Signed-off-by: Kai Liu +--- + bfd/plugin.c | 8 +++++++ + ld/testsuite/ld-plugin/lto.exp | 34 ++++++++++++++++++++++++++++++ + ld/testsuite/ld-plugin/pr28138-1.c | 6 ++++++ + ld/testsuite/ld-plugin/pr28138-2.c | 6 ++++++ + ld/testsuite/ld-plugin/pr28138-3.c | 6 ++++++ + ld/testsuite/ld-plugin/pr28138-4.c | 6 ++++++ + ld/testsuite/ld-plugin/pr28138-5.c | 6 ++++++ + ld/testsuite/ld-plugin/pr28138-6.c | 6 ++++++ + ld/testsuite/ld-plugin/pr28138-7.c | 6 ++++++ + ld/testsuite/ld-plugin/pr28138.c | 20 ++++++++++++++++++ + 10 files changed, 104 insertions(+) + create mode 100644 ld/testsuite/ld-plugin/pr28138-1.c + create mode 100644 ld/testsuite/ld-plugin/pr28138-2.c + create mode 100644 ld/testsuite/ld-plugin/pr28138-3.c + create mode 100644 ld/testsuite/ld-plugin/pr28138-4.c + create mode 100644 ld/testsuite/ld-plugin/pr28138-5.c + create mode 100644 ld/testsuite/ld-plugin/pr28138-6.c + create mode 100644 ld/testsuite/ld-plugin/pr28138-7.c + create mode 100644 ld/testsuite/ld-plugin/pr28138.c + +diff --git a/bfd/plugin.c b/bfd/plugin.c +index 6cfa2b66470..3bab8febe88 100644 +--- a/bfd/plugin.c ++++ b/bfd/plugin.c +@@ -291,6 +291,14 @@ bfd_plugin_close_file_descriptor (bfd *abfd, int fd) + && !bfd_is_thin_archive (abfd->my_archive)) + abfd = abfd->my_archive; + ++ /* Close the file descriptor if there is no archive plugin file ++ descriptor. */ ++ if (abfd->archive_plugin_fd == -1) ++ { ++ close (fd); ++ return; ++ } ++ + abfd->archive_plugin_fd_open_count--; + /* Dup the archive plugin file descriptor for later use, which + will be closed by _bfd_archive_close_and_cleanup. */ +diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp +index def69e43ab3..999d911ce6a 100644 +--- a/ld/testsuite/ld-plugin/lto.exp ++++ b/ld/testsuite/ld-plugin/lto.exp +@@ -687,6 +687,40 @@ if { [is_elf_format] && [check_lto_shared_available] } { + } + } + ++run_cc_link_tests [list \ ++ [list \ ++ "Build pr28138.a" \ ++ "-T" "" \ ++ {pr28138-1.c pr28138-2.c pr28138-3.c pr28138-4.c pr28138-5.c \ ++ pr28138-6.c pr28138-7.c} {} "pr28138.a" \ ++ ] \ ++ [list \ ++ "Build pr28138.o" \ ++ "" "" \ ++ {pr28138.c} {} \ ++ ] \ ++] ++ ++set exec_output [run_host_cmd "sh" \ ++ "-c \"ulimit -n 20; \ ++ $CC -Btmpdir/ld -o tmpdir/pr28138 \ ++ tmpdir/pr28138.o tmpdir/pr28138.a\""] ++set exec_output [prune_warnings $exec_output] ++if [string match "" $exec_output] then { ++ if { [isnative] } { ++ set exec_output [run_host_cmd "tmpdir/pr28138" ""] ++ if [string match "PASS" $exec_output] then { ++ pass "PR ld/28138" ++ } else { ++ fail "PR ld/28138" ++ } ++ } else { ++ pass "PR ld/28138" ++ } ++} else { ++ fail "PR ld/28138" ++} ++ + set testname "Build liblto-11.a" + remote_file host delete "tmpdir/liblto-11.a" + set catch_output [run_host_cmd "$ar" "rc $plug_opt tmpdir/liblto-11.a tmpdir/lto-11a.o tmpdir/lto-11b.o tmpdir/lto-11c.o"] +diff --git a/ld/testsuite/ld-plugin/pr28138-1.c b/ld/testsuite/ld-plugin/pr28138-1.c +new file mode 100644 +index 00000000000..51d119e1642 +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138-1.c +@@ -0,0 +1,6 @@ ++extern int a0(void); ++int ++a1(void) ++{ ++ return 1 + a0(); ++} +diff --git a/ld/testsuite/ld-plugin/pr28138-2.c b/ld/testsuite/ld-plugin/pr28138-2.c +new file mode 100644 +index 00000000000..1120cd797e9 +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138-2.c +@@ -0,0 +1,6 @@ ++extern int a1(void); ++int ++a2(void) ++{ ++ return 1 + a1(); ++} +diff --git a/ld/testsuite/ld-plugin/pr28138-3.c b/ld/testsuite/ld-plugin/pr28138-3.c +new file mode 100644 +index 00000000000..ec464947ee6 +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138-3.c +@@ -0,0 +1,6 @@ ++extern int a2(void); ++int ++a3(void) ++{ ++ return 1 + a2(); ++} +diff --git a/ld/testsuite/ld-plugin/pr28138-4.c b/ld/testsuite/ld-plugin/pr28138-4.c +new file mode 100644 +index 00000000000..475701b2c5c +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138-4.c +@@ -0,0 +1,6 @@ ++extern int a3(void); ++int ++a4(void) ++{ ++ return 1 + a3(); ++} +diff --git a/ld/testsuite/ld-plugin/pr28138-5.c b/ld/testsuite/ld-plugin/pr28138-5.c +new file mode 100644 +index 00000000000..e24f86c363e +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138-5.c +@@ -0,0 +1,6 @@ ++extern int a4(void); ++int ++a5(void) ++{ ++ return 1 + a4(); ++} +diff --git a/ld/testsuite/ld-plugin/pr28138-6.c b/ld/testsuite/ld-plugin/pr28138-6.c +new file mode 100644 +index 00000000000..b5b938bdb21 +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138-6.c +@@ -0,0 +1,6 @@ ++extern int a5(void); ++int ++a6(void) ++{ ++ return 1 + a5(); ++} +diff --git a/ld/testsuite/ld-plugin/pr28138-7.c b/ld/testsuite/ld-plugin/pr28138-7.c +new file mode 100644 +index 00000000000..4ef75bf0f0c +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138-7.c +@@ -0,0 +1,6 @@ ++extern int a6(void); ++int ++a7(void) ++{ ++ return 1 + a6(); ++} +diff --git a/ld/testsuite/ld-plugin/pr28138.c b/ld/testsuite/ld-plugin/pr28138.c +new file mode 100644 +index 00000000000..68252c9f382 +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138.c +@@ -0,0 +1,20 @@ ++#include ++ ++extern int a7(void); ++ ++int ++a0(void) ++{ ++ return 0; ++} ++ ++int ++main() ++{ ++ if (a7() == 7) ++ { ++ printf ("PASS\n"); ++ return 0; ++ } ++ return 1; ++} +-- +2.34.1 + diff --git a/binutils.spec b/binutils.spec index 9e3d278..d953970 100644 --- a/binutils.spec +++ b/binutils.spec @@ -1,7 +1,7 @@ Summary: Binary utilities Name: binutils Version: 2.37 -Release: 1 +Release: 6 License: GPLv3+ URL: https://sourceware.org/binutils @@ -29,13 +29,14 @@ Patch6: backport-CVE-2021-45078.patch Patch7: backport-0001-CVE-2021-42574.patch Patch8: backport-0002-CVE-2021-42574.patch Patch9: backport-0003-CVE-2021-42574.patch +Patch10: bfd-Close-the-file-descriptor-if-there-is-no-archive.patch Provides: bundled(libiberty) Buildroot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) BuildRequires: gcc, perl, sed, coreutils, dejagnu, zlib-devel, glibc-static, sharutils, bc, libstdc++-static -BuildRequires: bison, m4, gcc-c++, gettext, flex, zlib-devel, texinfo >= 4.0, perl-podlators +BuildRequires: bison, m4, gcc-c++, gettext, flex, zlib-devel, texinfo >= 4.0, perl-podlators chrpath Requires(post): info coreutils chkconfig Requires(preun):info chkconfig @@ -171,6 +172,14 @@ chmod +x %{buildroot}%{_libdir}/lib*.so* rm -f %{buildroot}%{_libdir}/lib{bfd,opcodes}.{so,la} +#Remove rpath +chrpath --delete %{buildroot}%{_bindir}/{ld.bfd,objcopy,addr2line,gprof,size,strings,c++filt,strip,as,objdump,nm,ranlib,ar,readelf} +chrpath --delete %{buildroot}%{_libdir}/libopcodes-%{version}.so +chrpath --delete %{buildroot}%{_libdir}/libctf.so.0.0.0 + +mkdir -p %{buildroot}/etc/ld.so.conf.d +echo "%{_libdir}" > %{buildroot}/etc/ld.so.conf.d/%{name}-%{_arch}.conf + %ifarch %{ix86} x86_64 arm sed -i -e '/^#include "ansidecl.h"/{p;s~^.*$~#include ~;}' \ -e 's/^#define BFD_DEFAULT_TARGET_SIZE \(32\|64\) *$/#define BFD_DEFAULT_TARGET_SIZE __WORDSIZE/' \ @@ -324,6 +333,7 @@ fi %exclude %{_libdir}/libctf-nobfd.a %exclude %{_libdir}/libbfd.so %exclude %{_libdir}/libopcodes.so +%config(noreplace) /etc/ld.so.conf.d/* %files devel %{_prefix}/include/* @@ -342,30 +352,54 @@ fi %{_infodir}/bfd*info* %changelog -* Wed Jan 19 2022 panxiaohe - 2.37-1 -- Type:enhancement +* Tue Mar 15 2022 zoulin - 2.37-6 +- Type:requirements +- ID:NA +- SUG:NA +- DESC:fix (obs) project build fail + +* Sat Mar 12 2022 zoulin - 2.37-5 +- Type:requirements +- ID:NA +- SUG:NA +- DESC:add binutils-extra + +* Fri Jan 21 2022 Kai Liu - 2.37-4 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:Fix upstream bug #28138, which results in "malformed archive" error when building nodejs + +* Wed Jan 19 2022 panxiaohe - 2.37-3 +- Type:CVE - ID:CVE-2021-42574 - SUG:NA -- DESC:update to 2.37 and fix CVE-2021-42574 +- DESC:Fix CVE-2021-42574 -* Fri Dec 24 2021 yangzhuangzhuang - 2.36.1-4 +* Fri Dec 24 2021 yangzhuangzhuang - 2.37-2 - Type:CVE - ID:CVE-2021-45078 - SUG:NA - DESC:Fix CVE-2021-45078 -* Thu Dec 16 2021 wangchen - 2.36.1-3 -- Type:bugfix +* Thu Dec 2 2021 wangchen - 2.37-1 +- Type:requirements - ID:NA - SUG:NA -- DESC: Fix demangle style usage info +- DESC:update to 2.37 -* Tue Sep 14 2021 panxiaohe - 2.36.1-2 +* Tue Sep 14 2021 panxiaohe - 2.36.1-3 - Type:bugfix - ID:NA - SUG:NA - DESC: fix issue about delete symlink when using the strip command +* Tue Sep 7 2021 yangzhuangzhuang - 2.36.1-2 +- Type:requirements +- ID:NA +- SUG:NA +- DESC:remove rpath and runpath of exec files and libraries + * Mon Jul 5 2021 yixiangzhike - 2.36.1-1 - Type:NA - ID:NA -- Gitee