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

RISC-V: JALR rd == 0 does not emit a branch #6273

Open
emesare opened this issue Dec 24, 2024 · 1 comment
Open

RISC-V: JALR rd == 0 does not emit a branch #6273

emesare opened this issue Dec 24, 2024 · 1 comment
Assignees
Labels
Arch: RISC-V Issues with the RISC-V architecture plugin Component: Architecture Issue needs changes to an architecture plugin Effort: Low Issue should take < 1 week Impact: Low Issue is a papercut or has a good, supported workaround Type: Bug Issue is a non-crashing bug with repro steps

Comments

@emesare
Copy link
Member

emesare commented Dec 24, 2024

However, I encountered another problem: "functions" that are called with jalr rd, rs1, imm usually end with jr rd. Obviously, the control-flow is the target "function" is unresolved, since rd does not have defined value in the context of the function.

As a matter of fact, this target "function" (ending with jr rd) is most probably just one or multiple basic blocks that are shared between multiple calling functions for space optimization.

Is there any way to tell BN to treat these target "functions" as such ? (i.e. not functions, but basic blocks to reattach to different parent functions). Doing this manually would be the equivalent of "Append function tail" feature in IDA ; that would be great is BN would handle this automatically (BN usually has no problem with shared basic blocks IIRC)

Or maybe my patch is incomplete, and this is already handled.

Anyway, thanks in advance

Forwarded for @jeanmicheldeva (original message)

@emesare emesare added Type: Bug Issue is a non-crashing bug with repro steps Component: Architecture Issue needs changes to an architecture plugin Impact: Low Issue is a papercut or has a good, supported workaround Arch: RISC-V Issues with the RISC-V architecture plugin Effort: Low Issue should take < 1 week labels Dec 24, 2024
@emesare
Copy link
Member Author

emesare commented Dec 24, 2024

While the first idea would be to emit an unresolved branch this would be ill-advised as that same instruction is used for function calls, some changes in analysis would be required to emit an unresolved branch that functions as a call in certain scenarios. I have yet to look into exactly what needs to change but I think it's pretty straightforward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arch: RISC-V Issues with the RISC-V architecture plugin Component: Architecture Issue needs changes to an architecture plugin Effort: Low Issue should take < 1 week Impact: Low Issue is a papercut or has a good, supported workaround Type: Bug Issue is a non-crashing bug with repro steps
Projects
None yet
Development

No branches or pull requests

2 participants