Skip to content

Commit

Permalink
Merge pull request #162 from rust-secure-code/fix-riscv
Browse files Browse the repository at this point in the history
Fix detection of `riscv64-linux-android` target features
  • Loading branch information
Shnatsel authored Sep 7, 2024
2 parents 1304b57 + 52ce497 commit 6ea2d28
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cargo-auditable/src/object_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ fn riscv_features(target_triple: &str) -> String {
if extensions.contains('g') {
extensions.push_str("imadf");
}
// Most but not all riscv targets declare target features.
// A notable exception is `riscv64-linux-android`.
// We assume that all Linux-capable targets are -gc.
if target_triple.contains("linux") {
extensions.push_str("imadfc");
}
extensions
}

Expand Down Expand Up @@ -234,6 +240,11 @@ mod tests {
assert!(!features.contains('c'));
assert!(!features.contains('d'));
assert!(features.contains('f'));
// real-world Android riscv target
let features = riscv_features("riscv64-linux-android");
assert!(features.contains('c'));
assert!(features.contains('d'));
assert!(features.contains('f'));
}

#[test]
Expand Down

0 comments on commit 6ea2d28

Please sign in to comment.