From 1f73163bfbcf1ebb59a50bf0358f0da28afbd163 Mon Sep 17 00:00:00 2001 From: Guoguo Date: Sat, 4 Nov 2023 10:50:28 +0000 Subject: [PATCH 1/2] add riscv64 support for execstack Signed-off-by: Guoguo --- 0004-Add-PL_ARCH-for-riscv64.patch | 112 +++++++++++++++++++++++++++++ execstack.spec | 14 +++- 2 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 0004-Add-PL_ARCH-for-riscv64.patch diff --git a/0004-Add-PL_ARCH-for-riscv64.patch b/0004-Add-PL_ARCH-for-riscv64.patch new file mode 100644 index 0000000..7094cb2 --- /dev/null +++ b/0004-Add-PL_ARCH-for-riscv64.patch @@ -0,0 +1,112 @@ +From 353286ad47b73fc2d2b790fff8df4782595e1242 Mon Sep 17 00:00:00 2001 +From: rpm-build +Date: Mon, 28 Jan 2019 08:49:23 +0000 +Subject: [PATCH] Add minimal support for RISC-V 64-bit (riscv64) + +Signed-off-by: rpm-build +--- + src/Makefile.am | 2 +- + src/Makefile.in | 7 ++++--- + src/arch-riscv64.c | 38 ++++++++++++++++++++++++++++++++++++++ + 3 files changed, 43 insertions(+), 4 deletions(-) + create mode 100644 src/arch-riscv64.c + +diff --git a/src/Makefile.am b/src/Makefile.am +index a4c65f2..28ea4a6 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -13,7 +13,7 @@ bin_PROGRAMS = execstack + arch_SOURCES = arch-i386.c arch-alpha.c arch-ppc.c arch-ppc64.c \ + arch-sparc.c arch-sparc64.c arch-x86_64.c arch-mips.c \ + arch-s390.c arch-s390x.c arch-arm.c arch-sh.c arch-ia64.c \ +- arch-aarch64.c ++ arch-aarch64.c arch-riscv64.c + common_SOURCES = checksum.c data.c dso.c dwarf2.c dwarf2.h fptr.c fptr.h \ + hashtab.c hashtab.h mdebug.c prelink.h stabs.c crc32.c + prelink_SOURCES = cache.c conflict.c cxx.c doit.c exec.c execle_open.c get.c \ +diff --git a/src/Makefile.in b/src/Makefile.in +index 863dc83..9a9f555 100644 +--- a/src/Makefile.in ++++ b/src/Makefile.in +@@ -108,7 +108,7 @@ bin_PROGRAMS = execstack + arch_SOURCES = arch-i386.c arch-alpha.c arch-ppc.c arch-ppc64.c \ + arch-sparc.c arch-sparc64.c arch-x86_64.c arch-mips.c \ + arch-s390.c arch-s390x.c arch-arm.c arch-sh.c arch-ia64.c \ +- arch-aarch64.c ++ arch-aarch64.c arch-riscv64.c + + common_SOURCES = checksum.c data.c dso.c dwarf2.c dwarf2.h fptr.c fptr.h \ + hashtab.c hashtab.h mdebug.c prelink.h stabs.c crc32.c +@@ -141,7 +141,7 @@ am__objects_2 = arch-i386.$(OBJEXT) arch-alpha.$(OBJEXT) \ + arch-sparc64.$(OBJEXT) arch-x86_64.$(OBJEXT) \ + arch-mips.$(OBJEXT) arch-s390.$(OBJEXT) arch-s390x.$(OBJEXT) \ + arch-arm.$(OBJEXT) arch-sh.$(OBJEXT) arch-ia64.$(OBJEXT) \ +- arch-aarch64.$(OBJEXT) ++ arch-aarch64.$(OBJEXT) arch-riscv64.$(OBJEXT) + am_execstack_OBJECTS = execstack.$(OBJEXT) $(am__objects_1) \ + $(am__objects_2) + execstack_OBJECTS = $(am_execstack_OBJECTS) +@@ -169,7 +169,7 @@ am__depfiles_maybe = depfiles + @AMDEP_TRUE@ ./$(DEPDIR)/arch-ppc.Po ./$(DEPDIR)/arch-ppc64.Po \ + @AMDEP_TRUE@ ./$(DEPDIR)/arch-s390.Po ./$(DEPDIR)/arch-s390x.Po \ + @AMDEP_TRUE@ ./$(DEPDIR)/arch-sh.Po ./$(DEPDIR)/arch-sparc.Po \ +-@AMDEP_TRUE@ ./$(DEPDIR)/arch-sparc64.Po \ ++@AMDEP_TRUE@ ./$(DEPDIR)/arch-sparc64.Po ./$(DEPDIR)/arch-riscv64.Po \ + @AMDEP_TRUE@ ./$(DEPDIR)/arch-x86_64.Po ./$(DEPDIR)/cache.Po \ + @AMDEP_TRUE@ ./$(DEPDIR)/canonicalize.Po ./$(DEPDIR)/checksum.Po \ + @AMDEP_TRUE@ ./$(DEPDIR)/conflict.Po ./$(DEPDIR)/crc32.Po \ +@@ -291,6 +291,7 @@ distclean-compile: + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch-sparc.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch-sparc64.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch-x86_64.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch-riscv64.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cache.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/canonicalize.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checksum.Po@am__quote@ +diff --git a/src/arch-riscv64.c b/src/arch-riscv64.c +new file mode 100644 +index 0000000..ceecc0f +--- /dev/null ++++ b/src/arch-riscv64.c +@@ -0,0 +1,38 @@ ++/* Copyright (C) 2019 David Abdurachmanov ++ Written by David Abdurachmanov , 2019. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 2, or (at your option) ++ any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program; if not, write to the Free Software Foundation, ++ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "prelink.h" ++ ++PL_ARCH = { ++ .name = "RISCV64", ++ .class = ELFCLASS64, ++ .machine = EM_RISCV, ++ .alternate_machine = { EM_NONE }, ++ .max_page_size = 0x1000, ++ .page_size = 0x1000 ++}; +-- +2.20.1 + diff --git a/execstack.spec b/execstack.spec index 5f42a2d..ec5bc12 100644 --- a/execstack.spec +++ b/execstack.spec @@ -1,4 +1,4 @@ -%define anolis_release 17 +%define anolis_release 18 %global commit 4c79120bcdbde0616f592458ccde7035e92ca3d8 %global shortcommit %(c=%{commit}; echo ${c:0:7}) @@ -9,10 +9,16 @@ Version: 0.5.0 Release: %{anolis_release}%{?dist} License: GPLv2+ Source0: https://github.com/keszybz/prelink/archive/%{commit}.tar.gz#/prelink-%{shortcommit}.tar.gz + Patch0001: 0001-Add-PL_ARCH-for-AArch64.patch Patch0002: 0002-execstack-configure-c99.patch +%ifarch loongarch64 Patch0003: 0003-Add-PL_ARCH-for-Loongarch64.patch +%endif +%ifarch riscv64 +Patch0004: 0004-Add-PL_ARCH-for-riscv64.patch +%endif BuildRequires: gcc gcc-c++ make BuildRequires: elfutils-libelf-devel libselinux-devel, libselinux-utils Requires: glibc >= 2.2.4-18, coreutils, findutils @@ -68,7 +74,11 @@ install -D -m 0644 doc/execstack.8 %{buildroot}%{_mandir}/man8/execstack.8 %doc ChangeLog NEWS README TODO THANKS %changelog -* Mon Oct 9 2023 Wenlong Zhang - 0.5.0-17 +* Sat Nov 4 2023 Guoguo - 0.5.0-18 +- add riscv64 support for execstack +- Patch from http://fedora.riscv.rocks:3000/rpms/execstack/raw/branch/f38-riscv64/0001-Add-minimal-support-for-RISC-V-64-bit-riscv64.patch + +* Mon Oct 9 2023 Wenlong Zhang - 0.5.0-17 - add loongarch64 support for execstack * Sat Apr 15 2023 Funda Wang - 0.5.0-16 -- Gitee From 1b11cbd31e264e484f5c24fc10ead77ec3b21a3f Mon Sep 17 00:00:00 2001 From: U2FsdGVkX1 Date: Fri, 15 Dec 2023 12:38:26 +0800 Subject: [PATCH 2/2] Add riscv64 support --- execstack.spec | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/execstack.spec b/execstack.spec index ec5bc12..ce9fec3 100644 --- a/execstack.spec +++ b/execstack.spec @@ -12,13 +12,9 @@ Source0: https://github.com/keszybz/prelink/archive/%{commit}.tar.gz#/prelink-% Patch0001: 0001-Add-PL_ARCH-for-AArch64.patch Patch0002: 0002-execstack-configure-c99.patch -%ifarch loongarch64 Patch0003: 0003-Add-PL_ARCH-for-Loongarch64.patch -%endif - -%ifarch riscv64 Patch0004: 0004-Add-PL_ARCH-for-riscv64.patch -%endif + BuildRequires: gcc gcc-c++ make BuildRequires: elfutils-libelf-devel libselinux-devel, libselinux-utils Requires: glibc >= 2.2.4-18, coreutils, findutils @@ -43,7 +39,15 @@ BuildArch: noarch This document package contains the doc files for %{name}. %prep -%autosetup -p1 -n prelink-%{commit} +%autosetup -N -n prelink-%{commit} +%patch -P1 -p1 +%patch -P2 -p1 +%ifarch loongarch64 +%patch -P3 -p1 +%endif +%ifarch riscv64 +%patch -P4 -p1 +%endif %build sed -i -e '/^prelink_LDADD/s/$/ -lpthread/' src/Makefile.{am,in} @@ -76,7 +80,6 @@ install -D -m 0644 doc/execstack.8 %{buildroot}%{_mandir}/man8/execstack.8 %changelog * Sat Nov 4 2023 Guoguo - 0.5.0-18 - add riscv64 support for execstack -- Patch from http://fedora.riscv.rocks:3000/rpms/execstack/raw/branch/f38-riscv64/0001-Add-minimal-support-for-RISC-V-64-bit-riscv64.patch * Mon Oct 9 2023 Wenlong Zhang - 0.5.0-17 - add loongarch64 support for execstack -- Gitee