From f75a7339c467e7bcc32da29a68c5c695c4ddd3d5 Mon Sep 17 00:00:00 2001 From: wangding16 Date: Wed, 8 Jun 2022 21:08:06 +0800 Subject: [PATCH] Fix gold linker relocation offset (cherry picked from commit d431376fd7b9d9cca3f76aa72531ed3733f27528) --- Fix-gold-relocation-offset.patch | 50 ++++++++++++++++++++++++++++++++ binutils.spec | 9 +++++- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 Fix-gold-relocation-offset.patch diff --git a/Fix-gold-relocation-offset.patch b/Fix-gold-relocation-offset.patch new file mode 100644 index 0000000..ac94d37 --- /dev/null +++ b/Fix-gold-relocation-offset.patch @@ -0,0 +1,50 @@ +From e1184ff4d698dbb7eb06e2b3a25ccdc12acfa5fb Mon Sep 17 00:00:00 2001 +From: wangding +Date: Wed, 8 Jun 2022 20:19:34 +0800 +Subject: [PATCH] Fix gold linker relocation offset + +--- + gold/aarch64.cc | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +diff --git a/gold/aarch64.cc b/gold/aarch64.cc +index 07abe44931f..05d40a383e0 100644 +--- a/gold/aarch64.cc ++++ b/gold/aarch64.cc +@@ -2915,6 +2915,7 @@ class Target_aarch64 : public Sized_target + Section_id_hash> AArch64_input_section_map; + typedef AArch64_insn_utilities Insn_utilities; + const static int TCB_SIZE = size / 8 * 2; ++ static const Address invalid_address = static_cast
(-1); + + Target_aarch64(const Target::Target_info* info = &aarch64_info) + : Sized_target(info), +@@ -8285,6 +8286,25 @@ Target_aarch64::relocate_relocs( + + gold_assert(sh_type == elfcpp::SHT_RELA); + ++ if (offset_in_output_section == this->invalid_address) { ++ const Output_relaxed_input_section* poris = ++ output_section->find_relaxed_input_section(relinfo->object, ++ relinfo->data_shndx); ++ if (poris != NULL) { ++ Address section_address = poris->address(); ++ section_size_type section_size = poris->data_size(); ++ ++ gold_assert((section_address >= view_address) ++ && ((section_address + section_size) ++ <= (view_address + view_size))); ++ ++ off_t offset = section_address - view_address; ++ view += offset; ++ view_address += offset; ++ view_size = section_size; ++ } ++ } ++ + gold::relocate_relocs( + relinfo, + prelocs, +-- +2.26.0 + diff --git a/binutils.spec b/binutils.spec index f15d64c..0eeac09 100644 --- a/binutils.spec +++ b/binutils.spec @@ -1,7 +1,7 @@ Summary: Binary utilities Name: binutils Version: 2.34 -Release: 19 +Release: 20 License: GPLv3+ URL: https://sourceware.org/binutils @@ -57,6 +57,7 @@ Patch40: backport-Fix-demangle-style-usage-info.patch Patch41: backport-CVE-2021-45078.patch Patch42: backport-0001-CVE-2021-42574.patch Patch43: backport-0002-CVE-2021-42574.patch +Patch44: Fix-gold-relocation-offset.patch Provides: bundled(libiberty) @@ -335,6 +336,12 @@ fi %{_infodir}/bfd*info* %changelog +* Wed Jun 8 2022 wangding - 2.34-20 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:Fix gold linker relocation offset + * Wed Jan 19 2022 panxiaohe - 2.34-19 - Type:CVE - ID:CVE-2021-42574 -- Gitee