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

Incorrectly selecting registers in input_regs #344

Open
fortunac opened this issue Sep 29, 2021 · 2 comments
Open

Incorrectly selecting registers in input_regs #344

fortunac opened this issue Sep 29, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@fortunac
Copy link

In input_regs https://github.com/draperlaboratory/cbat_tools/blob/master/wp/lib/bap_wp/src/precondition.ml#L423, AArch64 matches the arm target, but we are selecting 32-bit registers instead of 64-bit registers. We should also probably look up registers by their roles as stated in the comment.

@fortunac fortunac added the bug Something isn't working label Sep 29, 2021
@ivg
Copy link

ivg commented Oct 1, 2021

Do you need the input registers to be in a specific order? If not, i.e., if you're just looking for the set of call clobbered registers, then you can safely use Theory.Target.regs ~roles:[Theory.Role.Register.caller_saved]. If you need the set of registers that are used to pass arguments to a function, you can use function_argument and function_return roles. But the list of returned registers will be ordered by the register names (which coincides with the proper order in ARM, MIPS, PowerPC, but in general, e.g., in x86, doesn't work). You can, however, use the predefined list for x86, as it is now, and rely on the roles interface for the rest of the targets.

@fortunac
Copy link
Author

fortunac commented Oct 4, 2021

Nope, we don't need the registers to be in a specific order, so using Theory.Target.regs is exactly what we need. Thanks for the insight!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants