@@ -95,17 +95,7 @@ pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext<'_>) -> Result
95
95
return Ok ( EHAction :: None ) ;
96
96
} else {
97
97
let lpad = lpad_base + cs_lpad;
98
- if cs_action_entry == 0 {
99
- return Ok ( interpret_cs_action ( 0 , lpad) ) ;
100
- } else {
101
- let action_record =
102
- ( action_table as * mut u8 ) . offset ( cs_action_entry as isize - 1 ) ;
103
- let mut action_reader = DwarfReader :: new ( action_record) ;
104
- let ttype_index = action_reader. read_sleb128 ( ) ;
105
- // Normally, if ttype_index < 0, meaning the catch type is exception specification.
106
- // Since we only care about if ttype_index is zero, so casting ttype_index to u64 makes sense.
107
- return Ok ( interpret_cs_action ( ttype_index as u64 , lpad) ) ;
108
- }
98
+ return Ok ( interpret_cs_action ( action_table as * mut u8 , cs_action_entry, lpad) ) ;
109
99
}
110
100
}
111
101
}
@@ -129,28 +119,31 @@ pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext<'_>) -> Result
129
119
// Can never have null landing pad for sjlj -- that would have
130
120
// been indicated by a -1 call site index.
131
121
let lpad = ( cs_lpad + 1 ) as usize ;
132
- if cs_action_entry == 0 {
133
- return Ok ( interpret_cs_action ( 0 , lpad) ) ;
134
- } else {
135
- let action_record =
136
- ( action_table as * mut u8 ) . offset ( cs_action_entry as isize - 1 ) ;
137
- let mut action_reader = DwarfReader :: new ( action_record) ;
138
- let ttype_index = action_reader. read_sleb128 ( ) ;
139
- return Ok ( interpret_cs_action ( ttype_index as u64 , lpad) ) ;
140
- }
122
+ return Ok ( interpret_cs_action ( action_table as * mut u8 , cs_action_entry, lpad) ) ;
141
123
}
142
124
}
143
125
}
144
126
}
145
127
146
- fn interpret_cs_action ( cs_action : u64 , lpad : usize ) -> EHAction {
147
- if cs_action == 0 {
128
+ unsafe fn interpret_cs_action (
129
+ action_table : * mut u8 ,
130
+ cs_action_entry : u64 ,
131
+ lpad : usize ,
132
+ ) -> EHAction {
133
+ if cs_action_entry == 0 {
148
134
// If cs_action is 0 then this is a cleanup (Drop::drop). We run these
149
135
// for both Rust panics and foreign exceptions.
150
136
EHAction :: Cleanup ( lpad)
151
137
} else {
152
- // Stop unwinding Rust panics at catch_unwind.
153
- EHAction :: Catch ( lpad)
138
+ let action_record = ( action_table as * mut u8 ) . offset ( cs_action_entry as isize - 1 ) ;
139
+ let mut action_reader = DwarfReader :: new ( action_record) ;
140
+ let ttype_index = action_reader. read_sleb128 ( ) ;
141
+ if ttype_index == 0 {
142
+ EHAction :: Cleanup ( lpad)
143
+ } else {
144
+ // Stop unwinding Rust panics at catch_unwind.
145
+ EHAction :: Catch ( lpad)
146
+ }
154
147
}
155
148
}
156
149
0 commit comments