forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge bitcoin#25357: drop -z,noexecstack for PPC64
- Loading branch information
Showing
7 changed files
with
40 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |