-
Notifications
You must be signed in to change notification settings - Fork 14.5k
DWARF CFI Checker prototype #148296
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
base: main
Are you sure you want to change the base?
DWARF CFI Checker prototype #148296
Conversation
…mple CFI analysis
…/Write conditions
- Changing the register and not informing it using cfi directives - Changing the CFA and report it wrong - Load a register from another register stored location
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @amsen20,
I've only read the introduction to your proposal and it looks interesting!
Thanks for your effort. I'll try to have a better look in the coming days.
I know this is only a draft, but regarding the couple of 'nit' bolt changes, those could be added in a separate patch?
@@ -146,7 +146,7 @@ cl::opt<bool> Lite("lite", cl::desc("skip processing of cold functions"), | |||
cl::cat(BoltCategory)); | |||
|
|||
cl::opt<std::string> | |||
OutputFilename("o", | |||
OutputFilename("ooo", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this is renamed by mistake?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a temporary fix for linking the llvm-mc
tool with BOLT, when the linker tried to link them, having the same CL option with the same value caused errors.
This draft is not meant to be merged; the reviewers are added automatically because I changed parts of BOLT's code. Thank you for your time. Let me know if you have any suggestions/ideas on how we should add more semantic information to the MC layer. |
@paschalis-mpeis Thanks |
In this RFC, the design behind this prototype is explained.
This prototype implements the full algorithm explained in the RFC, as opposed to the current DWARFCFIChecker in LLVM, which is only capable of implementing the invalidation part of the algorithm.
The main difference is that this implementation has access to semantic information through BOLT
MCPlusBuilder
, which is an extension ofMCInstrAnalysis
providing the following information:matches
, which can be used to see if an instruction is anadd
/sub
/multiple
/... and what the arguments are, are they const or registers.Using this information, this implementation is capable of applying the abstract execution mentioned in the RFC properly.
Consider the following example:
In this example, two registers (
rdi
andrsi
) are spilled but are loaded in reverse order. The prototype can identify whenrdi
andrsi
are loaded from incorrect memory locations, a capability not shared by the currently landed checker, which only detects modifications tordi
, with its unwinding rule set tosame_value
.To fix the issue, we need to add more semantic information to
MCInst
. There are a couple of options proposed in the RFC. I recommend the first option as my personal choice, which is:Option 1: Extend MCInstrAnalysis with functionalities currently in BOLT’s MCPlus.
The reason to choose this option is that it’s the only truly incremental option that has already been implemented, tested, and explored by BOLT.