Skip to content

Also group CFI jump tables according to sections #140943

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

Open
PiJoules opened this issue May 21, 2025 · 2 comments
Open

Also group CFI jump tables according to sections #140943

PiJoules opened this issue May 21, 2025 · 2 comments
Labels
llvm Umbrella label for LLVM issues

Comments

@PiJoules
Copy link
Contributor

We have an embedded project that groups different functions into different custom sections. If I have function A in a custom section .ram_code that references another function B in the same section (through inline asm in my case), then the reference to B instead refers to the jumptable entry for B. This jump table is placed in .text.B. The linker script used for this project places .text very far away from .ram_code leading to relocation R_RISCV_JAL out of range.

I think the fix emitting jump tables per section in addition to per function type such that jump tables for functions in unique sections are in the same sections as those functions.

@PiJoules PiJoules added compiler-rt:cfi Control Flow Integrity llvm Umbrella label for LLVM issues and removed new issue compiler-rt:cfi Control Flow Integrity labels May 21, 2025
@PiJoules
Copy link
Contributor Author

cc @ilovepi @pcc

@pcc
Copy link
Contributor

pcc commented May 21, 2025

That would make indirect calls more expensive because now every call would need to check for the function in both jump tables.

How do long range calls normally work in RISC-V? While I was looking at lld for an unrelated reason it didn't seem like there was anything like range extension thunks, maybe that needs to be implemented?

Also once #138366 lands (and a RISC-V implementation is added) we should usually be able to avoid these long range branches anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm Umbrella label for LLVM issues
Projects
None yet
Development

No branches or pull requests

3 participants