]>
git.proxmox.com Git - rustc.git/blob - library/backtrace/tests/sgx-image-base.rs
1 #![cfg(all(target_env = "sgx", target_vendor = "fortanix"))]
2 #![feature(sgx_platform)]
4 #[cfg(feature = "std")]
6 fn sgx_image_base_with_std() {
9 let image_base
= std
::os
::fortanix_sgx
::mem
::image_base();
11 let mut frame_ips
= Vec
::new();
13 frame_ips
.push(frame
.ip());
17 assert
!(frame_ips
.len() > 0);
19 let ip
: u64 = ip
as _
;
20 assert
!(ip
< image_base
);
24 #[cfg(not(feature = "std"))]
26 fn sgx_image_base_no_std() {
27 use backtrace
::trace_unsynchronized
;
29 fn guess_image_base() -> u64 {
30 let mut top_frame_ip
= None
;
32 trace_unsynchronized(|frame
| {
33 top_frame_ip
= Some(frame
.ip());
37 top_frame_ip
.unwrap() as u64 & 0xFFFFFF000000
40 let image_base
= guess_image_base();
41 backtrace
::set_image_base(image_base
as _
);
43 let mut frame_ips
= Vec
::new();
45 trace_unsynchronized(|frame
| {
46 frame_ips
.push(frame
.ip());
51 assert
!(frame_ips
.len() > 0);
53 let ip
: u64 = ip
as _
;
54 assert
!(ip
< image_base
);