From 6d6af4d900ce1eac4475ff4125a400acbbef3f22 Mon Sep 17 00:00:00 2001
From: V3n3RiX <venerix@koprulu.sector>
Date: Fri, 24 Nov 2023 22:37:36 +0000
Subject: gentoo auto-resync : 24:11:2023 - 22:37:36

---
 sys-devel/mold/Manifest                            |   2 -
 .../mold/files/mold-2.0.0-DT_RELR-dependency.patch | 161 ---------------------
 .../mold/files/mold-2.0.0-reloc-test-fix.patch     |  58 --------
 3 files changed, 221 deletions(-)
 delete mode 100644 sys-devel/mold/files/mold-2.0.0-DT_RELR-dependency.patch
 delete mode 100644 sys-devel/mold/files/mold-2.0.0-reloc-test-fix.patch

(limited to 'sys-devel/mold')

diff --git a/sys-devel/mold/Manifest b/sys-devel/mold/Manifest
index dbe929472ea6..756aac378a3c 100644
--- a/sys-devel/mold/Manifest
+++ b/sys-devel/mold/Manifest
@@ -1,5 +1,3 @@
-AUX mold-2.0.0-DT_RELR-dependency.patch 5826 BLAKE2B f728523f8fe758d5f61768b4466e36a5fe44fc019f5c31fa41bf2310ef83db6c7eebfa585f776f0145d6b5727a68a686c0a624702af8ae54624ad2571472c977 SHA512 8ccca7ce514b2dd75a62613554237ef60cb527e892516aba35a6ac62a1a1851d217c5da98c821480a120d83ce071bf01fab390d0e80860d2d65b9ac54a8f03e3
-AUX mold-2.0.0-reloc-test-fix.patch 1468 BLAKE2B 197e9876667f4f066d801ff304216498aa4eb718d98badcb1a2eb951ae70984728171f5d1f9945201d7ca316d65a3ee1e3438b3e397246e0bdbc821f109bae59 SHA512 a912f06938d8acac52b673bad8a02ac70f13b47db232a51713d80e33dde93c45c7519b6db24451a072b799d6d7a839aabdb577786758d17535284ebe5b7bb055
 AUX mold-2.3.0-no-pch.patch 457 BLAKE2B ac313a6409a2e43b6d26833231cb26c36d3d34f25b25d4217d50fbd1f39eda9d5b42a1939ca8ee48f6dfb73d3c27d7c6111da9beb67a43c72d3c2beb070303b0 SHA512 c79b3e998cbc23ca7069eed95a7d7871371da9c21b6970fe2a1d8dcd1009466e262f63febbc267d364e552b2eb4bebd5d74bc6dc8084d48d4c0e9e02e1d868bc
 AUX mold-2.3.2-mimalloc-visibility-interposition.patch 18190 BLAKE2B dfcc0287bf6dfbcdd91fcb9ebf9b56b3d48ef0e6c83566ce832e1279e6ef83acefaac84822b75978596613802a99318765a08eb9c60ace591b5914c1e194263c SHA512 5596bd7cc81e8f5797960aa3cc24d9f5cff3b464839df9b2ff22bf76d3c22041381415464639d0a2079710ad30acd8b9f593e3cd342aedebd398b3d1196aba67
 DIST mold-2.1.0.tar.gz 9278811 BLAKE2B b31e13f92177553adf5069cf35c8c75c7bc28f0af4d1726cdc0c6abc1c9d3baaa5be512c3a8fb9bc3c3110096a79e1c6751c701171769595a2234fc1fa8c441a SHA512 f1c98d349b35b4042109d71f7db6eb8d7d089dc3241735bbd7b5402d513dcc85ca17904828779e5fc8234650fa9fb97f47c3a2f3e89cc2fb3cb9e9110439e5a2
