Diagnose BPF instructions exceeding the selected ISA spec
BPF assembler now provides better error messages for instructions not supported by the target ISA version.
The GNU assembler’s BPF backend now offers more informative diagnostics when an instruction is used that exists but is not available in the currently selected ISA specification. Previously, such cases would result in a generic ‘unrecognized instruction’ error. This change allows the assembler to identify and report the required ISA version for the problematic instruction, improving the developer experience.
In Details
The md_assemble function in tc-bpf.c is updated to attempt matching templates that are defined for ISA versions beyond the current isa_spec. If such a template matches the entire input statement, it's stored as a potential error candidate. The assembler continues to scan for templates within the isa_spec. Only if no valid template is found does the stored candidate drive the error message, now indicating the required ISA version. This prevents misleading diagnostics caused by version mismatches.