diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c934a877b..ceffaabed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -206,7 +206,10 @@ jobs: - name: Setup SDK environment if: matrix.sdk # This changes a variable, so is only set when a custom SDK is used - run: echo "SDKROOT=$HOME/extern/sdk" >> $GITHUB_ENV + run: | + echo "SDKROOT=$HOME/extern/sdk" >> $GITHUB_ENV + # Temporary + echo "RUSTFLAGS=$RUSTFLAGS --cfg=macos_10_7" >> $GITHUB_ENV - name: Install Clang & Valgrind if: contains(matrix.os, 'ubuntu') @@ -395,12 +398,12 @@ jobs: # Not using --all-features because that would enable e.g. gnustep args: ${{ env.ARGS }} ${{ env.TESTARGS }} --features ${{ env.FEATURES }},${{ env.UNSTABLE_FEATURES }} - - name: Test static selectors + - name: Test static class and selectors if: ${{ !matrix.dinghy && (matrix.runtime || 'apple') == 'apple' }} uses: actions-rs/cargo@v1 with: command: test - args: ${{ env.ARGS }} ${{ env.TESTARGS }} --features unstable-static-sel + args: ${{ env.ARGS }} ${{ env.TESTARGS }} --features unstable-static-sel,unstable-static-class - name: Run assembly tests if: ${{ !contains(matrix.runtime, 'compiler-rt') }} diff --git a/helper-scripts/test-local.fish b/helper-scripts/test-local.fish index cd729948e..b69c13234 100755 --- a/helper-scripts/test-local.fish +++ b/helper-scripts/test-local.fish @@ -34,5 +34,5 @@ rm -d .cargo export SDKROOT=(pwd)/ideas/MacOSX10.13.sdk export CARGO_BUILD_TARGET=i686-apple-darwin cargo +nightly test -Zbuild-std -cargo +nightly test -Zbuild-std --features malloc,block,exception,catch-all,verify_message +cargo +nightly test -Zbuild-std --features malloc,block,exception,catch-all,verify_message,unstable-static-class,unstable-static-sel cargo +nightly test -Zbuild-std --release diff --git a/objc2-foundation/examples/declaration.rs b/objc2-foundation/examples/declaration.rs index 9e18ff06b..06d9eb4bb 100644 --- a/objc2-foundation/examples/declaration.rs +++ b/objc2-foundation/examples/declaration.rs @@ -1,18 +1,22 @@ +#[cfg(all(feature = "apple", target_os = "macos"))] use objc2::{ msg_send, msg_send_id, rc::{Id, Shared}, runtime::{Bool, Object}, }; +#[cfg(all(feature = "apple", target_os = "macos"))] use objc2_foundation::{declare_class, extern_class, NSObject}; #[cfg(all(feature = "apple", target_os = "macos"))] #[link(name = "AppKit", kind = "framework")] extern "C" {} +#[cfg(all(feature = "apple", target_os = "macos"))] extern_class! { unsafe struct NSResponder: NSObject; } +#[cfg(all(feature = "apple", target_os = "macos"))] declare_class! { unsafe struct CustomAppDelegate: NSResponder, NSObject { pub ivar: u8, @@ -66,6 +70,7 @@ declare_class! { } } +#[cfg(all(feature = "apple", target_os = "macos"))] impl CustomAppDelegate { pub fn new(ivar: u8, another_ivar: bool) -> Id { let cls = Self::class(); @@ -80,9 +85,15 @@ impl CustomAppDelegate { } } +#[cfg(all(feature = "apple", target_os = "macos"))] fn main() { let delegate = CustomAppDelegate::new(42, true); println!("{}", delegate.ivar); println!("{}", delegate.another_ivar.as_bool()); } + +#[cfg(not(all(feature = "apple", target_os = "macos")))] +fn main() { + panic!("This example uses AppKit, which is only present on macOS"); +} diff --git a/objc2-foundation/examples/nspasteboard.rs b/objc2-foundation/examples/nspasteboard.rs index 28c6a0d93..20187399e 100644 --- a/objc2-foundation/examples/nspasteboard.rs +++ b/objc2-foundation/examples/nspasteboard.rs @@ -7,7 +7,7 @@ use std::ops::{Deref, DerefMut}; use objc2::rc::{Id, Shared}; use objc2::runtime::{Class, Object}; -use objc2::{class, msg_send, msg_send_bool, msg_send_id}; +use objc2::{msg_send, msg_send_bool, msg_send_id}; use objc2::{Encoding, Message, RefEncode}; use objc2_foundation::{NSArray, NSDictionary, NSInteger, NSObject, NSString}; @@ -59,7 +59,14 @@ impl DerefMut for NSPasteboard { impl NSPasteboard { /// Common convenience method. pub fn class() -> &'static Class { - class!(NSPasteboard) + #[cfg(all(feature = "apple", target_os = "macos"))] + { + objc2::class!(NSPasteboard) + } + #[cfg(not(all(feature = "apple", target_os = "macos")))] + { + panic!("this example only works on macOS") + } } /// We return a `Shared` `Id` because `general` can easily be called diff --git a/objc2-foundation/examples/nsspeechsynthesizer.rs b/objc2-foundation/examples/nsspeechsynthesizer.rs index 479630b26..4963a98c5 100644 --- a/objc2-foundation/examples/nsspeechsynthesizer.rs +++ b/objc2-foundation/examples/nsspeechsynthesizer.rs @@ -8,7 +8,7 @@ use std::time::Duration; use objc2::rc::{Id, Owned}; use objc2::runtime::Class; -use objc2::{class, msg_send, msg_send_bool, msg_send_id}; +use objc2::{msg_send, msg_send_bool, msg_send_id}; use objc2::{Encoding, Message, RefEncode}; use objc2_foundation::{NSObject, NSString}; @@ -47,7 +47,14 @@ impl DerefMut for NSSpeechSynthesizer { // TODO: Unsure about when to use `&mut` here? impl NSSpeechSynthesizer { pub fn class() -> &'static Class { - class!(NSSpeechSynthesizer) + #[cfg(all(feature = "apple", target_os = "macos"))] + { + objc2::class!(NSSpeechSynthesizer) + } + #[cfg(not(all(feature = "apple", target_os = "macos")))] + { + panic!("this example only works on macOS") + } } // Uses default voice diff --git a/objc2-foundation/src/declare_macro.rs b/objc2-foundation/src/declare_macro.rs index a2a1c3509..9b4b2335a 100644 --- a/objc2-foundation/src/declare_macro.rs +++ b/objc2-foundation/src/declare_macro.rs @@ -515,7 +515,7 @@ macro_rules! declare_class { use $crate::__std::sync::Once; use $crate::objc2::declare::ClassBuilder; - use $crate::objc2::runtime::Protocol; + use $crate::objc2::runtime::{Class, Protocol}; static REGISTER_CLASS: Once = Once::new(); REGISTER_CLASS.call_once(|| { @@ -555,7 +555,8 @@ macro_rules! declare_class { let _cls = builder.register(); }); - $crate::objc2::class!($name) + // We just registered the class, so it should be available + Class::get(stringify!($name)).unwrap() } } diff --git a/objc2-foundation/src/lib.rs b/objc2-foundation/src/lib.rs index fc0dc0f03..ecd6bb6d2 100644 --- a/objc2-foundation/src/lib.rs +++ b/objc2-foundation/src/lib.rs @@ -66,6 +66,7 @@ pub use self::process_info::NSProcessInfo; pub use self::range::NSRange; pub use self::string::NSString; pub use self::thread::{is_main_thread, is_multi_threaded, MainThreadMarker, NSThread}; +#[cfg(not(macos_10_7))] // Temporary pub use self::uuid::NSUUID; pub use self::value::NSValue; pub use self::zone::NSZone; @@ -112,6 +113,8 @@ mod process_info; mod range; mod string; mod thread; +// Temporarily disable testing UUID on macOS 10.7 until +#[cfg(not(macos_10_7))] mod uuid; mod value; mod zone; @@ -175,6 +178,7 @@ mod tests { assert_auto_traits::(); assert_unwindsafe::(); // Intentional assert_auto_traits::(); + #[cfg(not(macos_10_7))] assert_auto_traits::(); assert_auto_traits::>(); assert_unwindsafe::(); // Intentional diff --git a/objc2-foundation/src/uuid.rs b/objc2-foundation/src/uuid.rs index 71f413de1..726ffe641 100644 --- a/objc2-foundation/src/uuid.rs +++ b/objc2-foundation/src/uuid.rs @@ -15,6 +15,8 @@ extern_class! { /// Conversion methods to/from UUIDs from the `uuid` crate can be /// enabled with the `uuid` crate feature. /// + /// macOS: This is only available on 10.8 and above. + /// /// See [Apple's documentation](https://developer.apple.com/documentation/foundation/nsuuid?language=objc). #[derive(PartialEq, Eq, Hash)] unsafe pub struct NSUUID: NSObject; diff --git a/objc2/CHANGELOG.md b/objc2/CHANGELOG.md index 2ee5762e1..6f8fa44bc 100644 --- a/objc2/CHANGELOG.md +++ b/objc2/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased - YYYY-MM-DD +### Added +* Added the `"unstable-static-class"` and `"unstable-static-class-inlined"` + feature flags to make the `class!` macro zero cost. + ## 0.3.0-beta.1 - 2022-07-19 diff --git a/objc2/Cargo.toml b/objc2/Cargo.toml index 675b15e8c..715e39f7d 100644 --- a/objc2/Cargo.toml +++ b/objc2/Cargo.toml @@ -51,6 +51,8 @@ malloc = ["malloc_buf"] # https://github.com/madsmtm/objc2/issues/new unstable-static-sel = ["objc2-proc-macros"] unstable-static-sel-inlined = ["unstable-static-sel"] +unstable-static-class = ["objc2-proc-macros"] +unstable-static-class-inlined = ["unstable-static-class"] # Uses nightly features to make AutoreleasePool zero-cost even in debug mode unstable-autoreleasesafe = [] diff --git a/objc2/examples/introspection.rs b/objc2/examples/introspection.rs index 9d71d8155..685cf09ce 100644 --- a/objc2/examples/introspection.rs +++ b/objc2/examples/introspection.rs @@ -4,6 +4,10 @@ use objc2::{class, msg_send, msg_send_id}; #[cfg(feature = "malloc")] use objc2::{sel, Encode}; +#[cfg(feature = "apple")] +#[link(name = "Foundation", kind = "framework")] +extern "C" {} + fn main() { // Get a class let cls = class!(NSObject); diff --git a/objc2/examples/talk_to_me.rs b/objc2/examples/talk_to_me.rs index 7e5b4ea1e..e3a4b387b 100644 --- a/objc2/examples/talk_to_me.rs +++ b/objc2/examples/talk_to_me.rs @@ -3,19 +3,29 @@ //! **Untested**! //! //! Works on macOS >= 10.15 or iOS > 7.0! -use objc2::ffi::NSUInteger; -use objc2::rc::{Id, Owned, Shared}; -use objc2::runtime::Object; -use objc2::{class, msg_send, msg_send_bool, msg_send_id}; -use std::ffi::c_void; -#[cfg(feature = "apple")] -#[link(name = "AVFoundation", kind = "framework")] -extern "C" {} - -const UTF8_ENCODING: NSUInteger = 4; +#[cfg(not(talk_to_me_example))] +fn main() { + panic!("pass the `--cfg talk_to_me_example` flag to run this example!"); +} +#[cfg(talk_to_me_example)] fn main() { + use objc2::ffi::NSUInteger; + use objc2::rc::{Id, Owned, Shared}; + use objc2::runtime::Object; + use objc2::{class, msg_send, msg_send_bool, msg_send_id}; + use std::ffi::c_void; + + #[cfg(feature = "apple")] + #[link(name = "AVFoundation", kind = "framework")] + extern "C" {} + #[cfg(feature = "apple")] + #[link(name = "Foundation", kind = "framework")] + extern "C" {} + + const UTF8_ENCODING: NSUInteger = 4; + let text = "Hello from Rust!"; // Note: objc2-foundation has functionality to do this safely! diff --git a/objc2/src/__macro_helpers.rs b/objc2/src/__macro_helpers.rs index 15ce2cded..277785810 100644 --- a/objc2/src/__macro_helpers.rs +++ b/objc2/src/__macro_helpers.rs @@ -211,6 +211,35 @@ pub const fn in_selector_family(mut selector: &[u8], mut family: &[u8]) -> bool } } +/// Helper struct for emitting the module info that macOS 32-bit requires. +/// +/// +#[repr(C)] +pub struct ModuleInfo { + version: usize, + size: usize, + name: *const u8, + symtab: *const (), +} + +// SAFETY: ModuleInfo is immutable. +unsafe impl Sync for ModuleInfo {} + +impl ModuleInfo { + /// This is hardcoded in clang as 7. + const VERSION: usize = 7; + + pub const fn new(name: *const u8) -> Self { + Self { + version: Self::VERSION, + size: core::mem::size_of::(), + name, + // We don't expose any symbols + symtab: core::ptr::null(), + } + } +} + #[cfg(test)] mod tests { use super::*; @@ -441,4 +470,13 @@ mod tests { // to be different! assert_eq!(ident1, ident2); } + + #[test] + #[cfg_attr( + not(all(feature = "apple", target_os = "macos", target_arch = "x86")), + ignore = "Only relevant on macOS 32-bit" + )] + fn ensure_size_of_module_info() { + assert_eq!(core::mem::size_of::(), 16); + } } diff --git a/objc2/src/lib.rs b/objc2/src/lib.rs index a2993ccb5..01a951476 100644 --- a/objc2/src/lib.rs +++ b/objc2/src/lib.rs @@ -218,6 +218,11 @@ mod test_utils; #[cfg(feature = "malloc")] mod verify; +// Hack to make doctests work +#[cfg(all(feature = "apple", feature = "unstable-static-class"))] +#[link(name = "Foundation", kind = "framework")] +extern "C" {} + /// Hacky way to make GNUStep link properly to Foundation while testing. /// /// This is a temporary solution to make our CI work for now! diff --git a/objc2/src/macros.rs b/objc2/src/macros.rs index 9c133682f..2d2ad9ef9 100644 --- a/objc2/src/macros.rs +++ b/objc2/src/macros.rs @@ -1,14 +1,36 @@ /// Gets a reference to a [`Class`] from the given name. /// +/// [`Class`]: crate::runtime::Class +/// +/// /// # Panics /// /// Panics if no class with the given name can be found. /// /// To check for a class that may not exist, use [`Class::get`]. /// -/// [`Class`]: crate::runtime::Class /// [`Class::get`]: crate::runtime::Class::get /// +/// +/// # Features +/// +/// If the experimental `"unstable-static-class"` feature is enabled, this +/// will emit special statics that will be replaced by dyld when the program +/// starts up. +/// +/// Errors that were previously runtime panics may now turn into linker errors +/// if you try to use a class which is not available. Additionally, you may +/// have to call `msg_send![cls, class]` on the result if you want to use it +/// in a dynamic context (e.g. dynamically declaring classes). +/// +/// See the [corresponding section][sel#features] in the [`sel!`] macro for +/// more details on the limitations of this. The +/// `"unstable-static-class-inlined"` corresponds to the +/// `"unstable-static-sel-inlined"` feature here. +/// +/// [sel#features]: crate::sel#features +/// [`sel!`]: crate::sel +/// /// # Examples /// /// ```no_run @@ -17,6 +39,15 @@ /// ``` #[macro_export] macro_rules! class { + ($name:ident) => {{ + $crate::__class_inner!($name) + }}; +} + +#[doc(hidden)] +#[macro_export] +#[cfg(not(feature = "unstable-static-class"))] +macro_rules! __class_inner { ($name:ident) => {{ use $crate::__macro_helpers::{concat, panic, stringify, CachedClass, None, Some}; static CACHED_CLASS: CachedClass = CachedClass::new(); @@ -177,18 +208,26 @@ macro_rules! __sel_inner { #[doc(hidden)] #[macro_export] -macro_rules! __sel_inner_statics_apple_generic { +macro_rules! __inner_statics_apple_generic { { + @string_to_known_length_bytes; + $x:ident; + } => {{ + // Convert the `&[u8]` slice to an array with known length, so + // that we can place that directly in a static. + let mut res: [u8; $x.len()] = [0; $x.len()]; + let mut i = 0; + while i < $x.len() { + res[i] = $x[i]; + i += 1; + } + res + }}; + { + @image_info; $image_info_section:literal; - $var_name_section:literal; - $selector_ref_section:literal; - $data:expr, $($idents:ident)+ } => { - use $crate::__macro_helpers::{u8, UnsafeCell}; - use $crate::ffi::__ImageInfo; - use $crate::runtime::Sel; - /// We always emit the image info tag, since we need it to: /// - End up in the same codegen unit as the other statics below. /// - End up in the final binary so it can be read by dyld. @@ -202,7 +241,43 @@ macro_rules! __sel_inner_statics_apple_generic { $crate::__macro_helpers::__hash_idents!($($idents)+), )] #[used] // Make sure this reaches the linker - static _IMAGE_INFO: __ImageInfo = __ImageInfo::system(); + static _IMAGE_INFO: $crate::ffi::__ImageInfo = $crate::ffi::__ImageInfo::system(); + }; + { + @module_info; + $($idents:ident)+ + } => { + #[link_section = "__TEXT,__cstring,cstring_literals"] + #[export_name = $crate::__macro_helpers::concat!( + "\x01L_OBJC_CLASS_NAME_", + $crate::__macro_helpers::__hash_idents!($($idents)+), + "_MODULE_INFO" + )] + static MODULE_INFO_NAME: [$crate::__macro_helpers::u8; 1] = [0]; + + /// Emit module info. + /// + /// This is similar to image info, and must be present in the final + /// binary on macOS 32-bit. + #[link_section = "__OBJC,__module_info,regular,no_dead_strip"] + #[export_name = $crate::__macro_helpers::concat!( + "\x01L_OBJC_MODULES_", + $crate::__macro_helpers::__hash_idents!($($idents)+) + )] + #[used] // Make sure this reaches the linker + static _MODULE_INFO: $crate::__macro_helpers::ModuleInfo = $crate::__macro_helpers::ModuleInfo::new( + MODULE_INFO_NAME.as_ptr() + ); + }; + { + @sel; + $var_name_section:literal; + $selector_ref_section:literal; + $data:expr, + $($idents:ident)+ + } => { + use $crate::__macro_helpers::{u8, UnsafeCell}; + use $crate::runtime::Sel; const X: &[u8] = $data.as_bytes(); @@ -214,16 +289,9 @@ macro_rules! __sel_inner_statics_apple_generic { "\x01L_OBJC_METH_VAR_NAME_", $crate::__macro_helpers::__hash_idents!($($idents)+), )] - static NAME_DATA: [u8; X.len()] = { - // Convert the `&[u8]` slice to an array with known length, so - // that we can place that directly in a static. - let mut res: [u8; X.len()] = [0; X.len()]; - let mut i = 0; - while i < X.len() { - res[i] = X[i]; - i += 1; - } - res + static NAME_DATA: [u8; X.len()] = $crate::__inner_statics_apple_generic! { + @string_to_known_length_bytes; + X; }; /// Place the constant value in the correct section. @@ -239,10 +307,6 @@ macro_rules! __sel_inner_statics_apple_generic { /// `static mut` is used so that we don't need to wrap the /// `UnsafeCell` in something that implements `Sync`. /// - /// Clang uses `no_dead_strip` in the link section for some reason, - /// which other tools (notably some LLVM tools) now assume is present, - /// so we have to add it as well. - /// /// /// # Safety /// @@ -262,47 +326,163 @@ macro_rules! __sel_inner_statics_apple_generic { UnsafeCell::new(Sel::__internal_from_ptr(NAME_DATA.as_ptr().cast())) }; }; + { + @class; + $name:ident + } => { + use $crate::__macro_helpers::UnsafeCell; + use $crate::runtime::Class; + + extern "C" { + /// Link to the Objective-C class static. + /// + /// This uses the special symbol that static and dynamic linkers + /// knows about. + /// + /// Failure modes: + /// - Unknown class: Static linker error. + /// - OS version < Class introduced version: Dynamic linker error + /// on program startup. + /// - Deployment target > Class introduced version: No error, + /// though _should_ be a static linker error. + /// + /// Ideally, we'd have some way of allowing this to be weakly + /// linked, and return `Option<&Class>` in that case, but Rust + /// doesn't have the capability to do so yet! + /// + /// + /// + #[link_name = $crate::__macro_helpers::concat!( + "OBJC_CLASS_$_", + $crate::__macro_helpers::stringify!($name), + )] + static CLASS: Class; + } + + /// SAFETY: Same as `REF` above in `@sel`. + #[link_section = "__DATA,__objc_classrefs,regular,no_dead_strip"] + #[export_name = $crate::__macro_helpers::concat!( + "\x01L_OBJC_CLASSLIST_REFERENCES_$_", + $crate::__macro_helpers::__hash_idents!($name), + )] + static mut REF: UnsafeCell<&Class> = unsafe { + UnsafeCell::new(&CLASS) + }; + }; + { + @class_old; + $name:ident + } => { + use $crate::__macro_helpers::{u8, UnsafeCell}; + use $crate::runtime::Class; + + const X: &[u8] = $crate::__macro_helpers::stringify!($name).as_bytes(); + + /// Similar to NAME_DATA above in `@sel`. + #[link_section = "__TEXT,__cstring,cstring_literals"] + #[export_name = $crate::__macro_helpers::concat!( + "\x01L_OBJC_CLASS_NAME_", + $crate::__macro_helpers::__hash_idents!($name), + )] + static NAME_DATA: [u8; X.len()] = $crate::__inner_statics_apple_generic! { + @string_to_known_length_bytes; + X; + }; + + /// SAFETY: Same as `REF` above in `@sel`. + #[link_section = "__OBJC,__cls_refs,literal_pointers,no_dead_strip"] + #[export_name = $crate::__macro_helpers::concat!( + "\x01L_OBJC_CLASS_REFERENCES_", + $crate::__macro_helpers::__hash_idents!($name), + )] + static mut REF: UnsafeCell<&Class> = unsafe { + let ptr: *const Class = NAME_DATA.as_ptr().cast(); + UnsafeCell::new(&*ptr) + }; + } } +// These sections are found by reading clang/LLVM sources #[doc(hidden)] #[macro_export] #[cfg(all(feature = "apple", not(all(target_os = "macos", target_arch = "x86"))))] -macro_rules! __sel_inner_statics { - ($($args:tt)*) => { - // Found by reading clang/LLVM sources - $crate::__sel_inner_statics_apple_generic! { +macro_rules! __inner_statics { + (@image_info $($args:tt)*) => { + $crate::__inner_statics_apple_generic! { + @image_info; "__DATA,__objc_imageinfo,regular,no_dead_strip"; + $($args)* + } + }; + (@sel $($args:tt)*) => { + $crate::__inner_statics_apple_generic! { + @sel; "__TEXT,__objc_methname,cstring_literals"; + // Clang uses `no_dead_strip` in the link section for some reason, + // which other tools (notably some LLVM tools) now assume is + // present, so we have to add it as well. "__DATA,__objc_selrefs,literal_pointers,no_dead_strip"; $($args)* } }; + (@class $($args:tt)*) => { + $crate::__inner_statics_apple_generic! { + @class; + $($args)* + } + }; } #[doc(hidden)] #[macro_export] #[cfg(all(feature = "apple", target_os = "macos", target_arch = "x86"))] -macro_rules! __sel_inner_statics { - ($($args:tt)*) => { - $crate::__sel_inner_statics_apple_generic! { +macro_rules! __inner_statics { + (@image_info $($args:tt)*) => { + $crate::__inner_statics_apple_generic! { + @image_info; "__OBJC,__image_info,regular"; + $($args)* + } + }; + (@sel $($args:tt)*) => { + $crate::__inner_statics_apple_generic! { + @sel; "__TEXT,__cstring,cstring_literals"; "__OBJC,__message_refs,literal_pointers,no_dead_strip"; $($args)* } }; + (@class $($args:tt)*) => { + $crate::__inner_statics_apple_generic! { + @class_old; + $($args)* + } + $crate::__inner_statics_apple_generic! { + @module_info; + $($args)* + } + }; } #[doc(hidden)] #[macro_export] #[cfg(not(feature = "apple"))] -macro_rules! __sel_inner_statics { - ($($args:tt)*) => { +macro_rules! __inner_statics { + (@image_info $($args:tt)*) => { + // TODO + }; + (@sel $($args:tt)*) => { // TODO $crate::__macro_helpers::compile_error!( "The `\"unstable-static-sel\"` feature is not yet supported on GNUStep!" ) }; + (@class $($args:tt)*) => { + // TODO + $crate::__macro_helpers::compile_error!( + "The `\"unstable-static-class\"` feature is not yet supported on GNUStep!" + ) + }; } #[doc(hidden)] @@ -312,8 +492,9 @@ macro_rules! __sel_inner_statics { not(feature = "unstable-static-sel-inlined") ))] macro_rules! __sel_inner { - ($($args:tt)*) => {{ - $crate::__sel_inner_statics!($($args)*); + ($data:expr, $($idents:ident)+) => {{ + $crate::__inner_statics!(@image_info $($idents)+); + $crate::__inner_statics!(@sel $data, $($idents)+); /// HACK: Wrap the access in a non-generic, `#[inline(never)]` /// function to make the compiler group it into the same codegen unit @@ -340,8 +521,44 @@ macro_rules! __sel_inner { #[macro_export] #[cfg(all(feature = "unstable-static-sel-inlined"))] macro_rules! __sel_inner { - ($($args:tt)*) => {{ - $crate::__sel_inner_statics!($($args)*); + ($data:expr, $($idents:ident)+) => {{ + $crate::__inner_statics!(@image_info $($idents)+); + $crate::__inner_statics!(@sel $data, $($idents)+); + + #[allow(unused_unsafe)] + // SAFETY: See above + unsafe { *REF.get() } + }}; +} + +#[doc(hidden)] +#[macro_export] +#[cfg(all( + feature = "unstable-static-class", + not(feature = "unstable-static-class-inlined") +))] +macro_rules! __class_inner { + ($name:ident) => {{ + $crate::__inner_statics!(@image_info $name); + $crate::__inner_statics!(@class $name); + + #[inline(never)] + fn objc_static_workaround() -> &'static Class { + // SAFETY: Same as __sel_inner + unsafe { *REF.get() } + } + + objc_static_workaround() + }}; +} + +#[doc(hidden)] +#[macro_export] +#[cfg(all(feature = "unstable-static-class-inlined"))] +macro_rules! __class_inner { + ($name:ident) => {{ + $crate::__inner_statics!(@image_info $name); + $crate::__inner_statics!(@class $name); #[allow(unused_unsafe)] // SAFETY: See above @@ -406,6 +623,7 @@ macro_rules! __sel_inner { /// [`MessageReceiver`]: crate::MessageReceiver /// [`rc::Id`]: crate::rc::Id /// [`Encode`]: crate::Encode +/// [`sel!`]: crate::sel /// [`MessageReceiver::send_message`]: crate::MessageReceiver::send_message /// /// diff --git a/objc2/src/rc/test_object.rs b/objc2/src/rc/test_object.rs index 1f875f0a1..2f37c1822 100644 --- a/objc2/src/rc/test_object.rs +++ b/objc2/src/rc/test_object.rs @@ -130,10 +130,11 @@ impl RcTestObject { builder.add_method(sel!(dealloc), dealloc as unsafe extern "C" fn(_, _)); } - builder.register(); + let _cls = builder.register(); }); - class!(RcTestObject) + // Can't use `class!` here since `RcTestObject` is dynamically created. + Class::get("RcTestObject").unwrap() } pub(crate) fn new() -> Id { diff --git a/objc2/src/test_utils.rs b/objc2/src/test_utils.rs index 69b1de52b..1c71d73d2 100644 --- a/objc2/src/test_utils.rs +++ b/objc2/src/test_utils.rs @@ -5,8 +5,8 @@ use std::sync::Once; use crate::declare::{ClassBuilder, ProtocolBuilder}; use crate::runtime::{Class, Object, Protocol, Sel}; -use crate::{class, msg_send, sel}; use crate::{ffi, Encode, Encoding, MessageReceiver}; +use crate::{msg_send, sel}; #[derive(Debug)] pub(crate) struct CustomObject { @@ -173,7 +173,8 @@ pub(crate) fn custom_class() -> &'static Class { builder.register(); }); - class!(CustomObject) + // Can't use `class!` here since `CustomObject` is dynamically created. + Class::get("CustomObject").unwrap() } pub(crate) fn custom_protocol() -> &'static Protocol { @@ -232,7 +233,7 @@ pub(crate) fn custom_subclass() -> &'static Class { builder.register(); }); - class!(CustomSubclassObject) + Class::get("CustomSubclassObject").unwrap() } pub(crate) fn custom_subclass_object() -> CustomObject { diff --git a/objc2/tests/id_retain_autoreleased.rs b/objc2/tests/id_retain_autoreleased.rs index 2640a4a73..325614540 100644 --- a/objc2/tests/id_retain_autoreleased.rs +++ b/objc2/tests/id_retain_autoreleased.rs @@ -4,6 +4,16 @@ use objc2::rc::{autoreleasepool, Id, Shared}; use objc2::runtime::Object; use objc2::{class, msg_send}; +#[cfg(feature = "gnustep-1-7")] +#[test] +fn ensure_linkage() { + unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; +} + +#[cfg(feature = "apple")] +#[link(name = "Foundation", kind = "framework")] +extern "C" {} + fn retain_count(obj: &Object) -> usize { unsafe { msg_send![obj, retainCount] } } @@ -37,15 +47,6 @@ fn create_data(bytes: &[u8]) -> Id { #[test] fn test_retain_autoreleased() { - #[cfg(feature = "gnustep-1-7")] - unsafe { - objc2::__gnustep_hack::get_class_to_force_linkage() - }; - - #[cfg(feature = "apple")] - #[link(name = "Foundation", kind = "framework")] - extern "C" {} - autoreleasepool(|_| { // Run once to allow DYLD to resolve the symbol stubs. // Required for making `retain_autoreleased` work on x86_64. diff --git a/objc2/tests/no_prelude.rs b/objc2/tests/no_prelude.rs index 995cb7b4b..de3c7236e 100644 --- a/objc2/tests/no_prelude.rs +++ b/objc2/tests/no_prelude.rs @@ -9,6 +9,16 @@ extern crate objc2 as new_objc2; +#[cfg(feature = "gnustep-1-7")] +#[test] +fn ensure_linkage() { + unsafe { new_objc2::__gnustep_hack::get_class_to_force_linkage() }; +} + +#[cfg(feature = "apple")] +#[link(name = "Foundation", kind = "framework")] +extern "C" {} + mod core {} mod std {} mod libc {} diff --git a/objc2/tests/use_macros.rs b/objc2/tests/use_macros.rs index b58ebe190..eeb7613cf 100644 --- a/objc2/tests/use_macros.rs +++ b/objc2/tests/use_macros.rs @@ -7,6 +7,10 @@ fn ensure_linkage() { unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; } +#[cfg(feature = "apple")] +#[link(name = "Foundation", kind = "framework")] +extern "C" {} + #[test] fn use_class_and_msg_send() { unsafe { diff --git a/test-assembly/crates/test_msg_send_static_sel/expected/apple-aarch64.s b/test-assembly/crates/test_msg_send_static_sel/expected/apple-aarch64.s index 80acc2314..d517a3fe5 100644 --- a/test-assembly/crates/test_msg_send_static_sel/expected/apple-aarch64.s +++ b/test-assembly/crates/test_msg_send_static_sel/expected/apple-aarch64.s @@ -16,15 +16,15 @@ _handle_alloc_init: stp x29, x30, [sp, #16] add x29, sp, #16 Lloh2: - adrp x8, L_OBJC_SELECTOR_REFERENCES_0ea0a15a3d108c32@GOTPAGE + adrp x8, L_OBJC_SELECTOR_REFERENCES_a4d24db6a5648d44@GOTPAGE Lloh3: - ldr x8, [x8, L_OBJC_SELECTOR_REFERENCES_0ea0a15a3d108c32@GOTPAGEOFF] + ldr x8, [x8, L_OBJC_SELECTOR_REFERENCES_a4d24db6a5648d44@GOTPAGEOFF] Lloh4: ldr x19, [x8] Lloh5: - adrp x8, L_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2@GOTPAGE + adrp x8, L_OBJC_SELECTOR_REFERENCES_234aca269670483c@GOTPAGE Lloh6: - ldr x8, [x8, L_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2@GOTPAGEOFF] + ldr x8, [x8, L_OBJC_SELECTOR_REFERENCES_234aca269670483c@GOTPAGEOFF] Lloh7: ldr x1, [x8] bl _objc_msgSend diff --git a/test-assembly/crates/test_msg_send_static_sel/expected/apple-armv7.s b/test-assembly/crates/test_msg_send_static_sel/expected/apple-armv7.s index 62e173024..00697e63d 100644 --- a/test-assembly/crates/test_msg_send_static_sel/expected/apple-armv7.s +++ b/test-assembly/crates/test_msg_send_static_sel/expected/apple-armv7.s @@ -16,10 +16,10 @@ LPC0_0: _handle_alloc_init: push {r4, r7, lr} add r7, sp, #4 - movw r1, :lower16:(LL_OBJC_SELECTOR_REFERENCES_0ea0a15a3d108c32$non_lazy_ptr-(LPC1_0+8)) - movt r1, :upper16:(LL_OBJC_SELECTOR_REFERENCES_0ea0a15a3d108c32$non_lazy_ptr-(LPC1_0+8)) - movw r2, :lower16:(LL_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2$non_lazy_ptr-(LPC1_1+8)) - movt r2, :upper16:(LL_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2$non_lazy_ptr-(LPC1_1+8)) + movw r1, :lower16:(LL_OBJC_SELECTOR_REFERENCES_a4d24db6a5648d44$non_lazy_ptr-(LPC1_0+8)) + movt r1, :upper16:(LL_OBJC_SELECTOR_REFERENCES_a4d24db6a5648d44$non_lazy_ptr-(LPC1_0+8)) + movw r2, :lower16:(LL_OBJC_SELECTOR_REFERENCES_234aca269670483c$non_lazy_ptr-(LPC1_1+8)) + movt r2, :upper16:(LL_OBJC_SELECTOR_REFERENCES_234aca269670483c$non_lazy_ptr-(LPC1_1+8)) LPC1_0: ldr r1, [pc, r1] LPC1_1: @@ -156,11 +156,11 @@ L_OBJC_SELECTOR_REFERENCES_e76e01e8b2327e5d: .section __DATA,__nl_symbol_ptr,non_lazy_symbol_pointers .p2align 2 -LL_OBJC_SELECTOR_REFERENCES_0ea0a15a3d108c32$non_lazy_ptr: - .indirect_symbol L_OBJC_SELECTOR_REFERENCES_0ea0a15a3d108c32 +LL_OBJC_SELECTOR_REFERENCES_234aca269670483c$non_lazy_ptr: + .indirect_symbol L_OBJC_SELECTOR_REFERENCES_234aca269670483c .long 0 -LL_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2$non_lazy_ptr: - .indirect_symbol L_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2 +LL_OBJC_SELECTOR_REFERENCES_a4d24db6a5648d44$non_lazy_ptr: + .indirect_symbol L_OBJC_SELECTOR_REFERENCES_a4d24db6a5648d44 .long 0 .subsections_via_symbols diff --git a/test-assembly/crates/test_msg_send_static_sel/expected/apple-armv7s.s b/test-assembly/crates/test_msg_send_static_sel/expected/apple-armv7s.s index 7dda911a9..d7d9e83e2 100644 --- a/test-assembly/crates/test_msg_send_static_sel/expected/apple-armv7s.s +++ b/test-assembly/crates/test_msg_send_static_sel/expected/apple-armv7s.s @@ -19,10 +19,10 @@ LPC0_0: _handle_alloc_init: push {r4, r7, lr} add r7, sp, #4 - movw r1, :lower16:(LL_OBJC_SELECTOR_REFERENCES_0ea0a15a3d108c32$non_lazy_ptr-(LPC1_0+8)) - movt r1, :upper16:(LL_OBJC_SELECTOR_REFERENCES_0ea0a15a3d108c32$non_lazy_ptr-(LPC1_0+8)) - movw r2, :lower16:(LL_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2$non_lazy_ptr-(LPC1_1+8)) - movt r2, :upper16:(LL_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2$non_lazy_ptr-(LPC1_1+8)) + movw r1, :lower16:(LL_OBJC_SELECTOR_REFERENCES_a4d24db6a5648d44$non_lazy_ptr-(LPC1_0+8)) + movt r1, :upper16:(LL_OBJC_SELECTOR_REFERENCES_a4d24db6a5648d44$non_lazy_ptr-(LPC1_0+8)) + movw r2, :lower16:(LL_OBJC_SELECTOR_REFERENCES_234aca269670483c$non_lazy_ptr-(LPC1_1+8)) + movt r2, :upper16:(LL_OBJC_SELECTOR_REFERENCES_234aca269670483c$non_lazy_ptr-(LPC1_1+8)) LPC1_0: ldr r1, [pc, r1] LPC1_1: @@ -159,11 +159,11 @@ L_OBJC_SELECTOR_REFERENCES_e76e01e8b2327e5d: .section __DATA,__nl_symbol_ptr,non_lazy_symbol_pointers .p2align 2 -LL_OBJC_SELECTOR_REFERENCES_0ea0a15a3d108c32$non_lazy_ptr: - .indirect_symbol L_OBJC_SELECTOR_REFERENCES_0ea0a15a3d108c32 +LL_OBJC_SELECTOR_REFERENCES_234aca269670483c$non_lazy_ptr: + .indirect_symbol L_OBJC_SELECTOR_REFERENCES_234aca269670483c .long 0 -LL_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2$non_lazy_ptr: - .indirect_symbol L_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2 +LL_OBJC_SELECTOR_REFERENCES_a4d24db6a5648d44$non_lazy_ptr: + .indirect_symbol L_OBJC_SELECTOR_REFERENCES_a4d24db6a5648d44 .long 0 .subsections_via_symbols diff --git a/test-assembly/crates/test_msg_send_static_sel/expected/apple-old-x86.s b/test-assembly/crates/test_msg_send_static_sel/expected/apple-old-x86.s index 3a8e44cfe..e8385e2f1 100644 --- a/test-assembly/crates/test_msg_send_static_sel/expected/apple-old-x86.s +++ b/test-assembly/crates/test_msg_send_static_sel/expected/apple-old-x86.s @@ -27,9 +27,9 @@ _handle_alloc_init: call L1$pb L1$pb: pop eax - mov ecx, dword ptr [eax + LL_OBJC_SELECTOR_REFERENCES_0ea0a15a3d108c32$non_lazy_ptr-L1$pb] + mov ecx, dword ptr [eax + LL_OBJC_SELECTOR_REFERENCES_a4d24db6a5648d44$non_lazy_ptr-L1$pb] mov esi, dword ptr [ecx] - mov eax, dword ptr [eax + LL_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2$non_lazy_ptr-L1$pb] + mov eax, dword ptr [eax + LL_OBJC_SELECTOR_REFERENCES_234aca269670483c$non_lazy_ptr-L1$pb] sub esp, 8 push dword ptr [eax] push dword ptr [ebp + 8] @@ -161,11 +161,11 @@ L_OBJC_SELECTOR_REFERENCES_e76e01e8b2327e5d: .long L_OBJC_METH_VAR_NAME_e76e01e8b2327e5d .section __IMPORT,__pointers,non_lazy_symbol_pointers -LL_OBJC_SELECTOR_REFERENCES_0ea0a15a3d108c32$non_lazy_ptr: - .indirect_symbol L_OBJC_SELECTOR_REFERENCES_0ea0a15a3d108c32 +LL_OBJC_SELECTOR_REFERENCES_234aca269670483c$non_lazy_ptr: + .indirect_symbol L_OBJC_SELECTOR_REFERENCES_234aca269670483c .long 0 -LL_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2$non_lazy_ptr: - .indirect_symbol L_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2 +LL_OBJC_SELECTOR_REFERENCES_a4d24db6a5648d44$non_lazy_ptr: + .indirect_symbol L_OBJC_SELECTOR_REFERENCES_a4d24db6a5648d44 .long 0 .subsections_via_symbols diff --git a/test-assembly/crates/test_msg_send_static_sel/expected/apple-x86.s b/test-assembly/crates/test_msg_send_static_sel/expected/apple-x86.s index 8cd4a853d..3e181b54b 100644 --- a/test-assembly/crates/test_msg_send_static_sel/expected/apple-x86.s +++ b/test-assembly/crates/test_msg_send_static_sel/expected/apple-x86.s @@ -27,9 +27,9 @@ _handle_alloc_init: call L1$pb L1$pb: pop eax - mov ecx, dword ptr [eax + LL_OBJC_SELECTOR_REFERENCES_0ea0a15a3d108c32$non_lazy_ptr-L1$pb] + mov ecx, dword ptr [eax + LL_OBJC_SELECTOR_REFERENCES_a4d24db6a5648d44$non_lazy_ptr-L1$pb] mov esi, dword ptr [ecx] - mov eax, dword ptr [eax + LL_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2$non_lazy_ptr-L1$pb] + mov eax, dword ptr [eax + LL_OBJC_SELECTOR_REFERENCES_234aca269670483c$non_lazy_ptr-L1$pb] sub esp, 8 push dword ptr [eax] push dword ptr [ebp + 8] @@ -161,11 +161,11 @@ L_OBJC_SELECTOR_REFERENCES_e76e01e8b2327e5d: .long L_OBJC_METH_VAR_NAME_e76e01e8b2327e5d .section __IMPORT,__pointers,non_lazy_symbol_pointers -LL_OBJC_SELECTOR_REFERENCES_0ea0a15a3d108c32$non_lazy_ptr: - .indirect_symbol L_OBJC_SELECTOR_REFERENCES_0ea0a15a3d108c32 +LL_OBJC_SELECTOR_REFERENCES_234aca269670483c$non_lazy_ptr: + .indirect_symbol L_OBJC_SELECTOR_REFERENCES_234aca269670483c .long 0 -LL_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2$non_lazy_ptr: - .indirect_symbol L_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2 +LL_OBJC_SELECTOR_REFERENCES_a4d24db6a5648d44$non_lazy_ptr: + .indirect_symbol L_OBJC_SELECTOR_REFERENCES_a4d24db6a5648d44 .long 0 .subsections_via_symbols diff --git a/test-assembly/crates/test_msg_send_static_sel/expected/apple-x86_64.s b/test-assembly/crates/test_msg_send_static_sel/expected/apple-x86_64.s index d18af7e51..e1ff34379 100644 --- a/test-assembly/crates/test_msg_send_static_sel/expected/apple-x86_64.s +++ b/test-assembly/crates/test_msg_send_static_sel/expected/apple-x86_64.s @@ -16,9 +16,9 @@ _handle_alloc_init: mov rbp, rsp push rbx push rax - mov rax, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_0ea0a15a3d108c32@GOTPCREL] + mov rax, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_a4d24db6a5648d44@GOTPCREL] mov rbx, qword ptr [rax] - mov rax, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2@GOTPCREL] + mov rax, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_234aca269670483c@GOTPCREL] mov rsi, qword ptr [rax] call _objc_msgSend mov rdi, rax diff --git a/test-assembly/crates/test_static_class/Cargo.toml b/test-assembly/crates/test_static_class/Cargo.toml new file mode 100644 index 000000000..46b8a1047 --- /dev/null +++ b/test-assembly/crates/test_static_class/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "test_static_class" +version = "0.1.0" +edition = "2021" +publish = false + +[lib] +path = "lib.rs" + +[dependencies] +objc2 = { path = "../../../objc2", default-features = false } + +[features] +default = ["apple", "std"] +std = ["objc2/std"] +# Runtime +apple = ["objc2/apple"] +gnustep-1-7 = ["objc2/gnustep-1-7"] +gnustep-1-8 = ["gnustep-1-7", "objc2/gnustep-1-8"] +gnustep-1-9 = ["gnustep-1-8", "objc2/gnustep-1-9"] +gnustep-2-0 = ["gnustep-1-9", "objc2/gnustep-2-0"] +gnustep-2-1 = ["gnustep-2-0", "objc2/gnustep-2-1"] + +# Hack to prevent the feature flag from being enabled in the entire project +assembly-features = ["objc2/unstable-static-class-inlined"] diff --git a/test-assembly/crates/test_static_class/expected/apple-aarch64.s b/test-assembly/crates/test_static_class/expected/apple-aarch64.s new file mode 100644 index 000000000..0458a7a83 --- /dev/null +++ b/test-assembly/crates/test_static_class/expected/apple-aarch64.s @@ -0,0 +1,152 @@ + .section __TEXT,__text,regular,pure_instructions + .globl _get_class + .p2align 2 +_get_class: +Lloh0: + adrp x8, L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f@PAGE +Lloh1: + ldr x0, [x8, L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f@PAGEOFF] + ret + .loh AdrpLdr Lloh0, Lloh1 + + .globl _get_same_class + .p2align 2 +_get_same_class: +Lloh2: + adrp x8, L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79@PAGE +Lloh3: + ldr x0, [x8, L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79@PAGEOFF] + ret + .loh AdrpLdr Lloh2, Lloh3 + + .globl _get_different_class + .p2align 2 +_get_different_class: +Lloh4: + adrp x8, L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4@PAGE +Lloh5: + ldr x0, [x8, L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4@PAGEOFF] + ret + .loh AdrpLdr Lloh4, Lloh5 + + .globl _unused_sel + .p2align 2 +_unused_sel: + ret + + .globl _use_fns + .p2align 2 +_use_fns: +Lloh6: + adrp x9, L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f@PAGE +Lloh7: + ldr x9, [x9, L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f@PAGEOFF] +Lloh8: + adrp x10, L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79@PAGE +Lloh9: + ldr x10, [x10, L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79@PAGEOFF] +Lloh10: + adrp x11, L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4@PAGE +Lloh11: + ldr x11, [x11, L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4@PAGEOFF] +Lloh12: + adrp x12, L_OBJC_CLASSLIST_REFERENCES_$_2f45d8445f72bd9b@PAGE +Lloh13: + ldr x12, [x12, L_OBJC_CLASSLIST_REFERENCES_$_2f45d8445f72bd9b@PAGEOFF] + stp x9, x10, [x8] + stp x11, x12, [x8, #16] + ret + .loh AdrpLdr Lloh12, Lloh13 + .loh AdrpLdr Lloh10, Lloh11 + .loh AdrpLdr Lloh8, Lloh9 + .loh AdrpLdr Lloh6, Lloh7 + + .globl _use_same_twice + .p2align 2 +_use_same_twice: +Lloh14: + adrp x9, L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f@PAGE +Lloh15: + ldr x9, [x9, L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f@PAGEOFF] + stp x9, x9, [x8] + ret + .loh AdrpLdr Lloh14, Lloh15 + + .globl _use_in_loop + .p2align 2 +_use_in_loop: + ret + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_9657804a2a54ab6f + .p2align 2 +L_OBJC_IMAGE_INFO_9657804a2a54ab6f: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f + .p2align 3 +L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f: + .quad _OBJC_CLASS_$_NSObject + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_e897a41b218dcf79 + .p2align 2 +L_OBJC_IMAGE_INFO_e897a41b218dcf79: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79 + .p2align 3 +L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79: + .quad _OBJC_CLASS_$_NSObject + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_3b7780b4dcfcb9d4 + .p2align 2 +L_OBJC_IMAGE_INFO_3b7780b4dcfcb9d4: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4 + .p2align 3 +L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4: + .quad _OBJC_CLASS_$_NSString + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_f2fb7c579d3c0a74 + .p2align 2 +L_OBJC_IMAGE_INFO_f2fb7c579d3c0a74: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_f2fb7c579d3c0a74 + .p2align 3 +L_OBJC_CLASSLIST_REFERENCES_$_f2fb7c579d3c0a74: + .quad _OBJC_CLASS_$_NSData + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_2f45d8445f72bd9b + .p2align 2 +L_OBJC_IMAGE_INFO_2f45d8445f72bd9b: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_2f45d8445f72bd9b + .p2align 3 +L_OBJC_CLASSLIST_REFERENCES_$_2f45d8445f72bd9b: + .quad _OBJC_CLASS_$_NSException + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_3bf610c78df2b6bb + .p2align 2 +L_OBJC_IMAGE_INFO_3bf610c78df2b6bb: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_3bf610c78df2b6bb + .p2align 3 +L_OBJC_CLASSLIST_REFERENCES_$_3bf610c78df2b6bb: + .quad _OBJC_CLASS_$_NSLock + +.subsections_via_symbols diff --git a/test-assembly/crates/test_static_class/expected/apple-armv7.s b/test-assembly/crates/test_static_class/expected/apple-armv7.s new file mode 100644 index 000000000..f1af0a3ee --- /dev/null +++ b/test-assembly/crates/test_static_class/expected/apple-armv7.s @@ -0,0 +1,154 @@ + .section __TEXT,__text,regular,pure_instructions + .syntax unified + .globl _get_class + .p2align 2 + .code 32 +_get_class: + movw r0, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f-(LPC0_0+8)) + movt r0, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f-(LPC0_0+8)) +LPC0_0: + ldr r0, [pc, r0] + bx lr + + .globl _get_same_class + .p2align 2 + .code 32 +_get_same_class: + movw r0, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79-(LPC1_0+8)) + movt r0, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79-(LPC1_0+8)) +LPC1_0: + ldr r0, [pc, r0] + bx lr + + .globl _get_different_class + .p2align 2 + .code 32 +_get_different_class: + movw r0, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4-(LPC2_0+8)) + movt r0, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4-(LPC2_0+8)) +LPC2_0: + ldr r0, [pc, r0] + bx lr + + .globl _unused_sel + .p2align 2 + .code 32 +_unused_sel: + bx lr + + .globl _use_fns + .p2align 2 + .code 32 +_use_fns: + movw r9, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_2f45d8445f72bd9b-(LPC4_0+8)) + movt r9, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_2f45d8445f72bd9b-(LPC4_0+8)) +LPC4_0: + ldr r9, [pc, r9] + movw r2, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4-(LPC4_1+8)) + movt r2, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4-(LPC4_1+8)) +LPC4_1: + ldr r2, [pc, r2] + movw r3, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79-(LPC4_2+8)) + movt r3, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79-(LPC4_2+8)) +LPC4_2: + ldr r3, [pc, r3] + movw r1, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f-(LPC4_3+8)) + movt r1, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f-(LPC4_3+8)) + str r2, [r0, #8] +LPC4_3: + ldr r1, [pc, r1] + str r9, [r0, #12] + stm r0, {r1, r3} + bx lr + + .globl _use_same_twice + .p2align 2 + .code 32 +_use_same_twice: + movw r1, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f-(LPC5_0+8)) + movt r1, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f-(LPC5_0+8)) +LPC5_0: + ldr r1, [pc, r1] + str r1, [r0] + str r1, [r0, #4] + bx lr + + .globl _use_in_loop + .p2align 2 + .code 32 +_use_in_loop: + bx lr + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_9657804a2a54ab6f + .p2align 2 +L_OBJC_IMAGE_INFO_9657804a2a54ab6f: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f + .p2align 2 +L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f: + .long _OBJC_CLASS_$_NSObject + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_e897a41b218dcf79 + .p2align 2 +L_OBJC_IMAGE_INFO_e897a41b218dcf79: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79 + .p2align 2 +L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79: + .long _OBJC_CLASS_$_NSObject + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_3b7780b4dcfcb9d4 + .p2align 2 +L_OBJC_IMAGE_INFO_3b7780b4dcfcb9d4: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4 + .p2align 2 +L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4: + .long _OBJC_CLASS_$_NSString + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_f2fb7c579d3c0a74 + .p2align 2 +L_OBJC_IMAGE_INFO_f2fb7c579d3c0a74: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_f2fb7c579d3c0a74 + .p2align 2 +L_OBJC_CLASSLIST_REFERENCES_$_f2fb7c579d3c0a74: + .long _OBJC_CLASS_$_NSData + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_2f45d8445f72bd9b + .p2align 2 +L_OBJC_IMAGE_INFO_2f45d8445f72bd9b: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_2f45d8445f72bd9b + .p2align 2 +L_OBJC_CLASSLIST_REFERENCES_$_2f45d8445f72bd9b: + .long _OBJC_CLASS_$_NSException + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_3bf610c78df2b6bb + .p2align 2 +L_OBJC_IMAGE_INFO_3bf610c78df2b6bb: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_3bf610c78df2b6bb + .p2align 2 +L_OBJC_CLASSLIST_REFERENCES_$_3bf610c78df2b6bb: + .long _OBJC_CLASS_$_NSLock + +.subsections_via_symbols diff --git a/test-assembly/crates/test_static_class/expected/apple-armv7s.s b/test-assembly/crates/test_static_class/expected/apple-armv7s.s new file mode 100644 index 000000000..f1af0a3ee --- /dev/null +++ b/test-assembly/crates/test_static_class/expected/apple-armv7s.s @@ -0,0 +1,154 @@ + .section __TEXT,__text,regular,pure_instructions + .syntax unified + .globl _get_class + .p2align 2 + .code 32 +_get_class: + movw r0, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f-(LPC0_0+8)) + movt r0, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f-(LPC0_0+8)) +LPC0_0: + ldr r0, [pc, r0] + bx lr + + .globl _get_same_class + .p2align 2 + .code 32 +_get_same_class: + movw r0, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79-(LPC1_0+8)) + movt r0, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79-(LPC1_0+8)) +LPC1_0: + ldr r0, [pc, r0] + bx lr + + .globl _get_different_class + .p2align 2 + .code 32 +_get_different_class: + movw r0, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4-(LPC2_0+8)) + movt r0, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4-(LPC2_0+8)) +LPC2_0: + ldr r0, [pc, r0] + bx lr + + .globl _unused_sel + .p2align 2 + .code 32 +_unused_sel: + bx lr + + .globl _use_fns + .p2align 2 + .code 32 +_use_fns: + movw r9, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_2f45d8445f72bd9b-(LPC4_0+8)) + movt r9, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_2f45d8445f72bd9b-(LPC4_0+8)) +LPC4_0: + ldr r9, [pc, r9] + movw r2, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4-(LPC4_1+8)) + movt r2, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4-(LPC4_1+8)) +LPC4_1: + ldr r2, [pc, r2] + movw r3, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79-(LPC4_2+8)) + movt r3, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79-(LPC4_2+8)) +LPC4_2: + ldr r3, [pc, r3] + movw r1, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f-(LPC4_3+8)) + movt r1, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f-(LPC4_3+8)) + str r2, [r0, #8] +LPC4_3: + ldr r1, [pc, r1] + str r9, [r0, #12] + stm r0, {r1, r3} + bx lr + + .globl _use_same_twice + .p2align 2 + .code 32 +_use_same_twice: + movw r1, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f-(LPC5_0+8)) + movt r1, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f-(LPC5_0+8)) +LPC5_0: + ldr r1, [pc, r1] + str r1, [r0] + str r1, [r0, #4] + bx lr + + .globl _use_in_loop + .p2align 2 + .code 32 +_use_in_loop: + bx lr + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_9657804a2a54ab6f + .p2align 2 +L_OBJC_IMAGE_INFO_9657804a2a54ab6f: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f + .p2align 2 +L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f: + .long _OBJC_CLASS_$_NSObject + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_e897a41b218dcf79 + .p2align 2 +L_OBJC_IMAGE_INFO_e897a41b218dcf79: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79 + .p2align 2 +L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79: + .long _OBJC_CLASS_$_NSObject + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_3b7780b4dcfcb9d4 + .p2align 2 +L_OBJC_IMAGE_INFO_3b7780b4dcfcb9d4: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4 + .p2align 2 +L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4: + .long _OBJC_CLASS_$_NSString + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_f2fb7c579d3c0a74 + .p2align 2 +L_OBJC_IMAGE_INFO_f2fb7c579d3c0a74: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_f2fb7c579d3c0a74 + .p2align 2 +L_OBJC_CLASSLIST_REFERENCES_$_f2fb7c579d3c0a74: + .long _OBJC_CLASS_$_NSData + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_2f45d8445f72bd9b + .p2align 2 +L_OBJC_IMAGE_INFO_2f45d8445f72bd9b: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_2f45d8445f72bd9b + .p2align 2 +L_OBJC_CLASSLIST_REFERENCES_$_2f45d8445f72bd9b: + .long _OBJC_CLASS_$_NSException + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_3bf610c78df2b6bb + .p2align 2 +L_OBJC_IMAGE_INFO_3bf610c78df2b6bb: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_3bf610c78df2b6bb + .p2align 2 +L_OBJC_CLASSLIST_REFERENCES_$_3bf610c78df2b6bb: + .long _OBJC_CLASS_$_NSLock + +.subsections_via_symbols diff --git a/test-assembly/crates/test_static_class/expected/apple-old-x86.s b/test-assembly/crates/test_static_class/expected/apple-old-x86.s new file mode 100644 index 000000000..bb09643b2 --- /dev/null +++ b/test-assembly/crates/test_static_class/expected/apple-old-x86.s @@ -0,0 +1,274 @@ + .section __TEXT,__text,regular,pure_instructions + .intel_syntax noprefix + .globl _get_class + .p2align 4, 0x90 +_get_class: + push ebp + mov ebp, esp + call L0$pb +L0$pb: + pop eax + mov eax, dword ptr [eax + L_OBJC_CLASS_REFERENCES_9657804a2a54ab6f-L0$pb] + pop ebp + ret + + .globl _get_same_class + .p2align 4, 0x90 +_get_same_class: + push ebp + mov ebp, esp + call L1$pb +L1$pb: + pop eax + mov eax, dword ptr [eax + L_OBJC_CLASS_REFERENCES_e897a41b218dcf79-L1$pb] + pop ebp + ret + + .globl _get_different_class + .p2align 4, 0x90 +_get_different_class: + push ebp + mov ebp, esp + call L2$pb +L2$pb: + pop eax + mov eax, dword ptr [eax + L_OBJC_CLASS_REFERENCES_3b7780b4dcfcb9d4-L2$pb] + pop ebp + ret + + .globl _unused_sel + .p2align 4, 0x90 +_unused_sel: + push ebp + mov ebp, esp + pop ebp + ret + + .globl _use_fns + .p2align 4, 0x90 +_use_fns: + push ebp + mov ebp, esp + push edi + push esi + call L4$pb +L4$pb: + pop ecx + mov eax, dword ptr [ebp + 8] + mov edx, dword ptr [ecx + L_OBJC_CLASS_REFERENCES_9657804a2a54ab6f-L4$pb] + mov esi, dword ptr [ecx + L_OBJC_CLASS_REFERENCES_e897a41b218dcf79-L4$pb] + mov edi, dword ptr [ecx + L_OBJC_CLASS_REFERENCES_3b7780b4dcfcb9d4-L4$pb] + mov ecx, dword ptr [ecx + L_OBJC_CLASS_REFERENCES_2f45d8445f72bd9b-L4$pb] + mov dword ptr [eax], edx + mov dword ptr [eax + 4], esi + mov dword ptr [eax + 8], edi + mov dword ptr [eax + 12], ecx + pop esi + pop edi + pop ebp + ret 4 + + .globl _use_same_twice + .p2align 4, 0x90 +_use_same_twice: + push ebp + mov ebp, esp + call L5$pb +L5$pb: + pop ecx + mov eax, dword ptr [ebp + 8] + mov ecx, dword ptr [ecx + L_OBJC_CLASS_REFERENCES_9657804a2a54ab6f-L5$pb] + mov dword ptr [eax], ecx + mov dword ptr [eax + 4], ecx + pop ebp + ret 4 + + .globl _use_in_loop + .p2align 4, 0x90 +_use_in_loop: + push ebp + mov ebp, esp + pop ebp + ret + + .section __OBJC,__image_info + .globl L_OBJC_IMAGE_INFO_9657804a2a54ab6f + .p2align 2 +L_OBJC_IMAGE_INFO_9657804a2a54ab6f: + .asciz "\000\000\000\000@\000\000" + + .section __TEXT,__cstring,cstring_literals + .globl L_OBJC_CLASS_NAME_9657804a2a54ab6f +L_OBJC_CLASS_NAME_9657804a2a54ab6f: + .ascii "NSObject" + + .section __OBJC,__cls_refs,literal_pointers,no_dead_strip + .globl L_OBJC_CLASS_REFERENCES_9657804a2a54ab6f + .p2align 2 +L_OBJC_CLASS_REFERENCES_9657804a2a54ab6f: + .long L_OBJC_CLASS_NAME_9657804a2a54ab6f + + .section __TEXT,__cstring,cstring_literals + .globl L_OBJC_CLASS_NAME_9657804a2a54ab6f_MODULE_INFO +L_OBJC_CLASS_NAME_9657804a2a54ab6f_MODULE_INFO: + .space 1 + + .section __OBJC,__module_info,regular,no_dead_strip + .globl L_OBJC_MODULES_9657804a2a54ab6f + .p2align 2 +L_OBJC_MODULES_9657804a2a54ab6f: + .asciz "\007\000\000\000\020\000\000" + .long L_OBJC_CLASS_NAME_9657804a2a54ab6f_MODULE_INFO + .space 4 + + .section __OBJC,__image_info + .globl L_OBJC_IMAGE_INFO_e897a41b218dcf79 + .p2align 2 +L_OBJC_IMAGE_INFO_e897a41b218dcf79: + .asciz "\000\000\000\000@\000\000" + + .section __TEXT,__cstring,cstring_literals + .globl L_OBJC_CLASS_NAME_e897a41b218dcf79 +L_OBJC_CLASS_NAME_e897a41b218dcf79: + .ascii "NSObject" + + .section __OBJC,__cls_refs,literal_pointers,no_dead_strip + .globl L_OBJC_CLASS_REFERENCES_e897a41b218dcf79 + .p2align 2 +L_OBJC_CLASS_REFERENCES_e897a41b218dcf79: + .long L_OBJC_CLASS_NAME_e897a41b218dcf79 + + .section __TEXT,__cstring,cstring_literals + .globl L_OBJC_CLASS_NAME_e897a41b218dcf79_MODULE_INFO +L_OBJC_CLASS_NAME_e897a41b218dcf79_MODULE_INFO: + .space 1 + + .section __OBJC,__module_info,regular,no_dead_strip + .globl L_OBJC_MODULES_e897a41b218dcf79 + .p2align 2 +L_OBJC_MODULES_e897a41b218dcf79: + .asciz "\007\000\000\000\020\000\000" + .long L_OBJC_CLASS_NAME_e897a41b218dcf79_MODULE_INFO + .space 4 + + .section __OBJC,__image_info + .globl L_OBJC_IMAGE_INFO_3b7780b4dcfcb9d4 + .p2align 2 +L_OBJC_IMAGE_INFO_3b7780b4dcfcb9d4: + .asciz "\000\000\000\000@\000\000" + + .section __TEXT,__cstring,cstring_literals + .globl L_OBJC_CLASS_NAME_3b7780b4dcfcb9d4 +L_OBJC_CLASS_NAME_3b7780b4dcfcb9d4: + .ascii "NSString" + + .section __OBJC,__cls_refs,literal_pointers,no_dead_strip + .globl L_OBJC_CLASS_REFERENCES_3b7780b4dcfcb9d4 + .p2align 2 +L_OBJC_CLASS_REFERENCES_3b7780b4dcfcb9d4: + .long L_OBJC_CLASS_NAME_3b7780b4dcfcb9d4 + + .section __TEXT,__cstring,cstring_literals + .globl L_OBJC_CLASS_NAME_3b7780b4dcfcb9d4_MODULE_INFO +L_OBJC_CLASS_NAME_3b7780b4dcfcb9d4_MODULE_INFO: + .space 1 + + .section __OBJC,__module_info,regular,no_dead_strip + .globl L_OBJC_MODULES_3b7780b4dcfcb9d4 + .p2align 2 +L_OBJC_MODULES_3b7780b4dcfcb9d4: + .asciz "\007\000\000\000\020\000\000" + .long L_OBJC_CLASS_NAME_3b7780b4dcfcb9d4_MODULE_INFO + .space 4 + + .section __OBJC,__image_info + .globl L_OBJC_IMAGE_INFO_f2fb7c579d3c0a74 + .p2align 2 +L_OBJC_IMAGE_INFO_f2fb7c579d3c0a74: + .asciz "\000\000\000\000@\000\000" + + .section __TEXT,__cstring,cstring_literals + .globl L_OBJC_CLASS_NAME_f2fb7c579d3c0a74 +L_OBJC_CLASS_NAME_f2fb7c579d3c0a74: + .ascii "NSData" + + .section __OBJC,__cls_refs,literal_pointers,no_dead_strip + .globl L_OBJC_CLASS_REFERENCES_f2fb7c579d3c0a74 + .p2align 2 +L_OBJC_CLASS_REFERENCES_f2fb7c579d3c0a74: + .long L_OBJC_CLASS_NAME_f2fb7c579d3c0a74 + + .section __TEXT,__cstring,cstring_literals + .globl L_OBJC_CLASS_NAME_f2fb7c579d3c0a74_MODULE_INFO +L_OBJC_CLASS_NAME_f2fb7c579d3c0a74_MODULE_INFO: + .space 1 + + .section __OBJC,__module_info,regular,no_dead_strip + .globl L_OBJC_MODULES_f2fb7c579d3c0a74 + .p2align 2 +L_OBJC_MODULES_f2fb7c579d3c0a74: + .asciz "\007\000\000\000\020\000\000" + .long L_OBJC_CLASS_NAME_f2fb7c579d3c0a74_MODULE_INFO + .space 4 + + .section __OBJC,__image_info + .globl L_OBJC_IMAGE_INFO_2f45d8445f72bd9b + .p2align 2 +L_OBJC_IMAGE_INFO_2f45d8445f72bd9b: + .asciz "\000\000\000\000@\000\000" + + .section __TEXT,__cstring,cstring_literals + .globl L_OBJC_CLASS_NAME_2f45d8445f72bd9b +L_OBJC_CLASS_NAME_2f45d8445f72bd9b: + .ascii "NSException" + + .section __OBJC,__cls_refs,literal_pointers,no_dead_strip + .globl L_OBJC_CLASS_REFERENCES_2f45d8445f72bd9b + .p2align 2 +L_OBJC_CLASS_REFERENCES_2f45d8445f72bd9b: + .long L_OBJC_CLASS_NAME_2f45d8445f72bd9b + + .section __TEXT,__cstring,cstring_literals + .globl L_OBJC_CLASS_NAME_2f45d8445f72bd9b_MODULE_INFO +L_OBJC_CLASS_NAME_2f45d8445f72bd9b_MODULE_INFO: + .space 1 + + .section __OBJC,__module_info,regular,no_dead_strip + .globl L_OBJC_MODULES_2f45d8445f72bd9b + .p2align 2 +L_OBJC_MODULES_2f45d8445f72bd9b: + .asciz "\007\000\000\000\020\000\000" + .long L_OBJC_CLASS_NAME_2f45d8445f72bd9b_MODULE_INFO + .space 4 + + .section __OBJC,__image_info + .globl L_OBJC_IMAGE_INFO_3bf610c78df2b6bb + .p2align 2 +L_OBJC_IMAGE_INFO_3bf610c78df2b6bb: + .asciz "\000\000\000\000@\000\000" + + .section __TEXT,__cstring,cstring_literals + .globl L_OBJC_CLASS_NAME_3bf610c78df2b6bb +L_OBJC_CLASS_NAME_3bf610c78df2b6bb: + .ascii "NSLock" + + .section __OBJC,__cls_refs,literal_pointers,no_dead_strip + .globl L_OBJC_CLASS_REFERENCES_3bf610c78df2b6bb + .p2align 2 +L_OBJC_CLASS_REFERENCES_3bf610c78df2b6bb: + .long L_OBJC_CLASS_NAME_3bf610c78df2b6bb + + .section __TEXT,__cstring,cstring_literals + .globl L_OBJC_CLASS_NAME_3bf610c78df2b6bb_MODULE_INFO +L_OBJC_CLASS_NAME_3bf610c78df2b6bb_MODULE_INFO: + .space 1 + + .section __OBJC,__module_info,regular,no_dead_strip + .globl L_OBJC_MODULES_3bf610c78df2b6bb + .p2align 2 +L_OBJC_MODULES_3bf610c78df2b6bb: + .asciz "\007\000\000\000\020\000\000" + .long L_OBJC_CLASS_NAME_3bf610c78df2b6bb_MODULE_INFO + .space 4 + +.subsections_via_symbols diff --git a/test-assembly/crates/test_static_class/expected/apple-x86.s b/test-assembly/crates/test_static_class/expected/apple-x86.s new file mode 100644 index 000000000..f725ca330 --- /dev/null +++ b/test-assembly/crates/test_static_class/expected/apple-x86.s @@ -0,0 +1,166 @@ + .section __TEXT,__text,regular,pure_instructions + .intel_syntax noprefix + .globl _get_class + .p2align 4, 0x90 +_get_class: + push ebp + mov ebp, esp + call L0$pb +L0$pb: + pop eax + mov eax, dword ptr [eax + L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f-L0$pb] + pop ebp + ret + + .globl _get_same_class + .p2align 4, 0x90 +_get_same_class: + push ebp + mov ebp, esp + call L1$pb +L1$pb: + pop eax + mov eax, dword ptr [eax + L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79-L1$pb] + pop ebp + ret + + .globl _get_different_class + .p2align 4, 0x90 +_get_different_class: + push ebp + mov ebp, esp + call L2$pb +L2$pb: + pop eax + mov eax, dword ptr [eax + L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4-L2$pb] + pop ebp + ret + + .globl _unused_sel + .p2align 4, 0x90 +_unused_sel: + push ebp + mov ebp, esp + pop ebp + ret + + .globl _use_fns + .p2align 4, 0x90 +_use_fns: + push ebp + mov ebp, esp + push edi + push esi + call L4$pb +L4$pb: + pop ecx + mov eax, dword ptr [ebp + 8] + mov edx, dword ptr [ecx + L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f-L4$pb] + mov esi, dword ptr [ecx + L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79-L4$pb] + mov edi, dword ptr [ecx + L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4-L4$pb] + mov ecx, dword ptr [ecx + L_OBJC_CLASSLIST_REFERENCES_$_2f45d8445f72bd9b-L4$pb] + mov dword ptr [eax], edx + mov dword ptr [eax + 4], esi + mov dword ptr [eax + 8], edi + mov dword ptr [eax + 12], ecx + pop esi + pop edi + pop ebp + ret 4 + + .globl _use_same_twice + .p2align 4, 0x90 +_use_same_twice: + push ebp + mov ebp, esp + call L5$pb +L5$pb: + pop ecx + mov eax, dword ptr [ebp + 8] + mov ecx, dword ptr [ecx + L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f-L5$pb] + mov dword ptr [eax], ecx + mov dword ptr [eax + 4], ecx + pop ebp + ret 4 + + .globl _use_in_loop + .p2align 4, 0x90 +_use_in_loop: + push ebp + mov ebp, esp + pop ebp + ret + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_9657804a2a54ab6f + .p2align 2 +L_OBJC_IMAGE_INFO_9657804a2a54ab6f: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f + .p2align 2 +L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f: + .long _OBJC_CLASS_$_NSObject + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_e897a41b218dcf79 + .p2align 2 +L_OBJC_IMAGE_INFO_e897a41b218dcf79: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79 + .p2align 2 +L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79: + .long _OBJC_CLASS_$_NSObject + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_3b7780b4dcfcb9d4 + .p2align 2 +L_OBJC_IMAGE_INFO_3b7780b4dcfcb9d4: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4 + .p2align 2 +L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4: + .long _OBJC_CLASS_$_NSString + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_f2fb7c579d3c0a74 + .p2align 2 +L_OBJC_IMAGE_INFO_f2fb7c579d3c0a74: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_f2fb7c579d3c0a74 + .p2align 2 +L_OBJC_CLASSLIST_REFERENCES_$_f2fb7c579d3c0a74: + .long _OBJC_CLASS_$_NSData + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_2f45d8445f72bd9b + .p2align 2 +L_OBJC_IMAGE_INFO_2f45d8445f72bd9b: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_2f45d8445f72bd9b + .p2align 2 +L_OBJC_CLASSLIST_REFERENCES_$_2f45d8445f72bd9b: + .long _OBJC_CLASS_$_NSException + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_3bf610c78df2b6bb + .p2align 2 +L_OBJC_IMAGE_INFO_3bf610c78df2b6bb: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_3bf610c78df2b6bb + .p2align 2 +L_OBJC_CLASSLIST_REFERENCES_$_3bf610c78df2b6bb: + .long _OBJC_CLASS_$_NSLock + +.subsections_via_symbols diff --git a/test-assembly/crates/test_static_class/expected/apple-x86_64.s b/test-assembly/crates/test_static_class/expected/apple-x86_64.s new file mode 100644 index 000000000..420b51641 --- /dev/null +++ b/test-assembly/crates/test_static_class/expected/apple-x86_64.s @@ -0,0 +1,147 @@ + .section __TEXT,__text,regular,pure_instructions + .intel_syntax noprefix + .globl _get_class + .p2align 4, 0x90 +_get_class: + push rbp + mov rbp, rsp + mov rax, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f] + pop rbp + ret + + .globl _get_same_class + .p2align 4, 0x90 +_get_same_class: + push rbp + mov rbp, rsp + mov rax, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79] + pop rbp + ret + + .globl _get_different_class + .p2align 4, 0x90 +_get_different_class: + push rbp + mov rbp, rsp + mov rax, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4] + pop rbp + ret + + .globl _unused_sel + .p2align 4, 0x90 +_unused_sel: + push rbp + mov rbp, rsp + pop rbp + ret + + .globl _use_fns + .p2align 4, 0x90 +_use_fns: + push rbp + mov rbp, rsp + mov rax, rdi + mov rcx, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f] + mov rdx, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79] + mov rsi, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4] + mov rdi, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_2f45d8445f72bd9b] + mov qword ptr [rax], rcx + mov qword ptr [rax + 8], rdx + mov qword ptr [rax + 16], rsi + mov qword ptr [rax + 24], rdi + pop rbp + ret + + .globl _use_same_twice + .p2align 4, 0x90 +_use_same_twice: + push rbp + mov rbp, rsp + mov rax, rdi + mov rcx, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f] + mov qword ptr [rdi], rcx + mov qword ptr [rdi + 8], rcx + pop rbp + ret + + .globl _use_in_loop + .p2align 4, 0x90 +_use_in_loop: + push rbp + mov rbp, rsp + pop rbp + ret + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_9657804a2a54ab6f + .p2align 2 +L_OBJC_IMAGE_INFO_9657804a2a54ab6f: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f + .p2align 3 +L_OBJC_CLASSLIST_REFERENCES_$_9657804a2a54ab6f: + .quad _OBJC_CLASS_$_NSObject + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_e897a41b218dcf79 + .p2align 2 +L_OBJC_IMAGE_INFO_e897a41b218dcf79: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79 + .p2align 3 +L_OBJC_CLASSLIST_REFERENCES_$_e897a41b218dcf79: + .quad _OBJC_CLASS_$_NSObject + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_3b7780b4dcfcb9d4 + .p2align 2 +L_OBJC_IMAGE_INFO_3b7780b4dcfcb9d4: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4 + .p2align 3 +L_OBJC_CLASSLIST_REFERENCES_$_3b7780b4dcfcb9d4: + .quad _OBJC_CLASS_$_NSString + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_f2fb7c579d3c0a74 + .p2align 2 +L_OBJC_IMAGE_INFO_f2fb7c579d3c0a74: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_f2fb7c579d3c0a74 + .p2align 3 +L_OBJC_CLASSLIST_REFERENCES_$_f2fb7c579d3c0a74: + .quad _OBJC_CLASS_$_NSData + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_2f45d8445f72bd9b + .p2align 2 +L_OBJC_IMAGE_INFO_2f45d8445f72bd9b: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_2f45d8445f72bd9b + .p2align 3 +L_OBJC_CLASSLIST_REFERENCES_$_2f45d8445f72bd9b: + .quad _OBJC_CLASS_$_NSException + + .section __DATA,__objc_imageinfo,regular,no_dead_strip + .globl L_OBJC_IMAGE_INFO_3bf610c78df2b6bb + .p2align 2 +L_OBJC_IMAGE_INFO_3bf610c78df2b6bb: + .asciz "\000\000\000\000@\000\000" + + .section __DATA,__objc_classrefs,regular,no_dead_strip + .globl L_OBJC_CLASSLIST_REFERENCES_$_3bf610c78df2b6bb + .p2align 3 +L_OBJC_CLASSLIST_REFERENCES_$_3bf610c78df2b6bb: + .quad _OBJC_CLASS_$_NSLock + +.subsections_via_symbols diff --git a/test-assembly/crates/test_static_class/expected/gnustep-x86.s b/test-assembly/crates/test_static_class/expected/gnustep-x86.s new file mode 100644 index 000000000..c690d3633 --- /dev/null +++ b/test-assembly/crates/test_static_class/expected/gnustep-x86.s @@ -0,0 +1,3 @@ + .text + .intel_syntax noprefix + .section ".note.GNU-stack","",@progbits diff --git a/test-assembly/crates/test_static_class/expected/gnustep-x86_64.s b/test-assembly/crates/test_static_class/expected/gnustep-x86_64.s new file mode 100644 index 000000000..c690d3633 --- /dev/null +++ b/test-assembly/crates/test_static_class/expected/gnustep-x86_64.s @@ -0,0 +1,3 @@ + .text + .intel_syntax noprefix + .section ".note.GNU-stack","",@progbits diff --git a/test-assembly/crates/test_static_class/lib.rs b/test-assembly/crates/test_static_class/lib.rs new file mode 100644 index 000000000..57e31d89b --- /dev/null +++ b/test-assembly/crates/test_static_class/lib.rs @@ -0,0 +1,51 @@ +//! Test the output of the `class!` macro. +#![cfg(feature = "apple")] +use objc2::class; +use objc2::runtime::Class; + +#[cfg(feature = "apple")] +#[link(name = "Foundation", kind = "framework")] +extern "C" {} + +#[no_mangle] +fn get_class() -> &'static Class { + class!(NSObject) +} + +#[no_mangle] +fn get_same_class() -> &'static Class { + class!(NSObject) +} + +#[no_mangle] +fn get_different_class() -> &'static Class { + class!(NSString) +} + +#[no_mangle] +fn unused_sel() { + let _ = class!(NSData); +} + +#[no_mangle] +fn use_fns() -> [&'static Class; 4] { + let s1 = get_class(); + let s2 = get_same_class(); + let s3 = get_different_class(); + let s4 = class!(NSException); + [s1, s2, s3, s4] +} + +#[no_mangle] +fn use_same_twice() -> [&'static Class; 2] { + // Should not need to load twice + [get_class(), get_class()] +} + +#[no_mangle] +fn use_in_loop(n: usize) { + for _i in 0..n { + // Should be a noop + let _ = class!(NSLock); + } +} diff --git a/test-assembly/crates/test_static_sel/expected/apple-aarch64.s b/test-assembly/crates/test_static_sel/expected/apple-aarch64.s index f4bfc5ae3..ab21723d6 100644 --- a/test-assembly/crates/test_static_sel/expected/apple-aarch64.s +++ b/test-assembly/crates/test_static_sel/expected/apple-aarch64.s @@ -23,9 +23,9 @@ Lloh3: .p2align 2 _get_common_twice: Lloh4: - adrp x8, L_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2@GOTPAGE + adrp x8, L_OBJC_SELECTOR_REFERENCES_234aca269670483c@GOTPAGE Lloh5: - ldr x8, [x8, L_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2@GOTPAGEOFF] + ldr x8, [x8, L_OBJC_SELECTOR_REFERENCES_234aca269670483c@GOTPAGEOFF] Lloh6: ldr x0, [x8] mov x1, x0 diff --git a/test-assembly/crates/test_static_sel/expected/apple-armv7.s b/test-assembly/crates/test_static_sel/expected/apple-armv7.s index f196dd37b..02297ab34 100644 --- a/test-assembly/crates/test_static_sel/expected/apple-armv7.s +++ b/test-assembly/crates/test_static_sel/expected/apple-armv7.s @@ -24,8 +24,8 @@ LPC1_0: .p2align 2 .code 32 _get_common_twice: - movw r0, :lower16:(LL_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2$non_lazy_ptr-(LPC2_0+8)) - movt r0, :upper16:(LL_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2$non_lazy_ptr-(LPC2_0+8)) + movw r0, :lower16:(LL_OBJC_SELECTOR_REFERENCES_234aca269670483c$non_lazy_ptr-(LPC2_0+8)) + movt r0, :upper16:(LL_OBJC_SELECTOR_REFERENCES_234aca269670483c$non_lazy_ptr-(LPC2_0+8)) LPC2_0: ldr r0, [pc, r0] ldr r0, [r0] @@ -195,8 +195,8 @@ L_OBJC_SELECTOR_REFERENCES_c831c01ba82dcc2e: .section __DATA,__nl_symbol_ptr,non_lazy_symbol_pointers .p2align 2 -LL_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2$non_lazy_ptr: - .indirect_symbol L_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2 +LL_OBJC_SELECTOR_REFERENCES_234aca269670483c$non_lazy_ptr: + .indirect_symbol L_OBJC_SELECTOR_REFERENCES_234aca269670483c .long 0 .subsections_via_symbols diff --git a/test-assembly/crates/test_static_sel/expected/apple-armv7s.s b/test-assembly/crates/test_static_sel/expected/apple-armv7s.s index f196dd37b..02297ab34 100644 --- a/test-assembly/crates/test_static_sel/expected/apple-armv7s.s +++ b/test-assembly/crates/test_static_sel/expected/apple-armv7s.s @@ -24,8 +24,8 @@ LPC1_0: .p2align 2 .code 32 _get_common_twice: - movw r0, :lower16:(LL_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2$non_lazy_ptr-(LPC2_0+8)) - movt r0, :upper16:(LL_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2$non_lazy_ptr-(LPC2_0+8)) + movw r0, :lower16:(LL_OBJC_SELECTOR_REFERENCES_234aca269670483c$non_lazy_ptr-(LPC2_0+8)) + movt r0, :upper16:(LL_OBJC_SELECTOR_REFERENCES_234aca269670483c$non_lazy_ptr-(LPC2_0+8)) LPC2_0: ldr r0, [pc, r0] ldr r0, [r0] @@ -195,8 +195,8 @@ L_OBJC_SELECTOR_REFERENCES_c831c01ba82dcc2e: .section __DATA,__nl_symbol_ptr,non_lazy_symbol_pointers .p2align 2 -LL_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2$non_lazy_ptr: - .indirect_symbol L_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2 +LL_OBJC_SELECTOR_REFERENCES_234aca269670483c$non_lazy_ptr: + .indirect_symbol L_OBJC_SELECTOR_REFERENCES_234aca269670483c .long 0 .subsections_via_symbols diff --git a/test-assembly/crates/test_static_sel/expected/apple-old-x86.s b/test-assembly/crates/test_static_sel/expected/apple-old-x86.s index d8126d4e8..8b034f9a3 100644 --- a/test-assembly/crates/test_static_sel/expected/apple-old-x86.s +++ b/test-assembly/crates/test_static_sel/expected/apple-old-x86.s @@ -32,7 +32,7 @@ _get_common_twice: call L2$pb L2$pb: pop eax - mov eax, dword ptr [eax + LL_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2$non_lazy_ptr-L2$pb] + mov eax, dword ptr [eax + LL_OBJC_SELECTOR_REFERENCES_234aca269670483c$non_lazy_ptr-L2$pb] mov eax, dword ptr [eax] mov edx, eax pop ebp @@ -208,8 +208,8 @@ L_OBJC_SELECTOR_REFERENCES_c831c01ba82dcc2e: .long L_OBJC_METH_VAR_NAME_c831c01ba82dcc2e .section __IMPORT,__pointers,non_lazy_symbol_pointers -LL_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2$non_lazy_ptr: - .indirect_symbol L_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2 +LL_OBJC_SELECTOR_REFERENCES_234aca269670483c$non_lazy_ptr: + .indirect_symbol L_OBJC_SELECTOR_REFERENCES_234aca269670483c .long 0 .subsections_via_symbols diff --git a/test-assembly/crates/test_static_sel/expected/apple-x86.s b/test-assembly/crates/test_static_sel/expected/apple-x86.s index a0cbf62fd..48bebe0a4 100644 --- a/test-assembly/crates/test_static_sel/expected/apple-x86.s +++ b/test-assembly/crates/test_static_sel/expected/apple-x86.s @@ -32,7 +32,7 @@ _get_common_twice: call L2$pb L2$pb: pop eax - mov eax, dword ptr [eax + LL_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2$non_lazy_ptr-L2$pb] + mov eax, dword ptr [eax + LL_OBJC_SELECTOR_REFERENCES_234aca269670483c$non_lazy_ptr-L2$pb] mov eax, dword ptr [eax] mov edx, eax pop ebp @@ -208,8 +208,8 @@ L_OBJC_SELECTOR_REFERENCES_c831c01ba82dcc2e: .long L_OBJC_METH_VAR_NAME_c831c01ba82dcc2e .section __IMPORT,__pointers,non_lazy_symbol_pointers -LL_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2$non_lazy_ptr: - .indirect_symbol L_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2 +LL_OBJC_SELECTOR_REFERENCES_234aca269670483c$non_lazy_ptr: + .indirect_symbol L_OBJC_SELECTOR_REFERENCES_234aca269670483c .long 0 .subsections_via_symbols diff --git a/test-assembly/crates/test_static_sel/expected/apple-x86_64.s b/test-assembly/crates/test_static_sel/expected/apple-x86_64.s index f2cc42fed..d856c98f3 100644 --- a/test-assembly/crates/test_static_sel/expected/apple-x86_64.s +++ b/test-assembly/crates/test_static_sel/expected/apple-x86_64.s @@ -23,7 +23,7 @@ _get_same_sel: _get_common_twice: push rbp mov rbp, rsp - mov rax, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_1678d2f7468155d2@GOTPCREL] + mov rax, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_234aca269670483c@GOTPCREL] mov rax, qword ptr [rax] mov rdx, rax pop rbp