about summary refs log tree commit diff stats
path: root/miasm2/arch/x86
diff options
context:
space:
mode:
Diffstat (limited to 'miasm2/arch/x86')
-rw-r--r--miasm2/arch/x86/ctype.py137
1 files changed, 108 insertions, 29 deletions
diff --git a/miasm2/arch/x86/ctype.py b/miasm2/arch/x86/ctype.py
index 6b5844d7..0d8cd924 100644
--- a/miasm2/arch/x86/ctype.py
+++ b/miasm2/arch/x86/ctype.py
@@ -1,7 +1,8 @@
-from miasm2.core.objc import CTypeTemplate, ObjCDecl
+from miasm2.core.objc import CLeafTypes, ObjCDecl
+from miasm2.core.ctypesmngr import CTypeId, CTypePtr
 
 
-class CTypeAMD64_unk(CTypeTemplate):
+class CTypeAMD64_unk(CLeafTypes):
     """Define C types sizes/alignement for x86_64 architecture"""
 
     obj_char = ObjCDecl("char", 1, 1)
@@ -13,38 +14,116 @@ class CTypeAMD64_unk(CTypeTemplate):
     obj_ushort = ObjCDecl("ushort", 2, 2)
     obj_uint = ObjCDecl("uint", 4, 4)
     obj_ulong = ObjCDecl("ulong", 8, 8)
+
+    obj_void = ObjCDecl("void", 1, 1)
+
+    obj_enum = ObjCDecl("enum", 4, 4)
+
+    obj_float = ObjCDecl("float", 4, 4)
+    obj_double = ObjCDecl("double", 8, 8)
+    obj_ldouble = ObjCDecl("ldouble", 16, 16)
+
+    def __init__(self):
+        self.types = {
+            CTypeId('char'): self.obj_char,
+            CTypeId('short'): self.obj_short,
+            CTypeId('int'): self.obj_int,
+            CTypeId('void'): self.obj_void,
+            CTypeId('long',): self.obj_long,
+            CTypeId('float'): self.obj_float,
+            CTypeId('double'): self.obj_double,
+
+            CTypeId('signed', 'char'): self.obj_char,
+            CTypeId('unsigned', 'char'): self.obj_uchar,
+
+            CTypeId('short', 'int'): self.obj_short,
+            CTypeId('signed', 'short'): self.obj_short,
+            CTypeId('signed', 'short', 'int'): self.obj_short,
+            CTypeId('unsigned', 'short'): self.obj_ushort,
+            CTypeId('unsigned', 'short', 'int'): self.obj_ushort,
+
+            CTypeId('unsigned', ): self.obj_uint,
+            CTypeId('unsigned', 'int'): self.obj_uint,
+            CTypeId('signed', 'int'): self.obj_int,
+
+            CTypeId('long', 'int'): self.obj_long,
+            CTypeId('long', 'long'): self.obj_long,
+            CTypeId('long', 'long', 'int'): self.obj_long,
+            CTypeId('signed', 'long', 'long'): self.obj_long,
+            CTypeId('unsigned', 'long', 'long'): self.obj_ulong,
+            CTypeId('signed', 'long', 'long', 'int'): self.obj_long,
+            CTypeId('unsigned', 'long', 'long', 'int'): self.obj_ulong,
+
+            CTypeId('signed', 'long'): self.obj_long,
+            CTypeId('unsigned', 'long'): self.obj_ulong,
+            CTypeId('signed', 'long', 'int'): self.obj_long,
+            CTypeId('unsigned', 'long', 'int'): self.obj_ulong,
+
+            CTypeId('long', 'double'): self.obj_ldouble,
+            CTypePtr(CTypeId('void')): self.obj_ulong,
+        }
+
+
+
+
+
+class CTypeX86_unk(CLeafTypes):
+    """Define C types sizes/alignement for x86_64 architecture"""
+
+    obj_char = ObjCDecl("char", 1, 1)
+    obj_short = ObjCDecl("short", 2, 2)
+    obj_int = ObjCDecl("int", 4, 4)
+    obj_long = ObjCDecl("long", 4, 4)
+
+    obj_uchar = ObjCDecl("uchar", 1, 1)
+    obj_ushort = ObjCDecl("ushort", 2, 2)
+    obj_uint = ObjCDecl("uint", 4, 4)
+    obj_ulong = ObjCDecl("ulong", 4, 4)
+
     obj_void = ObjCDecl("void", 1, 1)
 
     obj_enum = ObjCDecl("enum", 4, 4)
 
