File tree 4 files changed +22
-5
lines changed
4 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ gimli = { version = "0.16.0", optional = true }
32
32
memmap = { version = " 0.7.0" , optional = true }
33
33
object = { version = " 0.9.0" , optional = true }
34
34
35
- [target .'cfg(unix)' .dependencies ]
35
+ [target .'cfg(any( unix, target_env = "sgx") )' .dependencies ]
36
36
libc = { version = " 0.2.45" , default-features = false }
37
37
38
38
[target .'cfg(windows)' .dependencies ]
Original file line number Diff line number Diff line change @@ -104,10 +104,11 @@ impl fmt::Debug for Frame {
104
104
}
105
105
106
106
cfg_if ! {
107
- if #[ cfg( all( unix,
107
+ if #[ cfg( any ( all( unix,
108
108
not( target_os = "emscripten" ) ,
109
109
not( all( target_os = "ios" , target_arch = "arm" ) ) ,
110
- feature = "libunwind" ) ) ] {
110
+ feature = "libunwind" ) ,
111
+ target_env="sgx" ) ) ] {
111
112
mod libunwind;
112
113
use self :: libunwind:: trace as trace_imp;
113
114
use self :: libunwind:: Frame as FrameImp ;
Original file line number Diff line number Diff line change @@ -229,7 +229,22 @@ impl fmt::Debug for Backtrace {
229
229
} ;
230
230
231
231
for ( idx, frame) in iter. enumerate ( ) {
232
- let ip = frame. ip ( ) ;
232
+ // To reduce TCB size in Sgx enclave, we do not want to implement symbol resolution functionality.
233
+ // Rather, we can print the offset of the address here, which could be later mapped to
234
+ // correct function.
235
+ let ip: * mut c_void ;
236
+ #[ cfg( target_env = "sgx" ) ]
237
+ {
238
+ ip = usize:: wrapping_sub (
239
+ frame. ip ( ) as _ ,
240
+ std:: os:: fortanix_sgx:: mem:: image_base ( ) as _ ,
241
+ ) as _ ;
242
+ }
243
+ #[ cfg( not( target_env = "sgx" ) ) ]
244
+ {
245
+ ip = frame. ip ( ) ;
246
+ }
247
+
233
248
write ! ( fmt, "\n {:4}: " , idx) ?;
234
249
235
250
let symbols = match frame. symbols {
Original file line number Diff line number Diff line change 71
71
#![ doc( html_root_url = "https://docs.rs/backtrace" ) ]
72
72
#![ deny( missing_docs) ]
73
73
#![ no_std]
74
+ #![ cfg_attr( target_env = "sgx" , feature( sgx_platform) ) ]
74
75
75
76
#[ cfg( feature = "std" ) ]
76
77
#[ macro_use] extern crate std;
77
78
78
- #[ cfg( unix) ]
79
+ #[ cfg( any ( unix, target_env = "sgx" ) ) ]
79
80
extern crate libc;
80
81
#[ cfg( windows) ]
81
82
extern crate winapi;
You can’t perform that action at this time.
0 commit comments