Skip to content

Commit 1842893

Browse files
committed
Add gettid support for Android
1 parent d967b26 commit 1842893

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/shims/extern_static.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl<'tcx> MiriMachine<'tcx> {
6262
}
6363
"android" => {
6464
Self::null_ptr_extern_statics(ecx, &["bsd_signal"])?;
65-
Self::weak_symbol_extern_statics(ecx, &["signal", "getrandom"])?;
65+
Self::weak_symbol_extern_statics(ecx, &["signal", "getrandom", "gettid"])?;
6666
}
6767
"windows" => {
6868
// "_tls_used"

src/shims/unix/android/foreign_items.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ use rustc_span::Symbol;
44
use rustc_target::callconv::FnAbi;
55

66
use crate::shims::unix::android::thread::prctl;
7+
use crate::shims::unix::env::EvalContextExt as _;
78
use crate::shims::unix::linux_like::epoll::EvalContextExt as _;
89
use crate::shims::unix::linux_like::eventfd::EvalContextExt as _;
910
use crate::shims::unix::linux_like::syscall::syscall;
1011
use crate::*;
1112

12-
pub fn is_dyn_sym(_name: &str) -> bool {
13-
false
13+
pub fn is_dyn_sym(name: &str) -> bool {
14+
matches!(name, "gettid")
1415
}
1516

1617
impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
@@ -54,6 +55,12 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
5455
this.write_scalar(errno_place.to_ref(this).to_scalar(), dest)?;
5556
}
5657

58+
"gettid" => {
59+
let [] = this.check_shim_sig_lenient(abi, CanonAbi::C, link_name, args)?;
60+
let result = this.unix_gettid(link_name.as_str())?;
61+
this.write_scalar(result, dest)?;
62+
}
63+
5764
// Dynamically invoked syscalls
5865
"syscall" => syscall(this, link_name, abi, args, dest)?,
5966

0 commit comments

Comments
 (0)