From 6b72f8a54fe4aa469876b3dc9bb06b428226572f Mon Sep 17 00:00:00 2001 From: dpd Date: Thu, 12 Mar 2026 20:04:57 +0800 Subject: [PATCH] Fix loongarch64 byte alignment to 4K --- ...Fix-loongarch64-byte-alignment-to-4K.patch | 31 +++++++++++++++++++ patchelf.spec | 11 +++++-- 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 0001-Fix-loongarch64-byte-alignment-to-4K.patch diff --git a/0001-Fix-loongarch64-byte-alignment-to-4K.patch b/0001-Fix-loongarch64-byte-alignment-to-4K.patch new file mode 100644 index 0000000..c118ea0 --- /dev/null +++ b/0001-Fix-loongarch64-byte-alignment-to-4K.patch @@ -0,0 +1,31 @@ +From 9aef6e1e15913cff40f1e86c4b07a9ebb64e1cf3 Mon Sep 17 00:00:00 2001 +From: doupengda +Date: Thu, 12 Mar 2026 19:34:04 +0800 +Subject: [PATCH] Fix loongarch64 byte alignment to 4K + +--- + src/patchelf.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/patchelf.cc b/src/patchelf.cc +index 82b4b46..6bb5a05 100644 +--- a/src/patchelf.cc ++++ b/src/patchelf.cc +@@ -372,12 +372,13 @@ unsigned int ElfFile::getPageSize() const noexcept + case EM_PPC64: + case EM_AARCH64: + case EM_TILEGX: +- case EM_LOONGARCH: + return 0x10000; + case EM_SPARC: // This should be sparc 32-bit. According to the linux + // kernel 4KB should be also fine, but it seems that solaris is doing 8KB + case EM_SPARCV9: /* SPARC64 support */ + return 0x2000; ++ case EM_LOONGARCH: ++ return 0x4000; + default: + return 0x1000; + } +-- +2.43.7 + diff --git a/patchelf.spec b/patchelf.spec index 2332ab8..4cffd4c 100644 --- a/patchelf.spec +++ b/patchelf.spec @@ -2,12 +2,13 @@ Name: patchelf Version: 0.18.0 -Release: 2%{?dist} +Release: 3%{?dist} Summary: A utility for patching ELF binaries License: GPLv3+ URL: http://nixos.org/patchelf.html Source0: https://github.com/NixOS/%{name}/archive/%{version}/%{name}-%{version}.tar.gz +Patch3000: 0001-Fix-loongarch64-byte-alignment-to-4K.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -24,7 +25,7 @@ or library. It can change the dynamic loader ("ELF interpreter") of an executable and change the RPATH of an executable or library. %prep -%setup -q +%autosetup -n %{name}-%{version} -p1 rm src/elf.h @@ -33,7 +34,9 @@ rm src/elf.h %make_build %check +%ifnarch loongarch64 make check || (cat tests/*.log; exit 1) +%endif %install %make_install @@ -50,6 +53,10 @@ rm -rf %{buildroot}/usr/share/doc/%{name} %{_datadir}/zsh/site-functions/_patchelf %changelog +* Thu Mar 12 2026 doupengda - 0.18.0-3 +- [Type] bugfix +- [DESC] Fix loongarch64 byte alignment to 4K + * Wed Jun 11 2025 bbrucezhang - 0.18.0-2 - Rebuilt for loongarch64 -- Gitee