diff --git a/sys-devel/mold/files/mold-2.0.0-DT_RELR-dependency.patch b/sys-devel/mold/files/mold-2.0.0-DT_RELR-dependency.patch
deleted file mode 100644
index 267afde230d2..000000000000
--- a/sys-devel/mold/files/mold-2.0.0-DT_RELR-dependency.patch
+++ /dev/null
@@ -1,161 +0,0 @@
-https://bugs.gentoo.org/911591
-https://bugzilla.mozilla.org/show_bug.cgi?id=1847697
-https://github.com/rui314/mold/issues/653#event-10041847648
-https://github.com/rui314/mold/commit/f467ad1add2ab6e381e0e458f026df197e63d487
-
-From f467ad1add2ab6e381e0e458f026df197e63d487 Mon Sep 17 00:00:00 2001
-From: Rui Ueyama <ruiu@bluewhale.systems>
-Date: Wed, 9 Aug 2023 11:40:09 +0900
-Subject: [PATCH] Create a symbol version dependency to GLIBC_ABI_DT_RELR
-
-Fixes https://github.com/rui314/mold/issues/653
----
- elf/cmdline.cc                     |  2 ++
- elf/mold.h                         |  1 +
- elf/output-chunks.cc               | 44 +++++++++++++++++++++++++-----
- test/elf/z-pack-relative-relocs.sh | 16 +++++++++++
- 4 files changed, 56 insertions(+), 7 deletions(-)
- create mode 100755 test/elf/z-pack-relative-relocs.sh
-
-diff --git a/elf/cmdline.cc b/elf/cmdline.cc
-index c568ce086..82a0e6869 100644
---- a/elf/cmdline.cc
-+++ b/elf/cmdline.cc
-@@ -875,8 +875,10 @@ std::vector<std::string> parse_nonpositional_args(Context<E> &ctx) {
-       ctx.arg.z_nodefaultlib = true;
-     } else if (read_z_flag("pack-relative-relocs")) {
-       ctx.arg.pack_dyn_relocs_relr = true;
-+      ctx.arg.z_pack_relative_relocs = true;
-     } else if (read_z_flag("nopack-relative-relocs")) {
-       ctx.arg.pack_dyn_relocs_relr = false;
-+      ctx.arg.z_pack_relative_relocs = false;
-     } else if (read_z_flag("separate-loadable-segments")) {
-       z_separate_code = SEPARATE_LOADABLE_SEGMENTS;
-     } else if (read_z_flag("separate-code")) {
-diff --git a/elf/mold.h b/elf/mold.h
-index e5532211c..3a027f1e9 100644
---- a/elf/mold.h
-+++ b/elf/mold.h
-@@ -1831,6 +1831,7 @@ struct Context {
-     bool z_nodefaultlib = false;
-     bool z_now = false;
-     bool z_origin = false;
-+    bool z_pack_relative_relocs = false;
-     bool z_relro = true;
-     bool z_sectionheader = true;
-     bool z_shstk = false;
-diff --git a/elf/output-chunks.cc b/elf/output-chunks.cc
-index 726a4da2b..3896a2991 100644
---- a/elf/output-chunks.cc
-+++ b/elf/output-chunks.cc
-@@ -2373,12 +2373,13 @@ void VerneedSection<E>::construct(Context<E> &ctx) {
-            std::tuple(((SharedFile<E> *)b->file)->soname, b->ver_idx);
-   });
- 
--  // Resize of .gnu.version
-+  // Resize .gnu.version
-   ctx.versym->contents.resize(ctx.dynsym->symbols.size(), 1);
-   ctx.versym->contents[0] = 0;
- 
-   // Allocate a large enough buffer for .gnu.version_r.
--  contents.resize((sizeof(ElfVerneed<E>) + sizeof(ElfVernaux<E>)) * syms.size());
-+  contents.resize((sizeof(ElfVerneed<E>) + sizeof(ElfVernaux<E>)) *
-+                  (syms.size() + 1));
- 
-   // Fill .gnu.version_r.
-   u8 *buf = (u8 *)&contents[0];
-@@ -2394,14 +2395,14 @@ void VerneedSection<E>::construct(Context<E> &ctx) {
-       verneed->vn_next = ptr - (u8 *)verneed;
- 
-     verneed = (ElfVerneed<E> *)ptr;
--    ptr += sizeof(*verneed);
-+    ptr += sizeof(ElfVerneed<E>);
-     verneed->vn_version = 1;
-     verneed->vn_file = ctx.dynstr->find_string(((SharedFile<E> *)file)->soname);
-     verneed->vn_aux = sizeof(ElfVerneed<E>);
-     aux = nullptr;
-   };
- 
--  auto add_entry = [&](Symbol<E> *sym) {
-+  auto add_entry = [&](std::string_view verstr) {
-     verneed->vn_cnt++;
- 
-     if (aux)
-@@ -2409,23 +2410,52 @@ void VerneedSection<E>::construct(Context<E> &ctx) {
-     aux = (ElfVernaux<E> *)ptr;
-     ptr += sizeof(*aux);
- 
--    std::string_view verstr = sym->get_version();
-     aux->vna_hash = elf_hash(verstr);
-     aux->vna_other = ++veridx;
-     aux->vna_name = ctx.dynstr->add_string(verstr);
-   };
- 
-+  // Create version entries.
-   for (i64 i = 0; i < syms.size(); i++) {
-     if (i == 0 || syms[i - 1]->file != syms[i]->file) {
-       start_group(syms[i]->file);
--      add_entry(syms[i]);
-+      add_entry(syms[i]->get_version());
-     } else if (syms[i - 1]->ver_idx != syms[i]->ver_idx) {
--      add_entry(syms[i]);
-+      add_entry(syms[i]->get_version());
-     }
- 
-     ctx.versym->contents[syms[i]->get_dynsym_idx(ctx)] = veridx;
-   }
- 
-+  if (ctx.arg.z_pack_relative_relocs) {
-+    // If `-z pack-relative-relocs` is specified, we'll create a .relr.dyn
-+    // section and store base relocation records to that section instead of
-+    // to the usual .rela.dyn section.
-+    //
-+    // .relr.dyn is relatively new feature and not supported by glibc until
-+    // 2.38 which was released in 2022. Executables built with `-z
-+    // pack-relative-relocs` don't work and usually crash immediately on
-+    // startup if libc doesn't support it.
-+    //
-+    // In the following code, we'll add a dependency to a dummy version name
-+    // "GLIBC_ABI_DT_RELR" so that executables built with the option failed
-+    // with a more friendly "version `GLIBC_ABI_DT_RELR' not found" error
-+    // message. glibc 2.38 or later knows about this dummy version name and
-+    // simply ignores it.
-+    auto find_glibc2 = [&]() -> InputFile<E> * {
-+      for (Symbol<E> *sym : syms)
-+        if (((SharedFile<E> *)sym->file)->soname.starts_with("libc.so.") &&
-+            sym->get_version().starts_with("GLIBC_2."))
-+          return sym->file;
-+      return nullptr;
-+    };
-+
-+    if (InputFile<E> *file = find_glibc2()) {
-+      start_group(file);
-+      add_entry("GLIBC_ABI_DT_RELR");
-+    }
-+  }
-+
-   // Resize .gnu.version_r to fit to its contents.
-   contents.resize(ptr - buf);
- }
-diff --git a/test/elf/z-pack-relative-relocs.sh b/test/elf/z-pack-relative-relocs.sh
-new file mode 100755
-index 000000000..e09d441e7
---- /dev/null
-+++ b/test/elf/z-pack-relative-relocs.sh
-@@ -0,0 +1,16 @@
-+#!/bin/bash
-+. $(dirname $0)/common.inc
-+
-+cat <<EOF | $CC -o $t/a.o -fPIC -c -xc -
-+#include <stdio.h>
-+int main() {
-+  printf("Hello world\n");
-+}
-+EOF
-+
-+$CC -B. -o $t/exe $t/a.o -pie -Wl,-z,pack-relative-relocs
-+
-+readelf -W -V $t/exe > $t/log
-+grep -Fq GLIBC_2. $t/log || skip
-+
-+grep -q GLIBC_ABI_DT_RELR $t/log
diff --git a/sys-devel/mold/files/mold-2.0.0-reloc-test-fix.patch b/sys-devel/mold/files/mold-2.0.0-reloc-test-fix.patch
deleted file mode 100644
index 8e6e04f5d535..000000000000
--- a/sys-devel/mold/files/mold-2.0.0-reloc-test-fix.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-https://github.com/rui314/mold/issues/1067
-https://github.com/rui314/mold/commit/1582b720d58df61bc4c0ae39fa269e3b250b94df
-
-From 1582b720d58df61bc4c0ae39fa269e3b250b94df Mon Sep 17 00:00:00 2001
-From: Rui Ueyama <ruiu@bluewhale.systems>
-Date: Fri, 28 Jul 2023 14:58:57 +0900
-Subject: [PATCH] Weak undefs should not keep DSOs alive
-
-Fixes https://github.com/rui314/mold/issues/1067
---- a/elf/input-files.cc
-+++ b/elf/input-files.cc
-@@ -1396,7 +1396,8 @@ SharedFile<E>::mark_live_objects(Context<E> &ctx,
-     if (sym.is_traced)
-       print_trace_symbol(ctx, *this, esym, sym);
- 
--    if (esym.is_undef() && sym.file && !sym.file->is_alive.test_and_set()) {
-+    if (esym.is_undef() && !esym.is_weak() && sym.file &&
-+        !sym.file->is_alive.test_and_set()) {
-       feeder(sym.file);
- 
-       if (sym.is_traced)
---- /dev/null
-+++ b/test/elf/as-needed-dso2.sh
-@@ -0,0 +1,33 @@
-+#!/bin/bash
-+. $(dirname $0)/common.inc
-+
-+cat <<EOF | $CC -c -fPIC -o $t/a.o -xc -
-+int foo() {
-+  return 0;
-+}
-+EOF
-+
-+cat <<EOF | $CC -c -fPIC -o $t/b.o -xc -
-+__attribute__((weak)) int foo();
-+
-+int bar() {
-+  if (foo) return foo();
-+  return 0;
-+}
-+EOF
-+
-+cat <<EOF | $CC -xc -c -o $t/c.o -
-+int bar();
-+
-+int main() {
-+  return bar();
-+}
-+EOF
-+
-+$CC -B. -shared -o $t/libfoo.so $t/a.o
-+$CC -B. -shared -o $t/libbar.so $t/b.o
-+$CC -B. -o $t/exe $t/c.o -L$t -Wl,--as-needed -lfoo -lbar
-+
-+readelf --dynamic $t/exe > $t/log
-+! grep libfoo.so $t/log || false
-+grep -q libbar.so $t/log
-
-- 
cgit v1.2.3