File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -200,6 +200,10 @@ chain for " target " development."))
200
200
(package-with-extra-patches base-nsis
201
201
(search-our-patches " nsis-gcc-10-memmove.patch" )))
202
202
203
+ (define (fix-ppc64-nx-default lief )
204
+ (package-with-extra-patches lief
205
+ (search-our-patches " lief-fix-ppc64-nx-default.patch" )))
206
+
203
207
(define-public lief
204
208
(package
205
209
(name " python-lief" )
@@ -602,7 +606,7 @@ inspecting signatures in Mach-O binaries.")
602
606
; ; Git
603
607
git
604
608
; ; Tests
605
- lief)
609
+ (fix-ppc64-nx-default lief) )
606
610
(let ((target (getenv " HOST" )))
607
611
(cond ((string-suffix? " -mingw32" target)
608
612
; ; Windows
Original file line number Diff line number Diff line change
1
+ Correct default for Binary::has_nx on ppc64
2
+
3
+ From the Linux kernel source:
4
+
5
+ * This is the default if a program doesn't have a PT_GNU_STACK
6
+ * program header entry. The PPC64 ELF ABI has a non executable stack
7
+ * stack by default, so in the absence of a PT_GNU_STACK program header
8
+ * we turn execute permission off.
9
+
10
+ This patch can be dropped the next time we update LIEF.
11
+
12
+ diff --git a/src/ELF/Binary.cpp b/src/ELF/Binary.cpp
13
+ index a90be1ab..fd2d9764 100644
14
+ --- a/src/ELF/Binary.cpp
15
+ +++ b/src/ELF/Binary.cpp
16
+ @@ -1084,7 +1084,12 @@ bool Binary::has_nx() const {
17
+ return segment->type() == SEGMENT_TYPES::PT_GNU_STACK;
18
+ });
19
+ if (it_stack == std::end(segments_)) {
20
+ - return false;
21
+ + if (header().machine_type() == ARCH::EM_PPC64) {
22
+ + // The PPC64 ELF ABI has a non-executable stack by default.
23
+ + return true;
24
+ + } else {
25
+ + return false;
26
+ + }
27
+ }
28
+
29
+ return !(*it_stack)->has(ELF_SEGMENT_FLAGS::PF_X);
You can’t perform that action at this time.
0 commit comments