From b409d5a4fdf4254b9771a04fc17513ff6991c1a5 Mon Sep 17 00:00:00 2001 From: Zach van Rijn Date: Fri, 10 Jun 2022 10:44:01 +0000 Subject: user/llvm8: add patch for PROT_READ on aarch64 and ppc64. fixes #711. --- user/llvm8/APKBUILD | 6 +++-- user/llvm8/fix-memory-mf_exec-on-aarch64.patch | 33 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 user/llvm8/fix-memory-mf_exec-on-aarch64.patch diff --git a/user/llvm8/APKBUILD b/user/llvm8/APKBUILD index 337c78be8..a7a2a44d3 100644 --- a/user/llvm8/APKBUILD +++ b/user/llvm8/APKBUILD @@ -6,7 +6,7 @@ _pkgname=llvm pkgver=8.0.1 _majorver=${pkgver%%.*} pkgname=$_pkgname$_majorver -pkgrel=2 +pkgrel=3 pkgdesc="Low Level Virtual Machine compiler system, version $_majorver" arch="all" options="!checkroot !dbg" @@ -26,6 +26,7 @@ source="https://github.com/llvm/llvm-project/releases/download/llvmorg-$pkgver/l even-more-secure-plt.patch python3-test.patch scc-insertion.patch + fix-memory-mf_exec-on-aarch64.patch " builddir="$srcdir/$_pkgname-$pkgver.src" @@ -236,4 +237,5 @@ e5ddbc4b6c4928e79846dc3c022eb7928aaa8fed40515c78f5f03b8ab8264f34f1eb8aa8bfc0f436 7ba7f5b396e1afb49ea53fdc16729f0709fbba88de433cc8a8e2f751d13733011d4121318f68d7f8a16a6c57c3a1bee727cc3e0da0f5c6cae38eff70d3a539cf more-secure-plt.patch deb71762721ebc73bfdf23143b582f40c70eddcef3e337ed14499e8e336bee2906292d38d64fe98fa633430c1bcb66cf6a2e067258c8fbe6e931f99f6d10a6f7 even-more-secure-plt.patch 53cc0d13dd871e9b775bb4e7567de4f9a97d91b8246cd7ce74607fd88d6e3e2ab9455f5b4195bc7f9dbdedbc77d659d43e98ec0b7cd78cd395aaea6919510287 python3-test.patch -4422a83ea953a6b30cb447a448d246956abd6b0cbd2451247e5f2c41318b2c0d18c7b6781155ea40a5558bbd66e9e1482cec0875d95776545fd0d87356b5e4bd scc-insertion.patch" +4422a83ea953a6b30cb447a448d246956abd6b0cbd2451247e5f2c41318b2c0d18c7b6781155ea40a5558bbd66e9e1482cec0875d95776545fd0d87356b5e4bd scc-insertion.patch +c9ef3cd95c4bd1d6ac69bbcd471b01755126d00f59d27d4a2a2ef5623943be73f8407e2fd731294d1a9d81a66e459f45f3f1d5dc5f9646f4f2fb2d8d891b5279 fix-memory-mf_exec-on-aarch64.patch" diff --git a/user/llvm8/fix-memory-mf_exec-on-aarch64.patch b/user/llvm8/fix-memory-mf_exec-on-aarch64.patch new file mode 100644 index 000000000..a70b39733 --- /dev/null +++ b/user/llvm8/fix-memory-mf_exec-on-aarch64.patch @@ -0,0 +1,33 @@ +Fix failures in AllocationTests/MappedMemoryTest.* on aarch64: + + Failing Tests (8): + LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.AllocAndRelease/3 + LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.DuplicateNear/3 + LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.EnabledWrite/3 + LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.MultipleAllocAndRelease/3 + LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.SuccessiveNear/3 + LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.UnalignedNear/3 + LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroNear/3 + LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroSizeNear/3 + +Upstream-Issue: https://bugs.llvm.org/show_bug.cgi?id=14278#c10 + +--- a/lib/Support/Unix/Memory.inc ++++ b/lib/Support/Unix/Memory.inc +@@ -54,7 +54,7 @@ + llvm::sys::Memory::MF_EXEC: + return PROT_READ | PROT_WRITE | PROT_EXEC; + case llvm::sys::Memory::MF_EXEC: +-#if defined(__FreeBSD__) ++#if defined(__FreeBSD__) || (defined(__linux__) && (defined(__aarch64__) || defined(__powerpc64__))) + // On PowerPC, having an executable page that has no read permission + // can have unintended consequences. The function InvalidateInstruction- + // Cache uses instructions dcbf and icbi, both of which are treated by +@@ -62,6 +62,7 @@ + // executing these instructions will result in a segmentation fault. + // Somehow, this problem is not present on Linux, but it does happen + // on FreeBSD. ++ // The same problem is present even on aarch64 Linux (at least on musl). + return PROT_READ | PROT_EXEC; + #else + return PROT_EXEC; -- cgit v1.2.3-60-g2f50