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

WIP Add support for checking return value in post-condition call #485

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion tools/rewriter/GenCallAsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,12 +838,19 @@ static void emit_set_return_pkru(AsmWriter &aw, uint32_t caller_pkey, Arch arch)
static void emit_post_condition_fn_call(AsmWriter &aw, Arch arch, std::string_view target_post_condition_name) {
llvm::errs() << "emitting post condition call to " << target_post_condition_name << "\n";
if (arch == Arch::X86) {
add_comment_line(aw, "Discard sixth param register on stack");
// Pop sixth register off the stack into an arbitrary register. This value will get overwritten
add_asm_line(aw, "popq %r9");
add_comment_line(aw, "Restore param regs for post condition call");
for (auto it = x86_int_param_reg_order.rbegin(); it != x86_int_param_reg_order.rend(); ++it) {
// Pop registers five through one. Note the registers popped differ from the registers pushed by one
for (auto it = x86_int_param_reg_order.rbegin(); it != x86_int_param_reg_order.rend() - 1; ++it) {
auto &r = *it;
add_asm_line(aw, "popq %"s + r);
}
}
// Put the return value in the first register
add_comment_line(aw, "Put return value in the first register");
add_asm_line(aw, "movq %rax, %rdi");
add_comment_line(aw, "Align stack");
add_asm_line(aw, "subq $8, %rsp");
add_comment_line(aw, "Call post condition function");
Expand Down
Loading