mirror of https://github.com/Nonannet/copapy.git
debug prints cleaned up
This commit is contained in:
parent
6beca7ffdb
commit
ee351fd864
|
|
@ -276,7 +276,7 @@ def compile_to_dag(node_list: Iterable[Node], sdb: stencil_database) -> tuple[bi
|
|||
dw.write_int(start)
|
||||
dw.write_int(lengths)
|
||||
dw.write_value(net.source.value, lengths)
|
||||
# print(f'+ {net.dtype} {net.source.value}')
|
||||
#print(f'+ {net.dtype} {net.source.value}')
|
||||
|
||||
# prep auxiliary_functions
|
||||
aux_function_mem_layout, aux_function_lengths = get_aux_function_mem_layout(aux_function_names, sdb)
|
||||
|
|
@ -333,8 +333,6 @@ def compile_to_dag(node_list: Iterable[Node], sdb: stencil_database) -> tuple[bi
|
|||
dw.write_com(binw.Command.ALLOCATE_CODE)
|
||||
dw.write_int(offset)
|
||||
|
||||
print('o aux: ', aux_function_mem_layout)
|
||||
|
||||
# write aux functions code
|
||||
for name, start, lengths in aux_function_mem_layout:
|
||||
dw.write_com(binw.Command.COPY_CODE)
|
||||
|
|
@ -348,7 +346,7 @@ def compile_to_dag(node_list: Iterable[Node], sdb: stencil_database) -> tuple[bi
|
|||
|
||||
assert reloc.target_symbol_info != 'STT_FUNC', "Not tested yet!"
|
||||
|
||||
if reloc.target_symbol_info in {'STT_OBJECT', 'STT_NOTYPE'}:
|
||||
if reloc.target_symbol_info in {'STT_OBJECT', 'STT_NOTYPE', 'STT_SECTION'}:
|
||||
# Patch constants/variable addresses on heap
|
||||
obj_addr = reloc.target_symbol_offset + section_addr_lookup[reloc.target_section_index]
|
||||
patch = sdb.get_patch(reloc, obj_addr, start, binw.Command.PATCH_OBJECT.value)
|
||||
|
|
@ -359,7 +357,7 @@ def compile_to_dag(node_list: Iterable[Node], sdb: stencil_database) -> tuple[bi
|
|||
patch = sdb.get_patch(reloc, func_addr, offset, binw.Command.PATCH_FUNC.value)
|
||||
|
||||
else:
|
||||
raise ValueError(f"Unsupported: {name} {reloc.target_symbol_info} {reloc.target_symbol_name}")
|
||||
raise ValueError(f"Unsupported: {name=} {reloc.target_symbol_info=} {reloc.target_symbol_name=} {reloc.target_section_index}")
|
||||
|
||||
patch_list.append(patch)
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ def get_last_call_in_function(func: elf_symbol) -> int:
|
|||
# Assume the call instruction is 4 bytes long for relocations with less than 32 bit and 5 bytes otherwise
|
||||
instruction_lengths = 4 if reloc.bits < 32 else 5
|
||||
address_field_length = 4
|
||||
print(f"-> {[r.fields['r_offset'] - func.fields['st_value'] for r in func.relocations]}")
|
||||
#print(f"-> {[r.fields['r_offset'] - func.fields['st_value'] for r in func.relocations]}")
|
||||
return reloc.fields['r_offset'] - func.fields['st_value'] + address_field_length - instruction_lengths
|
||||
|
||||
|
||||
|
|
@ -142,14 +142,12 @@ class stencil_database():
|
|||
start_index = 0
|
||||
end_index = symbol.fields['st_size']
|
||||
|
||||
print('->', symbol_name)
|
||||
for reloc in symbol.relocations:
|
||||
|
||||
# address to fist byte to patch relative to the start of the symbol
|
||||
patch_offset = reloc.fields['r_offset'] - symbol.fields['st_value'] - start_index
|
||||
|
||||
if patch_offset < end_index - start_index: # Exclude the call to the result_* function
|
||||
print(' |', symbol_name, reloc.symbol.info, reloc.symbol.name, reloc.type)
|
||||
yield relocation_entry(reloc.symbol.name,
|
||||
reloc.symbol.info,
|
||||
reloc.symbol.fields['st_value'],
|
||||
|
|
@ -183,9 +181,6 @@ class stencil_database():
|
|||
mask = 0xFFFFFFFF # 32 bit
|
||||
patch_value = symbol_address + pr.fields['r_addend'] - patch_offset
|
||||
|
||||
print(f"** {patch_offset=} {relocation.target_symbol_name=} {pr.fields['r_offset']=} {relocation.function_offset=} {relocation.start=} {function_offset=}")
|
||||
print(f" * {patch_value=} {symbol_address=} {pr.fields['r_addend']=}, {function_offset=}")
|
||||
|
||||
elif pr.type.endswith('_CALL26'):
|
||||
# ((S + A) - P) >> 2
|
||||
assert pr.file.byteorder == 'little', "Big endian not supported for ARM64"
|
||||
|
|
@ -199,13 +194,19 @@ class stencil_database():
|
|||
patch_value = symbol_address + pr.fields['r_addend']
|
||||
scale = 4096
|
||||
symbol_type = symbol_type + 0x01
|
||||
print(f" *> {patch_value=} {symbol_address=} {pr.fields['r_addend']=}, {function_offset=}")
|
||||
#print(f" *> {patch_value=} {symbol_address=} {pr.fields['r_addend']=}, {function_offset=}")
|
||||
|
||||
elif pr.type.endswith('_LDST32_ABS_LO12_NC'):
|
||||
# (S + A) & 0xFFF
|
||||
mask = 0b11111111111100000000
|
||||
patch_value = symbol_address + pr.fields['r_addend']
|
||||
print(f" *> {patch_value=} {symbol_address=} {pr.fields['r_addend']=}, {function_offset=}")
|
||||
mask = 0b11_1111_1111_1100_0000_0000
|
||||
patch_value = (symbol_address + pr.fields['r_addend']) >> 2
|
||||
#print(f" *> {patch_value=} {symbol_address=} {pr.fields['r_addend']=}, {function_offset=}")
|
||||
|
||||
elif pr.type.endswith('_LDST64_ABS_LO12_NC'):
|
||||
# (S + A) & 0xFFF
|
||||
mask = 0b11_1111_1111_1100_0000_0000
|
||||
patch_value = (symbol_address + pr.fields['r_addend']) >> 3
|
||||
#print(f" *> {patch_value=} {symbol_address=} {pr.fields['r_addend']=}, {function_offset=}")
|
||||
|
||||
else:
|
||||
raise NotImplementedError(f"Relocation type {pr.type} not implemented")
|
||||
|
|
|
|||
Loading…
Reference in New Issue