mirror of https://github.com/Nonannet/copapy.git
small refactors
This commit is contained in:
parent
31791cb6a6
commit
8a6bb7b248
|
|
@ -460,21 +460,19 @@ class Target():
|
||||||
if var_type == 'float':
|
if var_type == 'float':
|
||||||
if lengths == 4:
|
if lengths == 4:
|
||||||
value = struct.unpack(en + 'f', data)[0]
|
value = struct.unpack(en + 'f', data)[0]
|
||||||
assert isinstance(value, float)
|
|
||||||
return value
|
|
||||||
elif lengths == 8:
|
elif lengths == 8:
|
||||||
value = struct.unpack(en + 'd', data)[0]
|
value = struct.unpack(en + 'd', data)[0]
|
||||||
assert isinstance(value, float)
|
|
||||||
return value
|
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"Unsupported float length: {lengths}")
|
raise ValueError(f"Unsupported float length: {lengths} bytes")
|
||||||
|
assert isinstance(value, float)
|
||||||
|
return value
|
||||||
elif var_type == 'int':
|
elif var_type == 'int':
|
||||||
if lengths in (1, 2, 4, 8):
|
if lengths in (1, 2, 4, 8):
|
||||||
value = int.from_bytes(data, byteorder=self.sdb.byteorder, signed=True)
|
value = int.from_bytes(data, byteorder=self.sdb.byteorder, signed=True)
|
||||||
assert isinstance(value, int)
|
assert isinstance(value, int)
|
||||||
return value
|
return value
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"Unsupported int length: {lengths}")
|
raise ValueError(f"Unsupported int length: {lengths} bytes")
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"Unsupported variable type: {var_type}")
|
raise ValueError(f"Unsupported variable type: {var_type}")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,11 @@ def translate_relocation(relocation_addr: int, reloc_type: str, bits: int, r_add
|
||||||
patch_offset = relocation_addr
|
patch_offset = relocation_addr
|
||||||
return patch_entry(RelocationType.RELOC_RELATIVE_32, patch_offset, r_addend)
|
return patch_entry(RelocationType.RELOC_RELATIVE_32, patch_offset, r_addend)
|
||||||
else:
|
else:
|
||||||
raise Exception(f"Unknown: {reloc_type}")
|
print('relocation_addr: ', relocation_addr)
|
||||||
|
print('reloc_type: ', reloc_type)
|
||||||
|
print('bits: ', bits)
|
||||||
|
print('r_addend: ', r_addend)
|
||||||
|
raise Exception(f"Unknown relocation type: {reloc_type}")
|
||||||
|
|
||||||
|
|
||||||
def get_ret_function_def(symbol: pelfy.elf_symbol) -> str:
|
def get_ret_function_def(symbol: pelfy.elf_symbol) -> str:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue