Example #1
0
 def __init__(self, *args, **kwargs):
     AIStruct.__init__(self, AIStruct.SIZE32)
     self.section = kwargs["section"]
     self.setup(('UINT32', 'st_name', {
         "format": self.section.get_sym_name
     }), ('UINT32', 'value'), ('UINT32', 'size'), ('UINT8', 'info'),
                ('UINT8', 'other'), ('UINT16', 'st_shndx'))
Example #2
0
	def __init__(self, *args, **kwargs):
		AIStruct.__init__(self, AIStruct.SIZE32)
		self.elffile = kwargs["elffile"]
		def format_flags(x):
			the_str = [' ', ' ', ' ']
			if (x & self.PF_X):
				the_str[2] = 'E'
			if (x & self.PF_W):
				the_str[1] = 'W'
			if (x & self.PF_R):
				the_str[0] = 'R'
			return "".join(the_str)
		
		self.setup(
			('UINT32', 'p_type', {"names" :
					      {0: "NULL",
					       1: "LOAD",
					       2 : "DYNAMIC",
					       3 : "INTERP",
					       4 : "NOTE",
					       1685382481 : "GNU_STACK",
					       1694766464 : "PAX_FLAGS",
					       }
					      }  ),
			('UINT32', 'p_offset', {"format": "0x%06x"}),
			('UINT32', 'p_vaddr', {"format": "0x%08x"}),
			('UINT32', 'p_paddr', {"format": "0x%08x"}),
			('UINT32', 'p_filesz', {"format": "0x%05x"}),
			('UINT32', 'p_memsz', {"format": "0x%05x"}),
			('UINT32', 'p_flags', {"format": format_flags}),
			('UINT32', 'p_align', {"format": "0x%x"}),
		)
Example #3
0
	def __init__(self, *args, **kwargs):
		AIStruct.__init__(self, AIStruct.SIZE32)
		self.elffile = kwargs["elffile"]
		self.index = kwargs["index"]

		def format_flags(x):
			if x == (self.SHF_WRITE | self.SHF_ALLOC):
				return "WA"
			if x == (self.SHF_EXECINSTR | self.SHF_ALLOC):
				return "AX"
			if x == self.SHF_WRITE:
				return "W"
			if x == self.SHF_ALLOC:
				return "A"
			if x == self.SHF_EXECINSTR:
				return "X"
			return "%x" % x

		self.mutated = 0
		self._name = None

		self.setup(
			('UINT32', 'sh_name', {"format" : self.elffile.get_name}),
			('UINT32', 'sh_type', {"names" : {0:"NULL", 1:"PROGBITS", 2:"SYMTAB", 3:"STRTAB", 8:"NOBITS"}}),
			('UINT32', 'sh_flags', {"format": format_flags}),
			('UINT32', 'sh_addr', {"format" : "%08x"}),
			('UINT32', 'sh_offset', {"format" : "%06x"}),
			('UINT32', 'sh_size', {"format" : "%06x"}),
			('UINT32', 'sh_link'),
			('UINT32', 'sh_info', {"format" : "%3d"}),
			('UINT32', 'sh_addralign', {"format" : "%2d"}),
			('UINT32', 'sh_entsize', {"format" : "%02x"}),
		)
