Skip to content

Commit

Permalink
WIP rewriter changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ayrtonm committed Feb 23, 2024
1 parent 2b7b5f2 commit 9c14ecc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
7 changes: 4 additions & 3 deletions rewriter/GenCallAsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,6 @@ std::string emit_asm_wrapper(const CAbiSignature &sig,
WrapperKind kind, int caller_pkey, int target_pkey,
bool arm_mte, bool as_macro) {

if (arm_mte) {
return ""s;
}
// Small sanity check
assert(caller_pkey != target_pkey);
std::string terminator = {};
Expand Down Expand Up @@ -390,6 +387,9 @@ std::string emit_asm_wrapper(const CAbiSignature &sig,
add_asm_line(aw, ".type "s + wrapper_name + ", @function");
add_asm_line(aw, wrapper_name + ":");

if (arm_mte) {
add_asm_line(aw, "b "s + target_name.value());
} else {
// Save the old frame pointer and set the frame pointer for the call gate
add_asm_line(aw, "pushq %rbp");
add_asm_line(aw, "movq %rsp, %rbp");
Expand Down Expand Up @@ -621,6 +621,7 @@ std::string emit_asm_wrapper(const CAbiSignature &sig,
// Return to the caller
add_comment_line(aw, "Return to the caller");
add_asm_line(aw, "ret");
}
// Set the symbol size
add_asm_line(aw, ".size "s + wrapper_name + ", .-" + wrapper_name);

Expand Down
16 changes: 6 additions & 10 deletions rewriter/SourceRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1182,11 +1182,9 @@ int main(int argc, const char **argv) {
std::string asm_wrapper =
emit_asm_wrapper(c_abi_sig, wrapper_name, fn_name,
WrapperKind::Direct, caller_pkey, target_pkey, true);
if (Target != Arch::Aarch64) {
wrapper_out << "asm(\n";
wrapper_out << asm_wrapper;
wrapper_out << ");\n";
}
wrapper_out << "asm(\n";
wrapper_out << asm_wrapper;
wrapper_out << ");\n";

write_to_ld_file(ld_args_out, caller_pkey, "--wrap="s + fn_name + '\n');
}
Expand All @@ -1207,11 +1205,9 @@ int main(int argc, const char **argv) {
std::string asm_wrapper =
emit_asm_wrapper(c_abi_sig, wrapper_name, fn_name, WrapperKind::Direct,
0, compartment_pkey, true);
if (Target != Arch::Aarch64) {
wrapper_out << "asm(\n";
wrapper_out << asm_wrapper;
wrapper_out << ");\n";
}
wrapper_out << "asm(\n";
wrapper_out << asm_wrapper;
wrapper_out << ");\n";

write_to_ld_file(ld_args_out, compartment_pkey,
"--wrap="s + fn_name + '\n');
Expand Down

0 comments on commit 9c14ecc

Please sign in to comment.