BPF gas: Run pseudo-C spacing test
BPF gas pseudo-C spacing tests are now executed, fixing byte order issues and ensuring correct assembly.
This patch enables the execution of BPF gas pseudo-C spacing tests by adding them to the bpf.exp test suite. Previously, these tests were never run, leading to undiscovered issues. Enabling them revealed a byte order problem where the test declared big-endian assembly (-EB) but expected little-endian output. The patch corrects this by setting the assembler to little-endian (-EL), aligning the test with its expected encodings and filename. This ensures proper assembly of instructions with flexible spacing, such as goto+1 and conditional jumps.
- reviewer
Approves the patch, acknowledging the fix for running BPF pseudo-C spacing tests and the correction of byte order issues.
“OK. Thanks for the patch.”
- proposer
Submits a patch to enable and correct the BPF pseudo-C spacing tests in the gas test suite.
“Enabling it exposes a second problem: the .d declares -EB while its expected encodings are little endian, so the test fails on byte order alone.”
Technical Tradeoffs
- Enables previously untested code, improving overall test coverage.
- Fixes a byte-order mismatch, ensuring accurate assembly for little-endian targets.
- Reflects correct assembly behavior for instructions with flexible spacing.
In Details
This patch addresses an issue where BPF gas pseudo-C spacing tests (spacing-pseudoc.s and spacing-pseudoc.d) were defined but never executed because they were missing from the bpf.exp test runner. The patch adds run_dump_test spacing-pseudoc to bpf.exp. Upon enabling, a byte-order mismatch was found: the test's .d file specified big-endian (-EB), but the expected output was little-endian. The patch corrects this by changing the assembly directive to little-endian (-EL), ensuring the test accurately reflects the intended behavior for instructions with flexible spacing.
- BPF
- Berkeley Packet Filter, a technology that allows sandboxed programs to safely execute code in the Linux kernel, often used for networking and tracing.
- gas
- The GNU Assembler, part of the GNU Binutils package, responsible for converting assembly language code into machine code.
- pseudo-C
- A dialect or style of assembly language that mimics C language syntax for clarity or specific testing purposes.
- spacing test
- A test case designed to verify how an assembler handles whitespace and token boundaries between instruction mnemonics, operands, and labels.
- byte order
- The order in which bytes are arranged in computer memory for multi-byte data types. Common orders are little-endian (least significant byte first) and big-endian (most significant byte first).