Skip to content

Commit fe0bfd5

Browse files
committed
merge bitcoin#25357: drop -z,noexecstack for PPC64
1 parent 2f3503e commit fe0bfd5

File tree

7 files changed

+40
-11
lines changed

7 files changed

+40
-11
lines changed

contrib/containers/ci/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ RUN pip3 install \
3737
codespell==1.17.1 \
3838
flake8==3.8.3 \
3939
jinja2 \
40-
lief==0.12.0 \
40+
lief==0.12.1 \
4141
pyzmq \
4242
vulture==2.3 \
4343
yq \

contrib/gitian-descriptors/gitian-linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ script: |
110110
done
111111
}
112112
113-
pip3 install lief==0.12.0
113+
pip3 install lief==0.12.1
114114
115115
# Faketime for depends so intermediate results are comparable
116116
export PATH_orig=${PATH}

contrib/gitian-descriptors/gitian-osx.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ script: |
9696
done
9797
}
9898
99-
pip3 install lief==0.12.0
99+
pip3 install lief==0.12.1
100100
101101
# Faketime for depends so intermediate results are comparable
102102
export PATH_orig=${PATH}

contrib/gitian-descriptors/gitian-win.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ script: |
115115
done
116116
}
117117
118-
pip3 install lief==0.12.0
118+
pip3 install lief==0.12.1
119119
120120
# Faketime for depends so intermediate results are comparable
121121
export PATH_orig=${PATH}

contrib/guix/libexec/build.sh

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

266-
case "$HOST" in
267-
powerpc64-linux-*) HOST_LDFLAGS="${HOST_LDFLAGS} -Wl,-z,noexecstack" ;;
268-
esac
269-
270266
# Make $HOST-specific native binaries from depends available in $PATH
271267
export PATH="${BASEPREFIX}/${HOST}/native/bin:${PATH}"
272268
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
@@ -618,7 +622,7 @@ parse, modify and abstract ELF, PE and MachO formats.")
618622
;; Git
619623
git
620624
;; Tests
621-
lief)
625+
(fix-ppc64-nx-default lief))
622626
(let ((target (getenv "HOST")))
623627
(cond ((string-suffix? "-mingw32" target)
624628
;; 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)