"""Find function starts referenced from data that the function map missed. usage: python3 -I find_code_pointers.py > hints.txt A data word is a candidate when it points into .text at a 4-byte aligned address that directly follows a function return (jr $ra + delay slot, optionally followed by nop padding) and is not already a function start. """ import re import struct import sys JR_RA = 0x03E00008 def sections(elf): shoff, = struct.unpack_from("= text_addr + 8 and word_at(probe) == 0 and target - probe <= 16: if word_at(probe - 4) == JR_RA: return True probe -= 4 return word_at(target - 8) == JR_RA found = set() for name in (".data", ".rodata", ".sdata"): stype, addr, off, size = secs[name] if stype == 8: continue for pos in range(0, size - 3, 4): value = struct.unpack_from("