Skip to content

Commit 4266f6e

Browse files
committed
MachO: Check swift symbols for arc and canary. Fixes #6
`_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
1 parent db7b83e commit 4266f6e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/macho.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ impl fmt::Display for CheckSecResults {
150150
/// }
151151
/// ```
152152
pub trait Properties {
153-
/// check import names for `_objc_release`
153+
/// check symbol names for `_objc_release` or `_swift_release`
154154
fn has_arc(&self) -> bool;
155-
/// check import names for `___stack_chk_fail` or `___stack_chk_guard`
155+
/// check symbol names for `___stack_chk_fail` `___stack_chk_guard` or `___chkstk_darwin`
156156
fn has_canary(&self) -> bool;
157157
/// check data size of code signature in load commands
158158
fn has_code_signature(&self) -> bool;
@@ -178,8 +178,9 @@ impl Properties for MachO<'_> {
178178
fn has_arc(&self) -> bool {
179179
for i in self.symbols() {
180180
if let Ok((symbol,_)) = i {
181-
if symbol == "_objc_release" {
182-
return true;
181+
match symbol {
182+
"_objc_release" | "_swift_release" => return true,
183+
_ => continue,
183184
}
184185
}
185186
}
@@ -189,7 +190,7 @@ impl Properties for MachO<'_> {
189190
for i in self.symbols() {
190191
if let Ok((symbol,_)) = i {
191192
match symbol {
192-
"___stack_chk_fail" | "___stack_chk_guard" => return true,
193+
"___stack_chk_fail" | "___stack_chk_guard" | "___chkstk_darwin" => return true,
193194
_ => continue,
194195
}
195196
}

0 commit comments

Comments
 (0)