-
Notifications
You must be signed in to change notification settings - Fork 62
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
Add initial riscv64 support #941
base: main
Are you sure you want to change the base?
Conversation
// Copyright 2015 Ted Mielczarek. See the COPYRIGHT | ||
// file at the top-level directory of this distribution. |
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.
Not a big deal but I realize we have this header in most files but there's never been a top-level COPYRIGHT file. @luser what do you suggest we do for new files?
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.
There's a LICENSE file in the root of the repository, I think that should cover it? I would recommend dropping the license comments from individual files. I probably picked that habit up from Breakpad.
// in a range covered by one of our modules). If we find such an instruction, | ||
// we assume it's an pc value that was pushed by the CALL instruction that created | ||
// the current frame. The next frame is then assumed to end just before that | ||
// pc value. |
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.
I guess this was copied from the other architectures, but RISC-V doesn't have a CALL instruction. It uses a AUIPC followed by a JALR instruction to call a function, you should amend the text above to reflect this (assume the logic below applies to RISC-V).
// Arm leaf functions may not actually touch the stack (thanks | ||
// to the link register allowing you to "push" the return address | ||
// to a register), so we need to permit the stack pointer to not | ||
// change for the first frame of the unwind. After that we need | ||
// more strict validation to avoid infinite loops. |
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.
Likewise this looks like a copy-paste error, does the logic here hold true for RISC-V too? I'm not sufficiently familiar with the ABI to be able to tell.
// A caller's ip is the return address, which is the instruction | ||
// *after* the CALL that caused us to arrive at the callee. Set | ||
// the value to 4 less than that, so it points to the CALL instruction | ||
// (arm64 instructions are all 4 bytes wide). This is important because | ||
// we use this value to lookup the CFI we need to unwind the next frame. | ||
let ip = frame.context.get_instruction_pointer(); | ||
frame.instruction = ip - 4; |
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.
This is certainly wrong for RISC-V as the “C” extension for compressed instructions allows for 2-bytes wide instructions and all jumps have an address that is a multiple of 2 bytes.
The defines for riscv64 are from Google's breakpad. This is tested on Ubuntu 23.10/riscv64 using generated minidump by Google's breakpad.