Report indirect calls at the call site in BPF
BPF now reports indirect call errors at the correct location, not at the function end.
This commit improves error reporting for indirect calls in the BPF backend. Previously, errors related to indirect calls were reported at the end of the function, making debugging difficult. The issue was caused by diagnostics being issued too late in the compilation process, after location information was lost. The fix ensures that indirect calls are checked during expansion, providing accurate error messages and locations, and also addresses duplicate error reporting.
In Details
Indirect calls (callx) in the BPF target were previously diagnosed at instruction output time, after the call site's location was lost, leading to confusing diagnostics at the function's closing brace. Additionally, duplicated calls by later RTL passes resulted in multiple error reports. This change moves the check to the expansion of the 'call' and 'call_value' patterns, where the call location is still available. It returns a call to address zero to allow expansion to proceed and ensures the diagnostic is issued only once.
- BPF
- Berkeley Packet Filter, a technology that allows sandboxed programs to execute in the Linux kernel without changing kernel source code.
- indirect call
- A function call where the target address is determined at runtime, typically by loading it into a register.
- RTL
- Register Transfer Language, an intermediate representation used by GCC.
- callx
- An instruction in some extended BPF (eBPF) versions that performs an indirect call.