Skip to content

Commit d691505

Browse files
committed
merge bitcoin#25357: drop -z,noexecstack for PPC64
1 parent 5365419 commit d691505

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

contrib/guix/libexec/build.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,6 @@ case "$HOST" in
250250
*powerpc64*) HOST_LDFLAGS="${HOST_LDFLAGS} -Wl,--no-tls-get-addr-optimize" ;;
251251
esac
252252

253-
case "$HOST" in
254-
powerpc64-linux-*) HOST_LDFLAGS="${HOST_LDFLAGS} -Wl,-z,noexecstack" ;;
255-
esac
256-
257253
# Make $HOST-specific native binaries from depends available in $PATH
258254
export PATH="${BASEPREFIX}/${HOST}/native/bin:${PATH}"
259255
mkdir -p "$DISTSRC"

contrib/guix/manifest.scm

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,10 +548,14 @@ inspecting signatures in Mach-O binaries.")
548548
"glibc-2.27-dont-redefine-nss-database.patch"
549549
"glibc-2.27-guix-prefix.patch"))))))
550550

551+
(define (fix-ppc64-nx-default lief)
552+
(package-with-extra-patches lief
553+
(search-our-patches "lief-fix-ppc64-nx-default.patch")))
554+
551555
(define-public lief
552556
(package
553557
(name "python-lief")
554-
(version "0.12.0")
558+
(version "0.12.1")
555559
(source
556560
(origin
557561
(method git-fetch)
@@ -561,7 +565,7 @@ inspecting signatures in Mach-O binaries.")
561565
(file-name (git-file-name name version))
562566
(sha256
563567
(base32
564-
"026jchj56q25v6gc0754dj9cj5hz5zaza8ij93y5ga94w20kzm9q"))))
568+
"1xzbh3bxy4rw1yamnx68da1v5s56ay4g081cyamv67256g0qy2i1"))))
565569
(build-system python-build-system)
566570
(arguments
567571
`(#:phases
@@ -616,7 +620,7 @@ parse, modify and abstract ELF, PE and MachO formats.")
616620
;; Git
617621
git
618622
;; Tests
619-
lief)
623+
(fix-ppc64-nx-default lief))
620624
(let ((target (getenv "HOST")))
621625
(cond ((string-suffix? "-mingw32" target)
622626
;; Windows
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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);

0 commit comments

Comments
 (0)