@@ -7,7 +7,7 @@ use object::{
7
7
elf, File , Object , ObjectSection , ObjectSymbol , Relocation , RelocationFlags , RelocationTarget ,
8
8
Symbol , SymbolKind ,
9
9
} ;
10
- use ppc750cl:: { Argument , InsIter , GPR } ;
10
+ use ppc750cl:: { Argument , InsIter , Opcode , GPR } ;
11
11
12
12
use crate :: {
13
13
arch:: { DataType , ObjArch , ProcessCodeResult } ,
@@ -194,19 +194,21 @@ impl ObjArch for ObjArchPpc {
194
194
return Some ( DataType :: String ) ;
195
195
}
196
196
197
- match instruction. mnemonic . as_str ( ) {
198
- "lbz" | "lbzu" | "lbzux" | "lbzx" => Some ( DataType :: Int8 ) ,
199
- "lhz" | "lhzu" | "lhzux" | "lhzx" => Some ( DataType :: Int16 ) ,
200
- "lha" | "lhau" | "lhaux" | "lhax" => Some ( DataType :: Int16 ) ,
201
- "lwz" | "lwzu" | "lwzux" | "lwzx" => Some ( DataType :: Int32 ) ,
202
- "lfs" | "lfsu" | "lfsux" | "lfsx" => Some ( DataType :: Float ) ,
203
- "lfd" | "lfdu" | "lfdux" | "lfdx" => Some ( DataType :: Double ) ,
204
-
205
- "stb" | "stbu" | "stbux" | "stbx" => Some ( DataType :: Int8 ) ,
206
- "sth" | "sthu" | "sthux" | "sthx" => Some ( DataType :: Int16 ) ,
207
- "stw" | "stwu" | "stwux" | "stwx" => Some ( DataType :: Int32 ) ,
208
- "stfs" | "stfsu" | "stfsux" | "stfsx" => Some ( DataType :: Float ) ,
209
- "stfd" | "stfdu" | "stfdux" | "stfdx" => Some ( DataType :: Double ) ,
197
+ // SAFETY: ppc750cl::Opcode is repr(u8) and op is originally obtained on PPC from casting
198
+ // an Opcode to a u8 so we know it's a valid value for Opcode.
199
+ match unsafe { std:: mem:: transmute :: < u8 , Opcode > ( instruction. op as u8 ) } {
200
+ Opcode :: Lbz | Opcode :: Lbzu | Opcode :: Lbzux | Opcode :: Lbzx => Some ( DataType :: Int8 ) ,
201
+ Opcode :: Lhz | Opcode :: Lhzu | Opcode :: Lhzux | Opcode :: Lhzx => Some ( DataType :: Int16 ) ,
202
+ Opcode :: Lha | Opcode :: Lhau | Opcode :: Lhaux | Opcode :: Lhax => Some ( DataType :: Int16 ) ,
203
+ Opcode :: Lwz | Opcode :: Lwzu | Opcode :: Lwzux | Opcode :: Lwzx => Some ( DataType :: Int32 ) ,
204
+ Opcode :: Lfs | Opcode :: Lfsu | Opcode :: Lfsux | Opcode :: Lfsx => Some ( DataType :: Float ) ,
205
+ Opcode :: Lfd | Opcode :: Lfdu | Opcode :: Lfdux | Opcode :: Lfdx => Some ( DataType :: Double ) ,
206
+
207
+ Opcode :: Stb | Opcode :: Stbu | Opcode :: Stbux | Opcode :: Stbx => Some ( DataType :: Int8 ) ,
208
+ Opcode :: Sth | Opcode :: Sthu | Opcode :: Sthux | Opcode :: Sthx => Some ( DataType :: Int16 ) ,
209
+ Opcode :: Stw | Opcode :: Stwu | Opcode :: Stwux | Opcode :: Stwx => Some ( DataType :: Int32 ) ,
210
+ Opcode :: Stfs | Opcode :: Stfsu | Opcode :: Stfsux | Opcode :: Stfsx => Some ( DataType :: Float ) ,
211
+ Opcode :: Stfd | Opcode :: Stfdu | Opcode :: Stfdux | Opcode :: Stfdx => Some ( DataType :: Double ) ,
210
212
_ => None ,
211
213
}
212
214
}
0 commit comments