Remove strip_linker_suffix
This commit is contained in:
parent
a67a65359f
commit
9011524454
@ -723,11 +723,6 @@ where
|
|||||||
throw_ub_format!("incorrect number of arguments: got {}, expected {}", args.len(), N)
|
throw_ub_format!("incorrect number of arguments: got {}, expected {}", args.len(), N)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Strip linker suffixes (seen on 32-bit macOS).
|
|
||||||
pub fn strip_linker_suffix(link_name: &str) -> &str {
|
|
||||||
link_name.trim_end_matches("$UNIX2003")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn isolation_abort_error(name: &str) -> InterpResult<'static> {
|
pub fn isolation_abort_error(name: &str) -> InterpResult<'static> {
|
||||||
throw_machine_stop!(TerminationInfo::UnsupportedInIsolation(format!(
|
throw_machine_stop!(TerminationInfo::UnsupportedInIsolation(format!(
|
||||||
"{} not available when isolation is enabled",
|
"{} not available when isolation is enabled",
|
||||||
|
@ -25,7 +25,6 @@ use rustc_target::{
|
|||||||
|
|
||||||
use super::backtrace::EvalContextExt as _;
|
use super::backtrace::EvalContextExt as _;
|
||||||
use crate::*;
|
use crate::*;
|
||||||
use helpers::strip_linker_suffix;
|
|
||||||
|
|
||||||
/// Returned by `emulate_foreign_item_by_name`.
|
/// Returned by `emulate_foreign_item_by_name`.
|
||||||
pub enum EmulateByNameResult {
|
pub enum EmulateByNameResult {
|
||||||
@ -216,12 +215,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||||||
.first_attr_value_str_by_name(&attrs, sym::link_name)
|
.first_attr_value_str_by_name(&attrs, sym::link_name)
|
||||||
.unwrap_or_else(|| this.tcx.item_name(def_id));
|
.unwrap_or_else(|| this.tcx.item_name(def_id));
|
||||||
let link_name = link_name_sym.as_str();
|
let link_name = link_name_sym.as_str();
|
||||||
let link_name = strip_linker_suffix(&link_name);
|
|
||||||
let tcx = this.tcx.tcx;
|
let tcx = this.tcx.tcx;
|
||||||
|
|
||||||
// First: functions that diverge.
|
// First: functions that diverge.
|
||||||
let (dest, ret) = match ret {
|
let (dest, ret) = match ret {
|
||||||
None => match link_name {
|
None => match &*link_name {
|
||||||
"miri_start_panic" => {
|
"miri_start_panic" => {
|
||||||
// `check_shim` happens inside `handle_miri_start_panic`.
|
// `check_shim` happens inside `handle_miri_start_panic`.
|
||||||
this.handle_miri_start_panic(abi, link_name_sym, args, unwind)?;
|
this.handle_miri_start_panic(abi, link_name_sym, args, unwind)?;
|
||||||
@ -306,9 +304,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||||||
|
|
||||||
// Here we dispatch all the shims for foreign functions. If you have a platform specific
|
// Here we dispatch all the shims for foreign functions. If you have a platform specific
|
||||||
// shim, add it to the corresponding submodule.
|
// shim, add it to the corresponding submodule.
|
||||||
let shim_name = link_name.as_str();
|
match &*link_name.as_str() {
|
||||||
let shim_name = strip_linker_suffix(&shim_name);
|
|
||||||
match shim_name {
|
|
||||||
// Miri-specific extern functions
|
// Miri-specific extern functions
|
||||||
"miri_static_root" => {
|
"miri_static_root" => {
|
||||||
let &[ref ptr] = this.check_shim(abi, Abi::Rust, link_name, args)?;
|
let &[ref ptr] = this.check_shim(abi, Abi::Rust, link_name, args)?;
|
||||||
@ -499,7 +495,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||||||
let &[ref f] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
|
let &[ref f] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
|
||||||
// FIXME: Using host floats.
|
// FIXME: Using host floats.
|
||||||
let f = f32::from_bits(this.read_scalar(f)?.to_u32()?);
|
let f = f32::from_bits(this.read_scalar(f)?.to_u32()?);
|
||||||
let f = match shim_name {
|
let f = match &*link_name.as_str() {
|
||||||
"cbrtf" => f.cbrt(),
|
"cbrtf" => f.cbrt(),
|
||||||
"coshf" => f.cosh(),
|
"coshf" => f.cosh(),
|
||||||
"sinhf" => f.sinh(),
|
"sinhf" => f.sinh(),
|
||||||
@ -522,7 +518,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||||||
// FIXME: Using host floats.
|
// FIXME: Using host floats.
|
||||||
let f1 = f32::from_bits(this.read_scalar(f1)?.to_u32()?);
|
let f1 = f32::from_bits(this.read_scalar(f1)?.to_u32()?);
|
||||||
let f2 = f32::from_bits(this.read_scalar(f2)?.to_u32()?);
|
let f2 = f32::from_bits(this.read_scalar(f2)?.to_u32()?);
|
||||||
let n = match shim_name {
|
let n = match &*link_name.as_str() {
|
||||||
"_hypotf" | "hypotf" => f1.hypot(f2),
|
"_hypotf" | "hypotf" => f1.hypot(f2),
|
||||||
"atan2f" => f1.atan2(f2),
|
"atan2f" => f1.atan2(f2),
|
||||||
_ => bug!(),
|
_ => bug!(),
|
||||||
@ -541,7 +537,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||||||
let &[ref f] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
|
let &[ref f] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
|
||||||
// FIXME: Using host floats.
|
// FIXME: Using host floats.
|
||||||
let f = f64::from_bits(this.read_scalar(f)?.to_u64()?);
|
let f = f64::from_bits(this.read_scalar(f)?.to_u64()?);
|
||||||
let f = match shim_name {
|
let f = match &*link_name.as_str() {
|
||||||
"cbrt" => f.cbrt(),
|
"cbrt" => f.cbrt(),
|
||||||
"cosh" => f.cosh(),
|
"cosh" => f.cosh(),
|
||||||
"sinh" => f.sinh(),
|
"sinh" => f.sinh(),
|
||||||
@ -562,7 +558,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||||||
// FIXME: Using host floats.
|
// FIXME: Using host floats.
|
||||||
let f1 = f64::from_bits(this.read_scalar(f1)?.to_u64()?);
|
let f1 = f64::from_bits(this.read_scalar(f1)?.to_u64()?);
|
||||||
let f2 = f64::from_bits(this.read_scalar(f2)?.to_u64()?);
|
let f2 = f64::from_bits(this.read_scalar(f2)?.to_u64()?);
|
||||||
let n = match shim_name {
|
let n = match &*link_name.as_str() {
|
||||||
"_hypot" | "hypot" => f1.hypot(f2),
|
"_hypot" | "hypot" => f1.hypot(f2),
|
||||||
"atan2" => f1.atan2(f2),
|
"atan2" => f1.atan2(f2),
|
||||||
_ => bug!(),
|
_ => bug!(),
|
||||||
|
@ -6,7 +6,6 @@ use rustc_target::abi::{Align, LayoutOf, Size};
|
|||||||
use rustc_target::spec::abi::Abi;
|
use rustc_target::spec::abi::Abi;
|
||||||
|
|
||||||
use crate::*;
|
use crate::*;
|
||||||
use helpers::strip_linker_suffix;
|
|
||||||
use shims::foreign_items::EmulateByNameResult;
|
use shims::foreign_items::EmulateByNameResult;
|
||||||
use shims::posix::fs::EvalContextExt as _;
|
use shims::posix::fs::EvalContextExt as _;
|
||||||
use shims::posix::sync::EvalContextExt as _;
|
use shims::posix::sync::EvalContextExt as _;
|
||||||
@ -24,7 +23,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||||||
) -> InterpResult<'tcx, EmulateByNameResult> {
|
) -> InterpResult<'tcx, EmulateByNameResult> {
|
||||||
let this = self.eval_context_mut();
|
let this = self.eval_context_mut();
|
||||||
|
|
||||||
match strip_linker_suffix(&link_name.as_str()) {
|
match &*link_name.as_str() {
|
||||||
// Environment related shims
|
// Environment related shims
|
||||||
"getenv" => {
|
"getenv" => {
|
||||||
let &[ref name] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
|
let &[ref name] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
|
||||||
|
@ -3,7 +3,6 @@ use rustc_span::Symbol;
|
|||||||
use rustc_target::spec::abi::Abi;
|
use rustc_target::spec::abi::Abi;
|
||||||
|
|
||||||
use crate::*;
|
use crate::*;
|
||||||
use helpers::strip_linker_suffix;
|
|
||||||
use shims::foreign_items::EmulateByNameResult;
|
use shims::foreign_items::EmulateByNameResult;
|
||||||
use shims::posix::fs::EvalContextExt as _;
|
use shims::posix::fs::EvalContextExt as _;
|
||||||
use shims::posix::linux::sync::futex;
|
use shims::posix::linux::sync::futex;
|
||||||
@ -22,7 +21,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||||||
) -> InterpResult<'tcx, EmulateByNameResult> {
|
) -> InterpResult<'tcx, EmulateByNameResult> {
|
||||||
let this = self.eval_context_mut();
|
let this = self.eval_context_mut();
|
||||||
|
|
||||||
match strip_linker_suffix(&link_name.as_str()) {
|
match &*link_name.as_str() {
|
||||||
// errno
|
// errno
|
||||||
"__errno_location" => {
|
"__errno_location" => {
|
||||||
let &[] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
|
let &[] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
|
||||||
|
@ -3,7 +3,6 @@ use rustc_span::Symbol;
|
|||||||
use rustc_target::spec::abi::Abi;
|
use rustc_target::spec::abi::Abi;
|
||||||
|
|
||||||
use crate::*;
|
use crate::*;
|
||||||
use helpers::strip_linker_suffix;
|
|
||||||
use shims::foreign_items::EmulateByNameResult;
|
use shims::foreign_items::EmulateByNameResult;
|
||||||
use shims::posix::fs::EvalContextExt as _;
|
use shims::posix::fs::EvalContextExt as _;
|
||||||
use shims::posix::thread::EvalContextExt as _;
|
use shims::posix::thread::EvalContextExt as _;
|
||||||
@ -20,7 +19,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||||||
) -> InterpResult<'tcx, EmulateByNameResult> {
|
) -> InterpResult<'tcx, EmulateByNameResult> {
|
||||||
let this = self.eval_context_mut();
|
let this = self.eval_context_mut();
|
||||||
|
|
||||||
match strip_linker_suffix(&link_name.as_str()) {
|
match &*link_name.as_str() {
|
||||||
// errno
|
// errno
|
||||||
"__error" => {
|
"__error" => {
|
||||||
let &[] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
|
let &[] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
|
||||||
|
@ -6,7 +6,6 @@ use rustc_target::abi::Size;
|
|||||||
use rustc_target::spec::abi::Abi;
|
use rustc_target::spec::abi::Abi;
|
||||||
|
|
||||||
use crate::*;
|
use crate::*;
|
||||||
use helpers::strip_linker_suffix;
|
|
||||||
use shims::foreign_items::EmulateByNameResult;
|
use shims::foreign_items::EmulateByNameResult;
|
||||||
use shims::windows::sync::EvalContextExt as _;
|
use shims::windows::sync::EvalContextExt as _;
|
||||||
|
|
||||||
@ -27,7 +26,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||||||
// DWORD = ULONG = u32
|
// DWORD = ULONG = u32
|
||||||
// BOOL = i32
|
// BOOL = i32
|
||||||
// BOOLEAN = u8
|
// BOOLEAN = u8
|
||||||
match strip_linker_suffix(&link_name.as_str()) {
|
match &*link_name.as_str() {
|
||||||
// Environment related shims
|
// Environment related shims
|
||||||
"GetEnvironmentVariableW" => {
|
"GetEnvironmentVariableW" => {
|
||||||
let &[ref name, ref buf, ref size] =
|
let &[ref name, ref buf, ref size] =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user