mirror of https://github.com/Nonannet/copapy.git
tricore relocations added
This commit is contained in:
parent
34834faac7
commit
0e3812e0c6
|
|
@ -414,9 +414,13 @@ def compile_to_dag(node_list: Iterable[Node], sdb: stencil_database) -> tuple[bi
|
|||
elif reloc.target_symbol_name.startswith('result_'):
|
||||
# Set return jump address to address of following stencil
|
||||
patch = sdb.get_patch(reloc, offset + len(data), offset, binw.Command.PATCH_FUNC.value)
|
||||
elif reloc.pelfy_reloc.type == 'R_TRICORE_RELAX':
|
||||
pass
|
||||
elif reloc.pelfy_reloc.symbol.index == 0:
|
||||
assert reloc.pelfy_reloc.type == 'R_TRICORE_15REL'
|
||||
else:
|
||||
# Patch constants addresses on heap
|
||||
assert reloc.target_section_index in section_addr_lookup, f"- Function or object in {node.name} missing: {reloc.pelfy_reloc.symbol.name}"
|
||||
assert reloc.target_section_index in section_addr_lookup, f"- Function or object in {node.name} missing: {reloc.pelfy_reloc.symbol.name} ({reloc.pelfy_reloc.type})"
|
||||
obj_addr = reloc.target_symbol_offset + section_addr_lookup[reloc.target_section_index]
|
||||
patch = sdb.get_patch(reloc, obj_addr, offset, binw.Command.PATCH_OBJECT.value)
|
||||
#print('* constants stancils', patch.type, patch.patch_address, binw.Command.PATCH_OBJECT, node.name)
|
||||
|
|
@ -453,7 +457,8 @@ def compile_to_dag(node_list: Iterable[Node], sdb: stencil_database) -> tuple[bi
|
|||
for reloc in sdb.get_relocations(name):
|
||||
|
||||
if not reloc.target_section_index:
|
||||
assert reloc.pelfy_reloc.type == 'R_ARM_V4BX', (reloc.pelfy_reloc.type, name, reloc.pelfy_reloc.symbol.name)
|
||||
if reloc.pelfy_reloc.symbol.name != '__errno': # TODO: Temporary workaround for tricore
|
||||
assert reloc.pelfy_reloc.type in ('R_ARM_V4BX', 'R_TRICORE_RELAX', 'R_TRICORE_15REL', 'R_TRICORE_24REL'), (reloc.pelfy_reloc.type, name, reloc.pelfy_reloc.symbol.name)
|
||||
|
||||
elif reloc.target_symbol_info in {'STT_OBJECT', 'STT_NOTYPE', 'STT_SECTION'}:
|
||||
# Patch constants/variable addresses on heap
|
||||
|
|
|
|||
|
|
@ -371,6 +371,28 @@ class stencil_database():
|
|||
scale = 0x10000
|
||||
#print(f" *> {pr.type} {patch_value=} {symbol_address=}, {function_offset=}, {pr.fields['r_addend']=}")
|
||||
|
||||
elif pr.type == 'R_TRICORE_HIADJ':
|
||||
# S + A + 0x8000 >> 16
|
||||
mask = 0xFFFF
|
||||
patch_value = symbol_address + pr.fields['r_addend'] + 0x8000
|
||||
symbol_type = symbol_type + 0x04 # Absolut value
|
||||
scale = 0x10000
|
||||
#print(f" *> {pr.type} {patch_value=} {symbol_address=}, {function_offset=}")
|
||||
|
||||
elif pr.type == 'R_TRICORE_LO2':
|
||||
# S + A & 0xFFFF
|
||||
mask = 0xFFFF
|
||||
patch_value = symbol_address + pr.fields['r_addend']
|
||||
symbol_type = symbol_type + 0x04 # Absolut value
|
||||
#print(f" *> {pr.type} {patch_value=} {symbol_address=}, {function_offset=}")
|
||||
|
||||
elif pr.type == 'R_TRICORE_24REL':
|
||||
# S + A - P
|
||||
mask = 0xffffff # 24 bit
|
||||
patch_value = symbol_address + pr.fields['r_addend'] - patch_offset
|
||||
assert not patch_value & 0x01, hex(patch_value)
|
||||
scale = 2
|
||||
|
||||
else:
|
||||
raise NotImplementedError(f"Relocation type {pr.type} in {relocation.pelfy_reloc.target_section.name} pointing to {relocation.pelfy_reloc.symbol.name} not implemented")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue