2424use dwarf:: DwarfReader ;
2525use core:: mem;
2626
27- pub const DW_EH_PE_omit : u8 = 0xFF ;
28- pub const DW_EH_PE_absptr : u8 = 0x00 ;
29-
30- pub const DW_EH_PE_uleb128 : u8 = 0x01 ;
31- pub const DW_EH_PE_udata2 : u8 = 0x02 ;
32- pub const DW_EH_PE_udata4 : u8 = 0x03 ;
33- pub const DW_EH_PE_udata8 : u8 = 0x04 ;
34- pub const DW_EH_PE_sleb128 : u8 = 0x09 ;
35- pub const DW_EH_PE_sdata2 : u8 = 0x0A ;
36- pub const DW_EH_PE_sdata4 : u8 = 0x0B ;
37- pub const DW_EH_PE_sdata8 : u8 = 0x0C ;
38-
39- pub const DW_EH_PE_pcrel : u8 = 0x10 ;
40- pub const DW_EH_PE_textrel : u8 = 0x20 ;
41- pub const DW_EH_PE_datarel : u8 = 0x30 ;
42- pub const DW_EH_PE_funcrel : u8 = 0x40 ;
43- pub const DW_EH_PE_aligned : u8 = 0x50 ;
44-
45- pub const DW_EH_PE_indirect : u8 = 0x80 ;
27+ pub const DW_EH_PE_omit : u8 = 0xFF ;
28+ pub const DW_EH_PE_absptr : u8 = 0x00 ;
29+
30+ pub const DW_EH_PE_uleb128 : u8 = 0x01 ;
31+ pub const DW_EH_PE_udata2 : u8 = 0x02 ;
32+ pub const DW_EH_PE_udata4 : u8 = 0x03 ;
33+ pub const DW_EH_PE_udata8 : u8 = 0x04 ;
34+ pub const DW_EH_PE_sleb128 : u8 = 0x09 ;
35+ pub const DW_EH_PE_sdata2 : u8 = 0x0A ;
36+ pub const DW_EH_PE_sdata4 : u8 = 0x0B ;
37+ pub const DW_EH_PE_sdata8 : u8 = 0x0C ;
38+
39+ pub const DW_EH_PE_pcrel : u8 = 0x10 ;
40+ pub const DW_EH_PE_textrel : u8 = 0x20 ;
41+ pub const DW_EH_PE_datarel : u8 = 0x30 ;
42+ pub const DW_EH_PE_funcrel : u8 = 0x40 ;
43+ pub const DW_EH_PE_aligned : u8 = 0x50 ;
44+
45+ pub const DW_EH_PE_indirect : u8 = 0x80 ;
4646
4747#[ derive( Copy , Clone ) ]
4848pub struct EHContext {
49- pub ip : usize , // Current instruction pointer
49+ pub ip : usize , // Current instruction pointer
5050 pub func_start : usize , // Address of the current function
5151 pub text_start : usize , // Address of the code section
5252 pub data_start : usize , // Address of the data section
5353}
5454
55- pub unsafe fn find_landing_pad ( lsda : * const u8 , context : & EHContext )
56- -> Option < usize > {
55+ pub unsafe fn find_landing_pad ( lsda : * const u8 , context : & EHContext ) -> Option < usize > {
5756 if lsda. is_null ( ) {
5857 return None ;
5958 }
@@ -80,7 +79,7 @@ pub unsafe fn find_landing_pad(lsda: *const u8, context: &EHContext)
8079 let action_table = reader. ptr . offset ( call_site_table_length as isize ) ;
8180 // Return addresses point 1 byte past the call instruction, which could
8281 // be in the next IP range.
83- let ip = context. ip - 1 ;
82+ let ip = context. ip - 1 ;
8483
8584 while reader. ptr < action_table {
8685 let cs_start = read_encoded_pointer ( & mut reader, context, call_site_encoding) ;
@@ -90,7 +89,7 @@ pub unsafe fn find_landing_pad(lsda: *const u8, context: &EHContext)
9089 // Callsite table is sorted by cs_start, so if we've passed the ip, we
9190 // may stop searching.
9291 if ip < func_start + cs_start {
93- break
92+ break ;
9493 }
9594 if ip < func_start + cs_start + cs_len {
9695 if cs_lpad != 0 {
@@ -114,13 +113,13 @@ fn round_up(unrounded: usize, align: usize) -> usize {
114113
115114unsafe fn read_encoded_pointer ( reader : & mut DwarfReader ,
116115 context : & EHContext ,
117- encoding : u8 ) -> usize {
116+ encoding : u8 )
117+ -> usize {
118118 assert ! ( encoding != DW_EH_PE_omit ) ;
119119
120120 // DW_EH_PE_aligned implies it's an absolute pointer value
121121 if encoding == DW_EH_PE_aligned {
122- reader. ptr = round_up ( reader. ptr as usize ,
123- mem:: size_of :: < usize > ( ) ) as * const u8 ;
122+ reader. ptr = round_up ( reader. ptr as usize , mem:: size_of :: < usize > ( ) ) as * const u8 ;
124123 return reader. read :: < usize > ( ) ;
125124 }
126125
@@ -134,20 +133,26 @@ unsafe fn read_encoded_pointer(reader: &mut DwarfReader,
134133 DW_EH_PE_sdata2 => reader. read :: < i16 > ( ) as usize ,
135134 DW_EH_PE_sdata4 => reader. read :: < i32 > ( ) as usize ,
136135 DW_EH_PE_sdata8 => reader. read :: < i64 > ( ) as usize ,
137- _ => panic ! ( )
136+ _ => panic ! ( ) ,
138137 } ;
139138
140139 result += match encoding & 0x70 {
141140 DW_EH_PE_absptr => 0 ,
142141 // relative to address of the encoded value, despite the name
143142 DW_EH_PE_pcrel => reader. ptr as usize ,
144- DW_EH_PE_textrel => { assert ! ( context. text_start != 0 ) ;
145- context. text_start } ,
146- DW_EH_PE_datarel => { assert ! ( context. data_start != 0 ) ;
147- context. data_start } ,
148- DW_EH_PE_funcrel => { assert ! ( context. func_start != 0 ) ;
149- context. func_start } ,
150- _ => panic ! ( )
143+ DW_EH_PE_textrel => {
144+ assert ! ( context. text_start != 0 ) ;
145+ context. text_start
146+ }
147+ DW_EH_PE_datarel => {
148+ assert ! ( context. data_start != 0 ) ;
149+ context. data_start
150+ }
151+ DW_EH_PE_funcrel => {
152+ assert ! ( context. func_start != 0 ) ;
153+ context. func_start
154+ }
155+ _ => panic ! ( ) ,
151156 } ;
152157
153158 if encoding & DW_EH_PE_indirect != 0 {
0 commit comments