Open riidefi opened 3 years ago
Sounds easy enough :) Will take a look at this with the help of wii-symbols/match-symbols.py, which can match relocatable/object code to binary blobs: https://github.com/terorie/wii-symbols/blob/master/scripts/match_symbols.py (the person who wrote this must have a massive brain and amazing code style :P)
Logic will be as follows:
Inputs: obj_syms: Set<Symbol>, bin_syms: Set<Symbol>
Output: bool
Algorithm:
known_syms = intersect(obj_syms, bin_syms)
for (obj_sym, bin_sym) in known_syms:
if not obj_sym.match(bin_sym):
return false
return true
We decided to use an explicit approach instead. Rather than trying to derive which symbols get stripped through symbols.txt
, we'll embed information into the object file.
We do this like with the BINARY_BLOB
macro by writing debug information into a custom section that gets stripped from the DOL/REL.
Like this:
DEAD_STRIPPED(my_function);
void my_function() { ... }
Currently, we need to link an entire .dol/.rel executable to verify a function matches. Introducing a .o validator will enable faster iteration for both humans and computers ;)