Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use DWARF info to get the calling convention of external functions #3

Open
chc4 opened this issue Sep 12, 2021 · 0 comments
Open

Use DWARF info to get the calling convention of external functions #3

chc4 opened this issue Sep 12, 2021 · 0 comments
Labels
good first issue Good for newcomers

Comments

@chc4
Copy link
Owner

chc4 commented Sep 12, 2021

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.

@chc4 chc4 added the good first issue Good for newcomers label Sep 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant