From dc09b6ff770a0045a4086b0f8a6d2e59cf5b49f8 Mon Sep 17 00:00:00 2001 From: Matt Ickstadt Date: Tue, 16 Aug 2016 13:29:04 -0500 Subject: [PATCH 1/2] Use link_args to alias arm builtins --- src/arm.rs | 45 ++++++++++++--------------------------------- src/lib.rs | 1 + 2 files changed, 13 insertions(+), 33 deletions(-) diff --git a/src/arm.rs b/src/arm.rs index ad2b39a2..ba0e023a 100644 --- a/src/arm.rs +++ b/src/arm.rs @@ -36,57 +36,36 @@ extern "C" { fn memset(dest: *mut u8, c: i32, n: usize) -> *mut u8; } -// FIXME: The `*4` and `*8` variants should be defined as aliases. +// Create aliases for the *4 and *8 variants +#[link_args = "-Wl,--defsym=__aeabi_memcpy4=__aeabi_memcpy -Wl,--defsym=__aeabi_memcpy8=__aeabi_memcpy"] +extern {} #[cfg_attr(not(test), no_mangle)] pub unsafe extern "C" fn __aeabi_memcpy(dest: *mut u8, src: *const u8, n: usize) { memcpy(dest, src, n); } -#[cfg_attr(not(test), no_mangle)] -pub unsafe extern "C" fn __aeabi_memcpy4(dest: *mut u8, src: *const u8, n: usize) { - memcpy(dest, src, n); -} -#[cfg_attr(not(test), no_mangle)] -pub unsafe extern "C" fn __aeabi_memcpy8(dest: *mut u8, src: *const u8, n: usize) { - memcpy(dest, src, n); -} + +#[link_args = "-Wl,--defsym=__aeabi_memmove4=__aeabi_memmove -Wl,--defsym=__aeabi_memmove8=__aeabi_memmove"] +extern {} #[cfg_attr(not(test), no_mangle)] pub unsafe extern "C" fn __aeabi_memmove(dest: *mut u8, src: *const u8, n: usize) { memmove(dest, src, n); } -#[cfg_attr(not(test), no_mangle)] -pub unsafe extern "C" fn __aeabi_memmove4(dest: *mut u8, src: *const u8, n: usize) { - memmove(dest, src, n); -} -#[cfg_attr(not(test), no_mangle)] -pub unsafe extern "C" fn __aeabi_memmove8(dest: *mut u8, src: *const u8, n: usize) { - memmove(dest, src, n); -} + +#[link_args = "-Wl,--defsym=__aeabi_memset4=__aeabi_memset -Wl,--defsym=__aeabi_memset8=__aeabi_memset"] +extern {} // Note the different argument order #[cfg_attr(not(test), no_mangle)] pub unsafe extern "C" fn __aeabi_memset(dest: *mut u8, n: usize, c: i32) { memset(dest, c, n); } -#[cfg_attr(not(test), no_mangle)] -pub unsafe extern "C" fn __aeabi_memset4(dest: *mut u8, n: usize, c: i32) { - memset(dest, c, n); -} -#[cfg_attr(not(test), no_mangle)] -pub unsafe extern "C" fn __aeabi_memset8(dest: *mut u8, n: usize, c: i32) { - memset(dest, c, n); -} + +#[link_args = "-Wl,--defsym=__aeabi_memclr4=__aeabi_memclr -Wl,--defsym=__aeabi_memclr8=__aeabi_memclr"] +extern {} #[cfg_attr(not(test), no_mangle)] pub unsafe extern "C" fn __aeabi_memclr(dest: *mut u8, n: usize) { memset(dest, 0, n); } -#[cfg_attr(not(test), no_mangle)] -pub unsafe extern "C" fn __aeabi_memclr4(dest: *mut u8, n: usize) { - memset(dest, 0, n); -} -#[cfg_attr(not(test), no_mangle)] -pub unsafe extern "C" fn __aeabi_memclr8(dest: *mut u8, n: usize) { - memset(dest, 0, n); -} diff --git a/src/lib.rs b/src/lib.rs index 2263fda0..d59f48aa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,7 @@ #![feature(asm)] #![feature(core_intrinsics)] #![feature(linkage)] +#![feature(link_args)] #![feature(naked_functions)] #![cfg_attr(not(test), no_std)] #![no_builtins] From 517193f1c069d34bc3d3cdeddcda6298e149515c Mon Sep 17 00:00:00 2001 From: Matt Ickstadt Date: Tue, 16 Aug 2016 17:54:26 -0500 Subject: [PATCH 2/2] Don't use link_args for test builds --- src/arm.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/arm.rs b/src/arm.rs index ba0e023a..16061790 100644 --- a/src/arm.rs +++ b/src/arm.rs @@ -37,6 +37,7 @@ extern "C" { } // Create aliases for the *4 and *8 variants +#[cfg(not(test))] #[link_args = "-Wl,--defsym=__aeabi_memcpy4=__aeabi_memcpy -Wl,--defsym=__aeabi_memcpy8=__aeabi_memcpy"] extern {} @@ -45,6 +46,7 @@ pub unsafe extern "C" fn __aeabi_memcpy(dest: *mut u8, src: *const u8, n: usize) memcpy(dest, src, n); } +#[cfg(not(test))] #[link_args = "-Wl,--defsym=__aeabi_memmove4=__aeabi_memmove -Wl,--defsym=__aeabi_memmove8=__aeabi_memmove"] extern {} @@ -53,6 +55,7 @@ pub unsafe extern "C" fn __aeabi_memmove(dest: *mut u8, src: *const u8, n: usize memmove(dest, src, n); } +#[cfg(not(test))] #[link_args = "-Wl,--defsym=__aeabi_memset4=__aeabi_memset -Wl,--defsym=__aeabi_memset8=__aeabi_memset"] extern {} @@ -62,6 +65,7 @@ pub unsafe extern "C" fn __aeabi_memset(dest: *mut u8, n: usize, c: i32) { memset(dest, c, n); } +#[cfg(not(test))] #[link_args = "-Wl,--defsym=__aeabi_memclr4=__aeabi_memclr -Wl,--defsym=__aeabi_memclr8=__aeabi_memclr"] extern {}