Example #4
0
    def __init__(self, *args, **kwargs):
        AIStruct.__init__(self, AIStruct.SIZE32)
        self.elffile = kwargs["elffile"]
        self.index = kwargs["index"]

        def format_flags(x):
            if x == (self.SHF_WRITE | self.SHF_ALLOC):
                return "WA"
            if x == (self.SHF_EXECINSTR | self.SHF_ALLOC):
                return "AX"
            if x == self.SHF_WRITE:
                return "W"
            if x == self.SHF_ALLOC:
                return "A"
            if x == self.SHF_EXECINSTR:
                return "X"
            return "%x" % x

        self.mutated = 0
        self._name = None

        self.setup(
            ('UINT32', 'sh_name', {
                "format": self.elffile.get_name
            }),
            ('UINT32', 'sh_type', {
                "names": {
                    0: "NULL",
                    1: "PROGBITS",
                    2: "SYMTAB",
                    3: "STRTAB",
                    8: "NOBITS"
                }
            }),
            ('UINT32', 'sh_flags', {
                "format": format_flags
            }),
            ('UINT32', 'sh_addr', {
                "format": "%08x"
            }),
            ('UINT32', 'sh_offset', {
                "format": "%06x"
            }),
            ('UINT32', 'sh_size', {
                "format": "%06x"
            }),
            ('UINT32', 'sh_link'),
            ('UINT32', 'sh_info', {
                "format": "%3d"
            }),
            ('UINT32', 'sh_addralign', {
                "format": "%2d"
            }),
            ('UINT32', 'sh_entsize', {
                "format": "%02x"
            }),
        )
Example #5
0
 def __init__(self, *args, **kwargs):
     AIStruct.__init__(self, AIStruct.SIZE32)
     self.section = kwargs["section"]
     self.setup(
         ('UINT32', 'st_name', {"format" : self.section.get_sym_name}),
         ('UINT32', 'value'),
         ('UINT32', 'size'),
         ('UINT8', 'info'),
         ('UINT8', 'other'),
         ('UINT16', 'st_shndx')
         )
Example #6
0
File: elf.py Project: gz/aos10
	def __init__(self, *args, **kwargs):
		AIStruct.__init__(self, AIStruct.SIZE64)
		self.setup(
			('UINT32', 'p_type'),
			('UINT32', 'p_flags'),
			('UINT64', 'p_offset'),
			('UINT64', 'p_vaddr'),
			('UINT64', 'p_paddr'),
			('UINT64', 'p_filesz'),
			('UINT64', 'p_memsz'),
			('UINT64', 'p_align'),
		)
Example #7
0
	def __init__(self, *args, **kwargs):
		AIStruct.__init__(self, AIStruct.SIZE64)
		self.setup(
			('UINT32', 'p_type', {"names" : {0: "NULL", 1: "LOAD", 2 : "DYNAMIC", 3 : "INTERP", 4 : "NOTE"}}  ),
			('UINT32', 'p_flags'),
			('UINT64', 'p_offset'),
			('UINT64', 'p_vaddr'),
			('UINT64', 'p_paddr'),
			('UINT64', 'p_filesz'),
			('UINT64', 'p_memsz'),
			('UINT64', 'p_align'),
		)
Example #8
0
 def __init__(self):
     AIStruct.__init__(self, AIStruct.SIZE32)
     self.setup(('UINT8', 'ei_magic', {
         'times': 4
     }), ('UINT8', 'ei_class', {
         'names': {
             1: "ELF32",
             2: "ELF64"
         }
     }), ('UINT8', 'ei_data', {
         'names': {
             1: "2's complement, little endian",
             2: "2's complement, big endian"
         }
     }), ('UINT8', 'ei_version', {
         'names': {
             1: "1 (current)"
         }
     }), ('UINT8', 'ei_osabi', {
         'names': {
             0: "UNIX - System V",
             1: "HP-UX Operating System",
             255: "Standalone application"
         }
     }), ('UINT8', 'ei_abiversion'), ('UINT8', 'ei_padding', {
         'times': 7
     }), ('UINT16', 'e_type', {
         'names': {
             2: "EXEC (Executable file)"
         }
     }), ('UINT16', 'e_machine', {
         'names': {
             3: "Intel 80836"
         }
     }), ('UINT32', 'e_version', {
         'format': "0x%x"
     }), ('UINT32', 'e_entry', {
         'format': "0x%x"
     }), ('UINT32', 'e_phoff', {
         'format': "%d (bytes into file)"
     }), ('UINT32', 'e_shoff', {
         'format': "%d (bytes into file)"
     }), ('UINT32', 'e_flags', {
         'format': "0x%x"
     }), ('UINT16', 'e_ehsize', {
         'format': "%d (bytes)"
     }), ('UINT16', 'e_phentsize', {
         'format': "%d (bytes)"
     }), ('UINT16', 'e_phnum'), ('UINT16', 'e_shentsize', {
         'format': "%d (bytes)"
     }), ('UINT16', 'e_shnum'), ('UINT16', 'e_shstrndx'))
