When we call a function, we'd like to have a minimum set of values we have to actually emit to registers, in order to avoid having to place all of them. DWARF has some information for what prototype a function has, which afaik is literally what registers it needs as inputs. Not sure if it also includes clobbered registers (SystemV has a list of registers that you can't assume are valid after a function call).
This should probably be lazily cached in the Function struct the first time we request it, since parsing DWARF is fairly expensive and we don't want to do it for functions if we don't have to, and only once if we do. gimli is the crate we'd want to use, and feeding the goblin::Elf structure we already have if we can.
DWARF isn't what I'd called "well documented". This will probably need some reading of dwarfdump's source code and obscure mailing list threads to figure out how to get the register inputs, and maybe I'm just wrong and it doesn't actually give us registers and we have to try and infer them.
When we call a function, we'd like to have a minimum set of values we have to actually emit to registers, in order to avoid having to place all of them. DWARF has some information for what prototype a function has, which afaik is literally what registers it needs as inputs. Not sure if it also includes clobbered registers (SystemV has a list of registers that you can't assume are valid after a function call).
This should probably be lazily cached in the
Function
struct the first time we request it, since parsing DWARF is fairly expensive and we don't want to do it for functions if we don't have to, and only once if we do.gimli
is the crate we'd want to use, and feeding thegoblin::Elf
structure we already have if we can.DWARF isn't what I'd called "well documented". This will probably need some reading of
dwarfdump
's source code and obscure mailing list threads to figure out how to get the register inputs, and maybe I'm just wrong and it doesn't actually give us registers and we have to try and infer them.