-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #2493 - RalfJung:android, r=RalfJung
add very basic Android support This is just enough to print to stdout. I won't push this any further, but having these basics should hopefully make it easier for others to do so. Also slightly improve threading support on FreeBSD while we are at it. Partially based on #2011. Fixes #2010.
- Loading branch information
Showing
15 changed files
with
160 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
8556e6620e4866526b3cea767ad8c20ae877a569 | ||
9c20b2a8cc7588decb6de25ac6a7912dcef24d65 |
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,54 @@ | ||
use rustc_middle::mir; | ||
|
||
use crate::helpers::check_arg_count; | ||
use crate::*; | ||
|
||
#[derive(Debug, Copy, Clone)] | ||
#[allow(non_camel_case_types)] | ||
pub enum Dlsym { | ||
signal, | ||
} | ||
|
||
impl Dlsym { | ||
// Returns an error for unsupported symbols, and None if this symbol | ||
// should become a NULL pointer (pretend it does not exist). | ||
pub fn from_str<'tcx>(name: &str) -> InterpResult<'tcx, Option<Dlsym>> { | ||
Ok(match name { | ||
"signal" => Some(Dlsym::signal), | ||
"android_set_abort_message" => None, | ||
_ => throw_unsup_format!("unsupported Android dlsym: {}", name), | ||
}) | ||
} | ||
} | ||
|
||
impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mir, 'tcx> {} | ||
pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx> { | ||
fn call_dlsym( | ||
&mut self, | ||
dlsym: Dlsym, | ||
args: &[OpTy<'tcx, Provenance>], | ||
dest: &PlaceTy<'tcx, Provenance>, | ||
ret: Option<mir::BasicBlock>, | ||
) -> InterpResult<'tcx> { | ||
let this = self.eval_context_mut(); | ||
let ret = ret.expect("we don't support any diverging dlsym"); | ||
assert!(this.tcx.sess.target.os == "android"); | ||
|
||
match dlsym { | ||
Dlsym::signal => { | ||
if !this.frame_in_std() { | ||
throw_unsup_format!( | ||
"`signal` support is crude and just enough for libstd to work" | ||
); | ||
} | ||
|
||
let &[ref _sig, ref _func] = check_arg_count(args)?; | ||
this.write_null(dest)?; | ||
} | ||
} | ||
|
||
log::trace!("{:?}", this.dump_place(**dest)); | ||
this.go_to_block(ret); | ||
Ok(()) | ||
} | ||
} |
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,26 @@ | ||
use rustc_span::Symbol; | ||
use rustc_target::spec::abi::Abi; | ||
|
||
use crate::*; | ||
use shims::foreign_items::EmulateByNameResult; | ||
|
||
impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mir, 'tcx> {} | ||
|
||
pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx> { | ||
fn emulate_foreign_item_by_name( | ||
&mut self, | ||
link_name: Symbol, | ||
_abi: Abi, | ||
_args: &[OpTy<'tcx, Provenance>], | ||
_dest: &PlaceTy<'tcx, Provenance>, | ||
) -> InterpResult<'tcx, EmulateByNameResult<'mir, 'tcx>> { | ||
let _this = self.eval_context_mut(); | ||
#[allow(clippy::match_single_binding)] | ||
match link_name.as_str() { | ||
_ => return Ok(EmulateByNameResult::NotSupported), | ||
} | ||
|
||
#[allow(unreachable_code)] | ||
Ok(EmulateByNameResult::NeedsJumping) | ||
} | ||
} |
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,2 @@ | ||
pub mod dlsym; | ||
pub mod foreign_items; |
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ mod fs; | |
mod sync; | ||
mod thread; | ||
|
||
mod android; | ||
mod freebsd; | ||
mod linux; | ||
mod macos; | ||
|
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