@@ -125,39 +125,46 @@ impl fmt::Debug for Frame {
125125 }
126126}
127127
128- #[ cfg( all( target_env = "sgx" , target_vendor = "fortanix" , not( feature = "std" ) ) ) ]
129- mod sgx_no_std_image_base {
130- use core:: ffi:: c_void;
131- use core:: sync:: atomic:: { AtomicUsize , Ordering :: SeqCst } ;
132-
133- static IMAGE_BASE : AtomicUsize = AtomicUsize :: new ( 0 ) ;
134-
135- /// Set the image base address. This is only available for Fortanix SGX
136- /// target when the `std` feature is not enabled. This can be used in the
137- /// standard library to set the correct base address.
138- #[ doc( hidden) ]
139- pub fn set_image_base ( base_addr : * mut c_void ) {
140- IMAGE_BASE . store ( base_addr as _ , SeqCst ) ;
128+ #[ cfg( all( target_env = "sgx" , target_vendor = "fortanix" , not( miri) ) ) ]
129+ mod sgx_image_base {
130+
131+ #[ cfg( not( feature = "std" ) ) ]
132+ pub ( crate ) mod imp {
133+ use core:: sync:: atomic:: { AtomicUsize , Ordering :: SeqCst } ;
134+
135+ static IMAGE_BASE : AtomicUsize = AtomicUsize :: new ( 0 ) ;
136+
137+ /// Set the image base address. This is only available for Fortanix SGX
138+ /// target when the `std` feature is not enabled. This can be used in the
139+ /// standard library to set the correct base address.
140+ #[ doc( hidden) ]
141+ pub fn set_image_base ( base_addr : * mut c_void ) {
142+ IMAGE_BASE . store ( base_addr as _ , SeqCst ) ;
143+ }
144+
145+ pub ( crate ) fn get_image_base ( ) -> * mut c_void {
146+ IMAGE_BASE . load ( SeqCst ) as _
147+ }
141148 }
142149
143- pub ( crate ) fn get_image_base ( ) -> * mut c_void {
144- IMAGE_BASE . load ( SeqCst ) as _
150+ #[ cfg( feature = "std" ) ]
151+ mod imp {
152+ pub ( crate ) fn get_image_base ( ) -> * mut c_void {
153+ std:: os:: fortanix_sgx:: mem:: image_base ( ) as _
154+ }
145155 }
146- }
147-
148- #[ cfg( all( target_env = "sgx" , target_vendor = "fortanix" , not( feature = "std" ) ) ) ]
149- pub use self :: sgx_no_std_image_base:: set_image_base;
150156
151- #[ cfg( all( target_env = "sgx" , target_vendor = "fortanix" , not( feature = "std" ) ) ) ]
152- #[ deny( unused) ]
153- pub ( crate ) use self :: sgx_no_std_image_base:: get_image_base;
154-
155- #[ cfg( all( target_env = "sgx" , target_vendor = "fortanix" , feature = "std" ) ) ]
156- #[ deny( unused) ]
157- pub ( crate ) fn get_image_base ( ) -> * mut c_void {
158- std:: os:: fortanix_sgx:: mem:: image_base ( ) as _
157+ pub ( crate ) use imp:: get_image_base;
159158}
160159
160+ #[ cfg( all(
161+ target_env = "sgx" ,
162+ target_vendor = "fortanix" ,
163+ not( feature = "std" ) ,
164+ not( miri)
165+ ) ) ]
166+ pub use sgx_image_base:: imp:: set_image_base;
167+
161168cfg_if:: cfg_if! {
162169 // This needs to come first, to ensure that
163170 // Miri takes priority over the host platform
0 commit comments