]> git.lizzy.rs Git - rust.git/commitdiff
Remove `strip_linker_suffix`
authorhyd-dev <yd-huang@outlook.com>
Mon, 14 Jun 2021 17:16:38 +0000 (01:16 +0800)
committerhyd-dev <yd-huang@outlook.com>
Mon, 14 Jun 2021 17:16:38 +0000 (01:16 +0800)
src/helpers.rs
src/shims/foreign_items.rs
src/shims/posix/foreign_items.rs
src/shims/posix/linux/foreign_items.rs
src/shims/posix/macos/foreign_items.rs
src/shims/windows/foreign_items.rs

index 1a12d19e124e8b4c3c771ac084012c0d2380d085..b99a446577ac43d8c12474ce4a0770e75c29bbad 100644 (file)
@@ -723,11 +723,6 @@ pub fn check_arg_count<'a, 'tcx, const N: usize>(
     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> {
     throw_machine_stop!(TerminationInfo::UnsupportedInIsolation(format!(
         "{} not available when isolation is enabled",
index 36d075e32dff2575d8f06b273aeb7b77143b6c7d..3745b8cf2fa1d4ca37adee9afc2a7a45f281893c 100644 (file)
@@ -25,7 +25,6 @@
 
 use super::backtrace::EvalContextExt as _;
 use crate::*;
-use helpers::strip_linker_suffix;
 
 /// Returned by `emulate_foreign_item_by_name`.
 pub enum EmulateByNameResult {
@@ -216,12 +215,11 @@ fn emulate_foreign_item(
             .first_attr_value_str_by_name(&attrs, sym::link_name)
             .unwrap_or_else(|| this.tcx.item_name(def_id));
         let link_name = link_name_sym.as_str();
-        let link_name = strip_linker_suffix(&link_name);
         let tcx = this.tcx.tcx;
 
         // First: functions that diverge.
         let (dest, ret) = match ret {
-            None => match link_name {
+            None => match &*link_name {
                 "miri_start_panic" => {
                     // `check_shim` happens inside `handle_miri_start_panic`.
                     this.handle_miri_start_panic(abi, link_name_sym, args, unwind)?;
@@ -306,9 +304,7 @@ fn emulate_foreign_item_by_name(
 
         // Here we dispatch all the shims for foreign functions. If you have a platform specific
         // shim, add it to the corresponding submodule.
-        let shim_name = link_name.as_str();
-        let shim_name = strip_linker_suffix(&shim_name);
-        match shim_name {
+        match &*link_name.as_str() {
             // Miri-specific extern functions
             "miri_static_root" => {
                 let &[ref ptr] = this.check_shim(abi, Abi::Rust, link_name, args)?;
@@ -499,7 +495,7 @@ fn emulate_foreign_item_by_name(
                 let &[ref f] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
                 // FIXME: Using host floats.
                 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(),
                     "coshf" => f.cosh(),
                     "sinhf" => f.sinh(),
@@ -522,7 +518,7 @@ fn emulate_foreign_item_by_name(
                 // FIXME: Using host floats.
                 let f1 = f32::from_bits(this.read_scalar(f1)?.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),
                     "atan2f" => f1.atan2(f2),
                     _ => bug!(),
@@ -541,7 +537,7 @@ fn emulate_foreign_item_by_name(
                 let &[ref f] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
                 // FIXME: Using host floats.
                 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(),
                     "cosh" => f.cosh(),
                     "sinh" => f.sinh(),
@@ -562,7 +558,7 @@ fn emulate_foreign_item_by_name(
                 // FIXME: Using host floats.
                 let f1 = f64::from_bits(this.read_scalar(f1)?.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),
                     "atan2" => f1.atan2(f2),
                     _ => bug!(),
index 2585b562f2304066a0b176ada7d8c2e97c9e73c2..4035deff63ef048e8e7d01563fc0414c1401ec74 100644 (file)
@@ -6,7 +6,6 @@
 use rustc_target::spec::abi::Abi;
 
 use crate::*;
-use helpers::strip_linker_suffix;
 use shims::foreign_items::EmulateByNameResult;
 use shims::posix::fs::EvalContextExt as _;
 use shims::posix::sync::EvalContextExt as _;
@@ -24,7 +23,7 @@ fn emulate_foreign_item_by_name(
     ) -> InterpResult<'tcx, EmulateByNameResult> {
         let this = self.eval_context_mut();
 
-        match strip_linker_suffix(&link_name.as_str()) {
+        match &*link_name.as_str() {
             // Environment related shims
             "getenv" => {
                 let &[ref name] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
index 160e27f395e5e34b304f6bfa22560490ae512a45..33889963bc4481bcbaacb112290d71355b55a14d 100644 (file)
@@ -3,7 +3,6 @@
 use rustc_target::spec::abi::Abi;
 
 use crate::*;
-use helpers::strip_linker_suffix;
 use shims::foreign_items::EmulateByNameResult;
 use shims::posix::fs::EvalContextExt as _;
 use shims::posix::linux::sync::futex;
@@ -22,7 +21,7 @@ fn emulate_foreign_item_by_name(
     ) -> InterpResult<'tcx, EmulateByNameResult> {
         let this = self.eval_context_mut();
 
-        match strip_linker_suffix(&link_name.as_str()) {
+        match &*link_name.as_str() {
             // errno
             "__errno_location" => {
                 let &[] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
index 45d6f5b449534ea2e47144fb203e50b8cc2faff3..47a860b96a87a1e37b3a99d9ad824a0864b5d5da 100644 (file)
@@ -3,7 +3,6 @@
 use rustc_target::spec::abi::Abi;
 
 use crate::*;
-use helpers::strip_linker_suffix;
 use shims::foreign_items::EmulateByNameResult;
 use shims::posix::fs::EvalContextExt as _;
 use shims::posix::thread::EvalContextExt as _;
@@ -20,7 +19,7 @@ fn emulate_foreign_item_by_name(
     ) -> InterpResult<'tcx, EmulateByNameResult> {
         let this = self.eval_context_mut();
 
-        match strip_linker_suffix(&link_name.as_str()) {
+        match &*link_name.as_str() {
             // errno
             "__error" => {
                 let &[] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
index 77f8075361418f0944617b6b5b7e044a63f625dd..1921af359423917fe9fc2561575f1f8df2f4ce1f 100644 (file)
@@ -6,7 +6,6 @@
 use rustc_target::spec::abi::Abi;
 
 use crate::*;
-use helpers::strip_linker_suffix;
 use shims::foreign_items::EmulateByNameResult;
 use shims::windows::sync::EvalContextExt as _;
 
@@ -27,7 +26,7 @@ fn emulate_foreign_item_by_name(
         // DWORD = ULONG = u32
         // BOOL = i32
         // BOOLEAN = u8
-        match strip_linker_suffix(&link_name.as_str()) {
+        match &*link_name.as_str() {
             // Environment related shims
             "GetEnvironmentVariableW" => {
                 let &[ref name, ref buf, ref size] =