aboutsummaryrefslogtreecommitdiff
path: root/contrib/guix/patches
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2022-06-25 09:41:09 +0100
committerfanquake <fanquake@gmail.com>2022-06-25 10:04:10 +0100
commit5f082ad4e4cc59ccc0ea32626a69522abba71e0d (patch)
treebb16e0a06931cb35ccb71f5e4a3074d09d98a5ed /contrib/guix/patches
parent0b5adfda87ff9f3cf669c277b2c3e2b96676b259 (diff)
downloadbitcoin-5f082ad4e4cc59ccc0ea32626a69522abba71e0d.tar.xz
guix: patch LIEF to fix PPC64 NX default
This patches our LIEF build using the change merged upstream: https://github.com/lief-project/LIEF/pull/718. This can be dropped the next time we update LIEF.
Diffstat (limited to 'contrib/guix/patches')
-rw-r--r--contrib/guix/patches/lief-fix-ppc64-nx-default.patch29
1 files changed, 29 insertions, 0 deletions
diff --git a/contrib/guix/patches/lief-fix-ppc64-nx-default.patch b/contrib/guix/patches/lief-fix-ppc64-nx-default.patch
new file mode 100644
index 0000000000..101bc1ddc0
--- /dev/null
+++ b/contrib/guix/patches/lief-fix-ppc64-nx-default.patch
@@ -0,0 +1,29 @@
+Correct default for Binary::has_nx on ppc64
+
+From the Linux kernel source:
+
+ * This is the default if a program doesn't have a PT_GNU_STACK
+ * program header entry. The PPC64 ELF ABI has a non executable stack
+ * stack by default, so in the absence of a PT_GNU_STACK program header
+ * we turn execute permission off.
+
+This patch can be dropped the next time we update LIEF.
+
+diff --git a/src/ELF/Binary.cpp b/src/ELF/Binary.cpp
+index a90be1ab..fd2d9764 100644
+--- a/src/ELF/Binary.cpp
++++ b/src/ELF/Binary.cpp
+@@ -1084,7 +1084,12 @@ bool Binary::has_nx() const {
+ return segment->type() == SEGMENT_TYPES::PT_GNU_STACK;
+ });
+ if (it_stack == std::end(segments_)) {
+- return false;
++ if (header().machine_type() == ARCH::EM_PPC64) {
++ // The PPC64 ELF ABI has a non-executable stack by default.
++ return true;
++ } else {
++ return false;
++ }
+ }
+
+ return !(*it_stack)->has(ELF_SEGMENT_FLAGS::PF_X);