diff --git a/Fix-gold-relocation-offset-and-adrp-signed-shife.patch b/Fix-gold-relocation-offset-and-adrp-signed-shife.patch new file mode 100644 index 0000000000000000000000000000000000000000..52f9449c6ff20f36f7356c374b5854e92b9f5e4a --- /dev/null +++ b/Fix-gold-relocation-offset-and-adrp-signed-shife.patch @@ -0,0 +1,64 @@ +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, + +diff --git a/gold/aarch64.cc b/gold/aarch64.cc +index 9f3af466..521908ff 100644 +--- a/gold/aarch64.cc ++++ b/gold/aarch64.cc +@@ -1182,7 +1182,7 @@ class Reloc_stub : public Stub_base + aarch64_valid_for_adrp_p(AArch64_address location, AArch64_address dest) + { + typedef AArch64_relocate_functions Reloc; +- int64_t adrp_imm = (Reloc::Page(dest) - Reloc::Page(location)) >> 12; ++ int64_t adrp_imm = ((int64_t)(Reloc::Page(dest) - Reloc::Page(location))) >> 12; + return adrp_imm >= MIN_ADRP_IMM && adrp_imm <= MAX_ADRP_IMM; + } + +-- +2.26.0 + diff --git a/binutils.spec b/binutils.spec index c47e1554ac668604781d4e4667de9d40bde22806..f53fc1b0eb8e2040a6f7153d78ad26205f2c53c4 100644 --- a/binutils.spec +++ b/binutils.spec @@ -1,7 +1,7 @@ Summary: Binary utilities Name: binutils Version: 2.37 -Release: 14 +Release: 15 License: GPLv3+ URL: https://sourceware.org/binutils @@ -72,6 +72,7 @@ Patch46: backport-don-t-over-align-file-positions-of-PE-executable-sec.patch Patch47: backport-PR28186-SEGV-elf.c-7991-30-in-_bfd_elf_fixup_group_sections.patch Patch48: backport-PR28422-build_id-use-after-free.patch Patch49: backport-PR28540-segmentation-fault-on-NULL-byte_get.patch +Patch50: Fix-gold-relocation-offset-and-adrp-signed-shife.patch Provides: bundled(libiberty) @@ -396,6 +397,12 @@ fi %{_infodir}/bfd*info* %changelog +* Thu Apr 20 2023 dingguangya - 2.37-15 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:Fix gold linker relocation offset + * Mon Oct 24 2022 huyubiao - 2.37-14 - DESC:Prevents the use of null pointers and sets the pointer to null after being used.