Example #9
0
File: elf.py Project: gz/aos10
	def __init__(self, *args, **kwargs):
		AIStruct.__init__(self, AIStruct.SIZE64)
		self.setup(
			('UINT32', 'sh_name'),
			('UINT32', 'sh_type'),
			('UINT64', 'sh_flags'),
			('UINT64', 'sh_addr'),
			('UINT64', 'sh_offset'),
			('UINT64', 'sh_size'),
			('UINT32', 'sh_link'),
			('UINT32', 'sh_info'),
			('UINT64', 'sh_addralign'),
			('UINT64', 'sh_entsize'),
		)
Example #10
0
	def __init__(self, *args, **kwargs):
		AIStruct.__init__(self, AIStruct.SIZE64)
		self.setup(
			('UINT32', 'sh_name'),
			('UINT32', 'sh_type'),
			('UINT64', 'sh_flags'),
			('UINT64', 'sh_addr'),
			('UINT64', 'sh_offset'),
			('UINT64', 'sh_size'),
			('UINT32', 'sh_link'),
			('UINT32', 'sh_info'),
			('UINT64', 'sh_addralign'),
			('UINT64', 'sh_entsize'),
		)
Example #11
0
 def __init__(self):
     AIStruct.__init__(self, AIStruct.SIZE64)
     self.setup(('UINT8', 'ei_magic', {
         'times': 4
     }), ('UINT8', 'ei_class'), ('UINT8', 'ei_data'),
                ('UINT8', 'ei_version'), ('UINT8', 'ei_padding', {
                    'times': 9
                }), ('UINT16', 'e_type'), ('UINT16', 'e_machine'),
                ('UINT32', 'e_version'), ('UINT64', 'e_entry'),
                ('UINT64', 'e_phoff'), ('UINT64', 'e_shoff'),
                ('UINT32', 'e_flags'), ('UINT16', 'e_ehsize'),
                ('UINT16', 'e_phentsize'), ('UINT16', 'e_phnum'),
                ('UINT16', 'e_shentsize'), ('UINT16', 'e_shnum'),
                ('UINT16', 'e_shstrndx'))
Example #12
0
    def __init__(self, *args, **kwargs):
        AIStruct.__init__(self, AIStruct.SIZE32)
        self.elffile = kwargs["elffile"]

        def format_flags(x):
            the_str = [' ', ' ', ' ']
            if (x & self.PF_X):
                the_str[2] = 'E'
            if (x & self.PF_W):
                the_str[1] = 'W'
            if (x & self.PF_R):
                the_str[0] = 'R'
            return "".join(the_str)

        self.setup(
            ('UINT32', 'p_type', {
                "names": {
                    0: "NULL",
                    1: "LOAD",
                    2: "DYNAMIC",
                    3: "INTERP",
                    4: "NOTE",
                    1685382481: "GNU_STACK",
                    1694766464: "PAX_FLAGS",
                }
            }),
            ('UINT32', 'p_offset', {
                "format": "0x%06x"
            }),
            ('UINT32', 'p_vaddr', {
                "format": "0x%08x"
            }),
            ('UINT32', 'p_paddr', {
                "format": "0x%08x"
            }),
            ('UINT32', 'p_filesz', {
                "format": "0x%05x"
            }),
            ('UINT32', 'p_memsz', {
                "format": "0x%05x"
            }),
            ('UINT32', 'p_flags', {
                "format": format_flags
            }),
            ('UINT32', 'p_align', {
                "format": "0x%x"
            }),
        )
