Skip to content

Commit

Permalink
MachO: Check swift symbols for arc and canary. Fixes #6
Browse files Browse the repository at this point in the history
`_swift_release` is the ARC symbol for swift according to: https://stackoverflow.com/questions/34700937/profiling-swift-with-instruments-what-exactly-is-swift-retain
`___chkstk_darwin` is the Stack Canary symbol for swift according to: https://forums.swift.org/t/what-is-chkstk-darwin/59519
  • Loading branch information
titison authored and titison committed Nov 12, 2023
1 parent d6fb6ba commit a0100a9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/macho.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ impl fmt::Display for CheckSecResults {
/// }
/// ```
pub trait Properties {
/// check import names for `_objc_release`
/// check symbol names for `_objc_release` or `_swift_release`
fn has_arc(&self) -> bool;
/// check import names for `___stack_chk_fail` or `___stack_chk_guard`
/// check symbol names for `___stack_chk_fail` `___stack_chk_guard` or `___chkstk_darwin`
fn has_canary(&self) -> bool;
/// check data size of code signature in load commands
fn has_code_signature(&self) -> bool;
Expand All @@ -178,8 +178,9 @@ impl Properties for MachO<'_> {
fn has_arc(&self) -> bool {
for i in self.symbols() {
if let Ok((symbol,_)) = i {
if symbol == "_objc_release" {
return true;
match symbol {
"_objc_release" | "_swift_release" => return true,
_ => continue,
}
}
}
Expand All @@ -189,7 +190,7 @@ impl Properties for MachO<'_> {
for i in self.symbols() {
if let Ok((symbol,_)) = i {
match symbol {
"___stack_chk_fail" | "___stack_chk_guard" => return true,
"___stack_chk_fail" | "___stack_chk_guard" | "___chkstk_darwin" => return true,
_ => continue,
}
}
Expand Down

0 comments on commit a0100a9

Please sign in to comment.