Skip to content

Commit 9011524

Browse files
author
hyd-dev
committed
Remove strip_linker_suffix
1 parent a67a653 commit 9011524

File tree

6 files changed

+10
-23
lines changed

6 files changed

+10
-23
lines changed

src/helpers.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -723,11 +723,6 @@ where
723723
throw_ub_format!("incorrect number of arguments: got {}, expected {}", args.len(), N)
724724
}
725725

726-
/// Strip linker suffixes (seen on 32-bit macOS).
727-
pub fn strip_linker_suffix(link_name: &str) -> &str {
728-
link_name.trim_end_matches("$UNIX2003")
729-
}
730-
731726
pub fn isolation_abort_error(name: &str) -> InterpResult<'static> {
732727
throw_machine_stop!(TerminationInfo::UnsupportedInIsolation(format!(
733728
"{} not available when isolation is enabled",

src/shims/foreign_items.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use rustc_target::{
2525

2626
use super::backtrace::EvalContextExt as _;
2727
use crate::*;
28-
use helpers::strip_linker_suffix;
2928

3029
/// Returned by `emulate_foreign_item_by_name`.
3130
pub enum EmulateByNameResult {
@@ -216,12 +215,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
216215
.first_attr_value_str_by_name(&attrs, sym::link_name)
217216
.unwrap_or_else(|| this.tcx.item_name(def_id));
218217
let link_name = link_name_sym.as_str();
219-
let link_name = strip_linker_suffix(&link_name);
220218
let tcx = this.tcx.tcx;
221219

222220
// First: functions that diverge.
223221
let (dest, ret) = match ret {
224-
None => match link_name {
222+
None => match &*link_name {
225223
"miri_start_panic" => {
226224
// `check_shim` happens inside `handle_miri_start_panic`.
227225
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
306304

307305
// Here we dispatch all the shims for foreign functions. If you have a platform specific
308306
// shim, add it to the corresponding submodule.
309-
let shim_name = link_name.as_str();
310-
let shim_name = strip_linker_suffix(&shim_name);
311-
match shim_name {
307+
match &*link_name.as_str() {
312308
// Miri-specific extern functions
313309
"miri_static_root" => {
314310
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
499495
let &[ref f] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
500496
// FIXME: Using host floats.
501497
let f = f32::from_bits(this.read_scalar(f)?.to_u32()?);
502-
let f = match shim_name {
498+
let f = match &*link_name.as_str() {
503499
"cbrtf" => f.cbrt(),
504500
"coshf" => f.cosh(),
505501
"sinhf" => f.sinh(),
@@ -522,7 +518,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
522518
// FIXME: Using host floats.
523519
let f1 = f32::from_bits(this.read_scalar(f1)?.to_u32()?);
524520
let f2 = f32::from_bits(this.read_scalar(f2)?.to_u32()?);
525-
let n = match shim_name {
521+
let n = match &*link_name.as_str() {
526522
"_hypotf" | "hypotf" => f1.hypot(f2),
527523
"atan2f" => f1.atan2(f2),
528524
_ => bug!(),
@@ -541,7 +537,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
541537
let &[ref f] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
542538
// FIXME: Using host floats.
543539
let f = f64::from_bits(this.read_scalar(f)?.to_u64()?);
544-
let f = match shim_name {
540+
let f = match &*link_name.as_str() {
545541
"cbrt" => f.cbrt(),
546542
"cosh" => f.cosh(),
547543
"sinh" => f.sinh(),
@@ -562,7 +558,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
562558
// FIXME: Using host floats.
563559
let f1 = f64::from_bits(this.read_scalar(f1)?.to_u64()?);
564560
let f2 = f64::from_bits(this.read_scalar(f2)?.to_u64()?);
565-
let n = match shim_name {
561+
let n = match &*link_name.as_str() {
566562
"_hypot" | "hypot" => f1.hypot(f2),
567563
"atan2" => f1.atan2(f2),
568564
_ => bug!(),

src/shims/posix/foreign_items.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use rustc_target::abi::{Align, LayoutOf, Size};
66
use rustc_target::spec::abi::Abi;
77

88
use crate::*;
9-
use helpers::strip_linker_suffix;
109
use shims::foreign_items::EmulateByNameResult;
1110
use shims::posix::fs::EvalContextExt as _;
1211
use shims::posix::sync::EvalContextExt as _;
@@ -24,7 +23,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
2423
) -> InterpResult<'tcx, EmulateByNameResult> {
2524
let this = self.eval_context_mut();
2625

27-
match strip_linker_suffix(&link_name.as_str()) {
26+
match &*link_name.as_str() {
2827
// Environment related shims
2928
"getenv" => {
3029
let &[ref name] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;

src/shims/posix/linux/foreign_items.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use rustc_span::Symbol;
33
use rustc_target::spec::abi::Abi;
44

55
use crate::*;
6-
use helpers::strip_linker_suffix;
76
use shims::foreign_items::EmulateByNameResult;
87
use shims::posix::fs::EvalContextExt as _;
98
use shims::posix::linux::sync::futex;
@@ -22,7 +21,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
2221
) -> InterpResult<'tcx, EmulateByNameResult> {
2322
let this = self.eval_context_mut();
2423

25-
match strip_linker_suffix(&link_name.as_str()) {
24+
match &*link_name.as_str() {
2625
// errno
2726
"__errno_location" => {
2827
let &[] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;

src/shims/posix/macos/foreign_items.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use rustc_span::Symbol;
33
use rustc_target::spec::abi::Abi;
44

55
use crate::*;
6-
use helpers::strip_linker_suffix;
76
use shims::foreign_items::EmulateByNameResult;
87
use shims::posix::fs::EvalContextExt as _;
98
use shims::posix::thread::EvalContextExt as _;
@@ -20,7 +19,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
2019
) -> InterpResult<'tcx, EmulateByNameResult> {
2120
let this = self.eval_context_mut();
2221

23-
match strip_linker_suffix(&link_name.as_str()) {
22+
match &*link_name.as_str() {
2423
// errno
2524
"__error" => {
2625
let &[] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;

src/shims/windows/foreign_items.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use rustc_target::abi::Size;
66
use rustc_target::spec::abi::Abi;
77

88
use crate::*;
9-
use helpers::strip_linker_suffix;
109
use shims::foreign_items::EmulateByNameResult;
1110
use shims::windows::sync::EvalContextExt as _;
1211

@@ -27,7 +26,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
2726
// DWORD = ULONG = u32
2827
// BOOL = i32
2928
// BOOLEAN = u8
30-
match strip_linker_suffix(&link_name.as_str()) {
29+
match &*link_name.as_str() {
3130
// Environment related shims
3231
"GetEnvironmentVariableW" => {
3332
let &[ref name, ref buf, ref size] =

0 commit comments

Comments
 (0)