+    obj_float = ObjCDecl("float", 4, 4)
+    obj_double = ObjCDecl("double", 8, 8)
+    obj_ldouble = ObjCDecl("ldouble", 16, 16)
 
     def __init__(self):
         self.types = {
-            ('char',): self.obj_char,
-            ('short',): self.obj_short,
-            ('int',): self.obj_int,
-            ('void',): self.obj_void,
-            ('enum',): self.obj_enum,
-
-            ('signed', 'char'): self.obj_char,
-            ('unsigned', 'char'): self.obj_uchar,
-            ('signed', 'short', 'int'): self.obj_short,
-            ('short', 'int'): self.obj_short,
-            ('unsigned', 'short'): self.obj_ushort,
-            ('unsigned', 'short', 'int'): self.obj_ushort,
-            ('signed', 'int'): self.obj_int,
-            ('unsigned', 'int'): self.obj_uint,
-            ('long', 'int'): self.obj_long,
-            ('unsigned', 'long'): self.obj_ulong,
-            ('signed', 'long', 'int'): self.obj_long,
-            ('unsigned', 'long', 'int'): self.obj_ulong,
-            ('long',): self.obj_long,
-            ('unsigned', ): self.obj_uint,
-
-            ('signed', 'long', 'long', 'int'): self.obj_long,
-            ('long', 'unsigned', 'int'): self.obj_ulong,
-            ('unsigned', 'long', 'long'): self.obj_ulong,
-            ('long', 'long', 'int'): self.obj_long,
-            ('unsigned', 'long', 'long', 'int'): self.obj_ulong,
-            ('void*',): self.obj_ulong,
+            CTypeId('char'): self.obj_char,
+            CTypeId('short'): self.obj_short,
+            CTypeId('int'): self.obj_int,
+            CTypeId('void'): self.obj_void,
+            CTypeId('long',): self.obj_long,
+            CTypeId('float'): self.obj_float,
+            CTypeId('double'): self.obj_double,
+
+            CTypeId('signed', 'char'): self.obj_char,
+            CTypeId('unsigned', 'char'): self.obj_uchar,
+
+            CTypeId('short', 'int'): self.obj_short,
+            CTypeId('signed', 'short'): self.obj_short,
+            CTypeId('signed', 'short', 'int'): self.obj_short,
+            CTypeId('unsigned', 'short'): self.obj_ushort,
+            CTypeId('unsigned', 'short', 'int'): self.obj_ushort,
+
+            CTypeId('unsigned', ): self.obj_uint,
+            CTypeId('unsigned', 'int'): self.obj_uint,
+            CTypeId('signed', 'int'): self.obj_int,
+
+            CTypeId('long', 'int'): self.obj_long,
+            CTypeId('long', 'long'): self.obj_long,
+            CTypeId('long', 'long', 'int'): self.obj_long,
+            CTypeId('signed', 'long', 'long'): self.obj_long,
+            CTypeId('unsigned', 'long', 'long'): self.obj_ulong,
+            CTypeId('signed', 'long', 'long', 'int'): self.obj_long,
+            CTypeId('unsigned', 'long', 'long', 'int'): self.obj_ulong,
+
+            CTypeId('signed', 'long'): self.obj_long,
+            CTypeId('unsigned', 'long'): self.obj_ulong,
+            CTypeId('signed', 'long', 'int'): self.obj_long,
+            CTypeId('unsigned', 'long', 'int'): self.obj_ulong,
+
+            CTypeId('long', 'double'): self.obj_ldouble,
+            CTypePtr(CTypeId('void')): self.obj_uint,
         }