Example #13
0
 def __init__(self, *args, **kwargs):
     AIStruct.__init__(self, AIStruct.SIZE64)
     self.setup(
         ('UINT32', 'p_type', {
             "names": {
                 0: "NULL",
                 1: "LOAD",
                 2: "DYNAMIC",
                 3: "INTERP",
                 4: "NOTE"
             }
         }),
         ('UINT32', 'p_flags'),
         ('UINT64', 'p_offset'),
         ('UINT64', 'p_vaddr'),
         ('UINT64', 'p_paddr'),
         ('UINT64', 'p_filesz'),
         ('UINT64', 'p_memsz'),
         ('UINT64', 'p_align'),
     )
Example #14
0
	def __init__(self):
		AIStruct.__init__(self, AIStruct.SIZE64)
		self.setup(
			('UINT8', 'ei_magic', {'times': 4}),
			('UINT8', 'ei_class'),
			('UINT8', 'ei_data'),
			('UINT8', 'ei_version'),
			('UINT8', 'ei_padding', {'times': 9}),
			('UINT16', 'e_type'),
			('UINT16', 'e_machine'),
			('UINT32', 'e_version'),
			('UINT64', 'e_entry'),
			('UINT64', 'e_phoff'),
			('UINT64', 'e_shoff'),
			('UINT32', 'e_flags'),
			('UINT16', 'e_ehsize'),
			('UINT16', 'e_phentsize'),
			('UINT16', 'e_phnum'),
			('UINT16', 'e_shentsize'),
			('UINT16', 'e_shnum'),
			('UINT16', 'e_shstrndx')
		)
Example #15
0
	def __init__(self):
		AIStruct.__init__(self, AIStruct.SIZE32)
		self.setup(
			('UINT8', 'ei_magic', {'times': 4}),
			('UINT8', 'ei_class', {'names' : { 1: "ELF32", 2: "ELF64" }} ),
			('UINT8', 'ei_data', {'names' : { 1 : "2's complement, little endian", 2: "2's complement, big endian" }}),
			('UINT8', 'ei_version', {'names' : { 1 : "1 (current)" }}),
			('UINT8', 'ei_osabi', { 'names' : { 0 : "UNIX - System V", 1 : "HP-UX Operating System", 255 : "Standalone application"}}),
			('UINT8', 'ei_abiversion'),
			('UINT8', 'ei_padding', {'times': 7}),
			('UINT16', 'e_type', { 'names' : { 2 : "EXEC (Executable file)" }} ),
			('UINT16', 'e_machine', { 'names' : { 3 : "Intel 80836" } }),
			('UINT32', 'e_version', {'format': "0x%x" }),
			('UINT32', 'e_entry', {'format': "0x%x" }),
			('UINT32', 'e_phoff', { 'format' : "%d (bytes into file)" }),
			('UINT32', 'e_shoff', { 'format' : "%d (bytes into file)" }),
			('UINT32', 'e_flags', {'format': "0x%x" }),
			('UINT16', 'e_ehsize', { 'format' : "%d (bytes)" } ),
			('UINT16', 'e_phentsize', { 'format' : "%d (bytes)" } ),
			('UINT16', 'e_phnum'),
			('UINT16', 'e_shentsize', { 'format' : "%d (bytes)" } ),
			('UINT16', 'e_shnum'),
			('UINT16', 'e_shstrndx')
		)
Example #16
0
 def __init__(self, *args, **kwargs):
     AIStruct.__init__(self, AIStruct.SIZE32)
     self.setup(('UINT32', 'addr'))
Example #17
0
File: readelf.py Project: gz/aos10
	def __init__(self, *args, **kwargs):
		AIStruct.__init__(self, AIStruct.SIZE32)
		self.setup(
			('UINT32', 'addr')
		)
Example #18
0
 def __init__(self, *args, **kwargs):
     AIStruct.__init__(self, AIStruct.SIZE32)
     self.setup(("UINT32", "addr"))