Repository navigation
test(ghidra): require pending multi-HI16 coverage in the real MIPS relocatable lane - #1974
Conversation
…locatable lane Post-merge review on morluto#1950: the relocation oracle exposes coverage.multiple_hi16, but the real-Ghidra lane never required it, and Clang's C output never produces a LO16 that resolves several pending HI16s. Ghidra's loader could therefore mishandle that stream while the lane still passed, although most GCC-built kernel modules checked contain it. The relocatable fixture adds an assembly block with two lui %hi(rea_mips_rel_carry); LLVM's relocation sort then leaves one HI16 pending until a later LO16 that resolves it together with another HI16, including the carry. The lane now requires multiple_hi16: false on the previous fixture, true for all three variants (LE, BE, soft-float module) on real Ghidra 12.1.4.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 56fdfe6d60
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| * symbol make LLVM's relocation sort leave one HI16 pending until a later | ||
| * LO16 that also resolves another HI16, including the carry. |
There was a problem hiding this comment.
Stop depending on LLVM's relocation sort order
With REA_MIPS_CLANG=clang on Clang 17.0.0 (a compiler with MIPS target support that passes compileMipsFixture), GNU readelf reports this block as HI@0, LO@8, HI@4, LO@16 for all three variants. Thus no LO sees more than one pending HI, coverage.multiple_hi16 remains false, and the newly required assertion aborts the advertised real-Ghidra lane; Clang 20/21 sorting differently does not make this fixture portable. Encode the intended relocation stream deterministically instead of relying on LLVM's version-dependent sorting.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed independently: GNU as 2.45 orders the old block as HI@4 LO@8 HI@0 LO@10, so each LO16 resolves one HI16 and multiple_hi16 stays false. Only Clang 21's sort happened to leave a HI16 pending.
Fixed in 6c58f89: the block now uses a dedicated symbol (rea_mips_rel_highs_target) with two %hi and exactly one %lo. Any assembler that places each HI16 before a matching LO16 must emit both HI16s ahead of that single LO16. Clang 21 gives HI@0 HI@4 LO@8; GNU as 2.45, on the full fixture, gives HI@4 HI@0 LO@8. The real-Ghidra lane passes for LE, BE and the soft-float module variant with multiple_hi16 true. I could not test Clang 17 directly, but the single %lo leaves its sort no other valid placement.
|
Note on the red CI here: the three failing tests are outside this change and fail on |
…ion sorting Review on morluto#1974: the block used two %lo of rea_mips_rel_carry, a symbol with other %lo uses, so the relocation stream depended on the assembler's HI16/LO16 sort. Clang 21 happened to leave a HI16 pending; Clang 17 (per review) and GNU as 2.45 (checked here: HI@4 LO@8 HI@0 LO@10) pair each HI16 with its own LO16, so multiple_hi16 stays false and the lane fails. Use a dedicated symbol with two %hi and exactly one %lo. Any assembler that orders each HI16 before a matching LO16 must then emit both HI16s ahead of that single LO16: Clang 21 gives HI@0 HI@4 LO@8, GNU as 2.45 gives HI@4 HI@0 LO@8. The real-Ghidra lane passes for LE, BE and the soft-float module variant with multiple_hi16 true.
|
TL;DR: The new check works, on head 6c58f89 against base 290d301 (#1950). On Linux with real Ghidra 12.1.4, the MIPS relocatable lane passes on this PR, and the lane fails with the old fixture. The three red CI tests also fail on main, as AurelioB said.
There are three variants. One is little-endian, one is big-endian, and one is a soft-float module. The old-fixture run stopped at the first variant, so it shows the failure for little-endian only. Clang here is 22.1.8; the PR text tested Clang 21. The PR changes no unit tests, so I ran the existing 4 files only. CI: do the failures match main?Yes. The same three tests fail on the PR and on main. CI runs compared
The CI workflows do not run this MIPS lane, so green CI says nothing about the new check. When I looked, one job on the 22:16 PR run was still pending (macOS x64 package baseline). Not run
Thanks, AurelioB, for the quick fix after the Codex review, and for the clear notes on the CI failures. Commandsexport PATH=~/.local/opt/node24/bin:$PATH
export GHIDRA_INSTALL_DIR=~/.local/opt/ghidra_12.1.4_PUBLIC
export JAVA_HOME=~/.local/opt/jdk-21.0.12.1+1
# head 6c58f8903, base 290d301ec (merge-base with main), both from git archive
npm ci && npm run build && npm run test:prepare # head; base reuses head's node_modules
npm run verify:ghidra:mips-relocatable --prefix HEAD_DIR # exit 0, 62 s
npm run verify:ghidra:mips-relocatable --prefix BASE_DIR # exit 0, 70 s
# throwaway copy of head with the base fixture mips-relocatable.c swapped in
npm run verify:ghidra:mips-relocatable --prefix NEG_DIR # exit 1, 9 s
clang --target=mipsel-linux-gnu -march=mips32r2 -mabi=32 -mno-abicalls -fno-pic -G0 -fno-builtin -O1 -c mips-relocatable.c
readelf -r mips-relocatable.o
node_modules/.bin/vitest run tests/conformance/ghidra src/ghidra/GhidraMipsProfile.test.ts # 73 passed, both trees
gh pr checks 1974 -R morluto/rea
gh run list -R morluto/rea --branch main --limit 5
gh run view RUN_ID --log-failedThe box was shared with other test agents. The one-minute load average read 4.7 to 8.3 during the lane runs, so the timings are not from an idle machine. Test setup
🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
Thanks @CassieFox23. Now that #1972 has fixed the three shared failures on |
Follow-up to #1950, addressing the post-merge Codex review comment on
scripts/verify-real-ghidra-mips-relocatable.mjs.Problem
The relocation oracle exposes
coverage.multiple_hi16(one LO16 resolving several pending HI16s), but the real-Ghidra lane never required it, and Clang's C output never produces that stream. Ghidra's loader could mishandle it whileverify:ghidra:mips-relocatablestill passed, although it is common in real objects: 24 of the 30 GCC-built kernel modules I checked contain it.Change
tests/conformance/c/mips-relocatable.c: an assembly block with two%hiand exactly one%loof a dedicated symbol, so any assembler that orders each HI16 before a matching LO16 emits both HI16s ahead of that single LO16 (Clang 21:HI@0 HI@4 LO@8; GNU as 2.45:HI@4 HI@0 LO@8). The first revision relied on Clang 21's sort; see the review thread.scripts/verify-real-ghidra-mips-relocatable.mjs: requirescoverage.multiple_hi16.docs/ghidra-mips.md: lists the requirement.Verification
Host: Linux x64, Ghidra 12.1.4, OpenJDK 21.0.12, Clang 21, GNU readelf.
node scripts/verify-real-ghidra-mips-relocatable.mjs: LE, BE and the soft-float-mlong-callsmodule variant allpassed, each withmultiple_hi16,shared_hi16andlo16_carrytrue; process lineage verified. On the previous fixture the same lane reportedmultiple_hi16: false, so the new requirement would have failed.vitestontests/conformance/ghidraandsrc/ghidra/GhidraMipsProfile.test.ts: 73 passed.oxfmt --check,oxlintandjscpdpass.Branched from the #1950 merge commit (
290d301ec) because syncing my fork past #1963's workflow change needs a token scope I don't have; none of the three files changed onmainsince, and the branch merges cleanly.