[packages/mold] upstream fix for crash with --icf=all; rel 2

atler atler at pld-linux.org
Sat Aug 31 15:13:26 CEST 2024


commit 77972f84eda4c2541791faae9265d1b4ea1856ca
Author: Jan Palus <atler at pld-linux.org>
Date:   Sat Aug 31 14:28:42 2024 +0200

    upstream fix for crash with --icf=all; rel 2

 icf-all.patch | 42 ++++++++++++++++++++++++++++++++++++++++++
 mold.spec     |  4 +++-
 2 files changed, 45 insertions(+), 1 deletion(-)
---
diff --git a/mold.spec b/mold.spec
index d08d4dd..f800227 100644
--- a/mold.spec
+++ b/mold.spec
@@ -5,11 +5,12 @@
 Summary:	mold: A Modern Linker
 Name:		mold
 Version:	2.33.0
-Release:	1
+Release:	2
 License:	MIT
 Group:		Development/Libraries
 Source0:	https://github.com/rui314/mold/archive/v%{version}/%{name}-%{version}.tar.gz
 # Source0-md5:	3a860c9aabdf1a186cd0a0d084252105
+Patch0:		icf-all.patch
 URL:		https://github.com/rui314/mold
 BuildRequires:	blake3-devel
 BuildRequires:	cmake >= 3.14
@@ -38,6 +39,7 @@ especially in rapid debug-edit-rebuild cycles.
 
 %prep
 %setup -q
+%patch0 -p1
 
 %{__rm} -r third-party/{mimalloc,tbb}
 
diff --git a/icf-all.patch b/icf-all.patch
new file mode 100644
index 0000000..59b9560
--- /dev/null
+++ b/icf-all.patch
@@ -0,0 +1,42 @@
+From 5a9919b43344b4fb92ea701f0b32a7e20857b9ca Mon Sep 17 00:00:00 2001
+From: Rui Ueyama <ruiu at cs.stanford.edu>
+Date: Fri, 9 Aug 2024 12:08:03 +0900
+Subject: [PATCH] Fix a crash bug
+
+Fixes https://github.com/rui314/mold/issues/1326
+---
+ elf/output-chunks.cc | 15 ++++++---------
+ 1 file changed, 6 insertions(+), 9 deletions(-)
+
+diff --git a/elf/output-chunks.cc b/elf/output-chunks.cc
+index 74c054b8f4..cb246caeb2 100644
+--- a/elf/output-chunks.cc
++++ b/elf/output-chunks.cc
+@@ -1730,21 +1730,18 @@ ElfSym<E> to_output_esym(Context<E> &ctx, Symbol<E> &sym, u32 st_name,
+     esym.st_type = STT_FUNC;
+     esym.st_visibility = sym.visibility;
+     esym.st_value = sym.get_plt_addr(ctx);
+-  } else if (!isec->output_section) {
++  } else if ((isec->shdr().sh_flags & SHF_MERGE) &&
++             !(isec->shdr().sh_flags & SHF_ALLOC)) {
+     // Symbol in a mergeable non-SHF_ALLOC section, such as .debug_str
+-    assert(!(isec->shdr().sh_flags & SHF_ALLOC));
+-    assert(isec->shdr().sh_flags & SHF_MERGE);
+-    assert(!sym.file->is_dso);
+-
+     ObjectFile<E> *file = (ObjectFile<E> *)sym.file;
+-    MergeableSection<E> *m =
+-      file->mergeable_sections[file->get_shndx(sym.esym())].get();
++    MergeableSection<E> &m =
++      *file->mergeable_sections[file->get_shndx(sym.esym())];
+ 
+     SectionFragment<E> *frag;
+     i64 frag_addend;
+-    std::tie(frag, frag_addend) = m->get_fragment(sym.esym().st_value);
++    std::tie(frag, frag_addend) = m.get_fragment(sym.esym().st_value);
+ 
+-    shndx = m->parent.shndx;
++    shndx = m.parent.shndx;
+     esym.st_visibility = sym.visibility;
+     esym.st_value = frag->get_addr(ctx) + frag_addend;
+   } else {
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/mold.git/commitdiff/77972f84eda4c2541791faae9265d1b4ea1856ca



More information about the pld-cvs-commit mailing list