mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 02:33:24 -03:00
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.
This commit is contained in:
parent
0b5adfda87
commit
5f082ad4e4
2 changed files with 34 additions and 1 deletions
|
@ -200,6 +200,10 @@ chain for " target " development."))
|
|||
(package-with-extra-patches base-nsis
|
||||
(search-our-patches "nsis-gcc-10-memmove.patch")))
|
||||
|
||||
(define (fix-ppc64-nx-default lief)
|
||||
(package-with-extra-patches lief
|
||||
(search-our-patches "lief-fix-ppc64-nx-default.patch")))
|
||||
|
||||
(define-public lief
|
||||
(package
|
||||
(name "python-lief")
|
||||
|
@ -602,7 +606,7 @@ inspecting signatures in Mach-O binaries.")
|
|||
;; Git
|
||||
git
|
||||
;; Tests
|
||||
lief)
|
||||
(fix-ppc64-nx-default lief))
|
||||
(let ((target (getenv "HOST")))
|
||||
(cond ((string-suffix? "-mingw32" target)
|
||||
;; Windows
|
||||
|
|
29
contrib/guix/patches/lief-fix-ppc64-nx-default.patch
Normal file
29
contrib/guix/patches/lief-fix-ppc64-nx-default.patch
Normal file
|
@ -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);
|
Loading…
Add table
Reference in a new issue