From df0d047ed5409dc653417a2ccd560908f580488f Mon Sep 17 00:00:00 2001 From: Funda Wang Date: Mon, 4 Nov 2024 22:01:56 +0800 Subject: [PATCH] Handle DT_MIPS_RLD_MAP_REL on MIPS (debian bug#820335) --- chrpath-fix-mips-segfault.patch | 31 +++++++++++++++++++++++++++++++ chrpath.spec | 7 ++++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 chrpath-fix-mips-segfault.patch diff --git a/chrpath-fix-mips-segfault.patch b/chrpath-fix-mips-segfault.patch new file mode 100644 index 0000000..c9239b7 --- /dev/null +++ b/chrpath-fix-mips-segfault.patch @@ -0,0 +1,31 @@ +--- chrpath-0.18.orig/killrpath.c ++++ chrpath-0.18/killrpath.c +@@ -78,10 +78,26 @@ + dynpos = 0; + for (i = 0; DYNSS(i, d_tag) != DT_NULL; i++) + { +- if (is_e32()) ++ if (is_e32()) { + ((Elf32_Dyn *)dyns)[dynpos] = ((Elf32_Dyn *)dyns)[i]; +- else ++#ifdef DT_MIPS_RLD_MAP_REL ++ /* DT_MIPS_RLD_MAP_REL is relative to the offset of the tag. ++ Adjust it consequently. */ ++ if (DYNSS(i, d_tag) == DT_MIPS_RLD_MAP_REL) ++ ((Elf32_Dyn *)dyns)[dynpos].d_un.d_val = ++ DO_SWAPU32(DYNSU(i, d_un.d_val) + ++ (i - dynpos) * sizeof(Elf32_Dyn)); ++#endif ++ } else { + ((Elf64_Dyn *)dyns)[dynpos] = ((Elf64_Dyn *)dyns)[i]; ++#ifdef DT_MIPS_RLD_MAP_REL ++ /* Ditto */ ++ if (DYNSS(i, d_tag) == DT_MIPS_RLD_MAP_REL) ++ ((Elf64_Dyn *)dyns)[dynpos].d_un.d_val = ++ DO_SWAPU64(DYNSU(i, d_un.d_val) + ++ (i - dynpos) * sizeof(Elf64_Dyn)); ++#endif ++ } + if ( ! elf_dynpath_tag(DYNSS(i, d_tag)) ) + dynpos++; + } diff --git a/chrpath.spec b/chrpath.spec index ad24e0d..674e0c1 100644 --- a/chrpath.spec +++ b/chrpath.spec @@ -1,10 +1,12 @@ Name: chrpath Version: 0.18 -Release: 1 +Release: 2 Summary: Modify the dynamic library load path (rpath) of compiled programs License: GPL-2.0-or-later URL: https://codeberg.org/pere/chrpath Source0: https://codeberg.org/pere/chrpath/archive/release-%{version}.tar.gz +# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=820335 +Patch6001: chrpath-fix-mips-segfault.patch BuildRequires: gcc make BuildRequires: autoconf automake libtool @@ -40,6 +42,9 @@ rm -rf %{buildroot}/usr/doc %{_mandir}/man1/chrpath.1* %changelog +* Mon Nov 04 2024 Funda Wang - 0.18-2 +- Handle DT_MIPS_RLD_MAP_REL on MIPS (debian bug#820335) + * Sun Nov 03 2024 Funda Wang - 0.18-1 - Change to latest native branch comes with debian -- Gitee