From f3d16d01024f1a49e261d4f9d3e8e1db4a32ab1d Mon Sep 17 00:00:00 2001 From: Huang Yang Date: Mon, 8 Apr 2024 06:31:37 +0000 Subject: [PATCH] add loongarch64 support --- 0002-execstack-configure-c99.patch | 37 +++++++++ 0003-Add-PL_ARCH-for-Loongarch64.patch | 108 +++++++++++++++++++++++++ execstack.spec | 9 ++- 3 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 0002-execstack-configure-c99.patch create mode 100644 0003-Add-PL_ARCH-for-Loongarch64.patch diff --git a/0002-execstack-configure-c99.patch b/0002-execstack-configure-c99.patch new file mode 100644 index 0000000..f0b36fe --- /dev/null +++ b/0002-execstack-configure-c99.patch @@ -0,0 +1,37 @@ +Avoid implicit function declarations, a C feature removed in 1999. + +diff --git a/aclocal.m4 b/aclocal.m4 +index a357ef74b30a09a6..2d2af334d5369e8e 100644 +--- a/aclocal.m4 ++++ b/aclocal.m4 +@@ -6727,6 +6727,7 @@ AC_DEFUN(AC_LIBELF_SXWORD, + #include + #include + #include ++#include + + static unsigned char sparc64_elf[] = { + 0x7f,0x45,0x4c,0x46,0x02,0x02,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +diff --git a/configure b/configure +index 9f2a746fbf3f7471..960e140559761417 100755 +--- a/configure ++++ b/configure +@@ -4438,8 +4438,8 @@ main () + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) +- exit(2); +- exit (0); ++ return 2; ++ return 0; + } + _ACEOF + rm -f conftest$ac_exeext +@@ -19411,6 +19411,7 @@ cat >>conftest.$ac_ext <<_ACEOF + #include + #include + #include ++#include + + static unsigned char sparc64_elf[] = { + 0x7f,0x45,0x4c,0x46,0x02,0x02,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, diff --git a/0003-Add-PL_ARCH-for-Loongarch64.patch b/0003-Add-PL_ARCH-for-Loongarch64.patch new file mode 100644 index 0000000..31157f7 --- /dev/null +++ b/0003-Add-PL_ARCH-for-Loongarch64.patch @@ -0,0 +1,108 @@ +iFrom cf07bef7cbc17e20a53ea56203abb137a1fe8ab7 Mon Sep 17 00:00:00 2001 +From: rpm-build +Date: Sat, 5 Nov 2022 07:46:27 +0000 +Subject: [PATCH] Add PL_ARCH for Loongarch64 + +--- + src/Makefile.am | 2 +- + src/Makefile.in | 6 ++++-- + src/arch-loongarch64.c | 37 +++++++++++++++++++++++++++++++++++++ + 3 files changed, 42 insertions(+), 3 deletions(-) + create mode 100644 src/arch-loongarch64.c + +diff --git a/src/Makefile.am b/src/Makefile.am +index a4c65f2..c18d0fd 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-loongarch64.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..77fc31b 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-loongarch64.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-loongarch64.$(OBJEXT) + am_execstack_OBJECTS = execstack.$(OBJEXT) $(am__objects_1) \ + $(am__objects_2) + execstack_OBJECTS = $(am_execstack_OBJECTS) +@@ -170,6 +170,7 @@ am__depfiles_maybe = depfiles + @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-loongarch64.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 \ +@@ -280,6 +281,7 @@ distclean-compile: + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch-alpha.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch-arm.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch-arch64.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch-loongarch64.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch-i386.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch-ia64.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch-mips.Po@am__quote@ +diff --git a/src/arch-loongarch64.c b/src/arch-loongarch64.c +new file mode 100644 +index 0000000..8bd9de8 +--- /dev/null ++++ b/src/arch-loongarch64.c +@@ -0,0 +1,37 @@ ++/* Copyright (C) 2022 Loongson Technology Co., Ltd. ++ ++ 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 = "LongArch64", ++ .class = ELFCLASS64, ++ .machine = EM_LOONGARCH, ++ .alternate_machine = { EM_NONE }, ++ .max_page_size = 0x100000, ++ .page_size = 0x4000 ++}; +-- +2.27.0 diff --git a/execstack.spec b/execstack.spec index 75b1ab7..1730001 100644 --- a/execstack.spec +++ b/execstack.spec @@ -4,13 +4,15 @@ Summary: Utility to set/clear/query executable stack bit Name: execstack Version: 0.5.0 -Release: 5%{?dist} +Release: 6%{?dist} License: GPLv2+ URL: https://github.com/keszybz/prelink Source0: %{url}/archive/%{commit}.tar.gz#/prelink-%{shortcommit}.tar.gz Patch3000: Add-PL_ARCH-for-AArch64.patch - +Patch3001: 0002-execstack-configure-c99.patch +Patch3002: 0003-Add-PL_ARCH-for-Loongarch64.patch + BuildRequires: gcc gcc-c++ elfutils-libelf-devel libselinux-devel libselinux-utils git make Requires: glibc coreutils findutils util-linux gawk grep @@ -48,6 +50,9 @@ install -Dm0644 doc/execstack.8 %{buildroot}%{_mandir}/man8/execstack.8 %{_mandir}/man8/execstack.8.* %changelog +* Mon Apr 08 2024 Huang Yang - 0.5.0-6 +- add loongarch64 support + * Wed Jan 17 2024 Rebuild Robot - 0.5.0-5 - Rebuilt for elfutils -- Gitee