Repository navigation
Resolve k4-x86_64 to the k3 toolchain: pre-2.31 binutils - #5
Merged
Merged
Conversation
binutils 2.31 began emitting R_X86_64_PLT32 where it previously emitted R_X86_64_PC32. Linux only learned that relocation in 4.16 (b21ebf2fb4cd, "x86: Treat R_X86_64_PLT32 as R_X86_64_PC32"). An x86_64 kernel older than 4.16, built with binutils >= 2.31, compiles, links, packages, and has the correct ELF class, byte order, machine and size -- and does not boot. It decompresses, prints "Booting the kernel.", and goes silent before console init. linux_builder shipped exactly that in nixdev_0.1.0's 4.10/x86_64. Every gate passed it: the build, shape-check, the patch-series check, and kernelsmith's own boot.nix -- whose k4 cell boots 5.10.229, so the 4.x half of the band had never been booted by anything. It surfaced three repos downstream, in penguin's integration tests. This was known here before. rehosting/embedded-toolchains, the Docker image kernelsmith replaces, hand-built an "x86_64-legacy" toolchain pinning binutils 2.30 -- the last release before 2.31 -- and _in_container_build.sh selected it for (x86_64, 4.10) alone. The reason was never written down, so it did not survive the port to a version-keyed resolver. k3 is already that toolchain: gcc 6.5.0 (the same version embedded-toolchains picked) and binutils 2.27, on the same x86_64-linux-musl triple. So this needs no new cell, only a resolver entry with the reason attached. Verified: 4.10/x86_64 now boots to the root-fs stage where it was previously silent, with gcc held constant at 6.5.0 across both -- the linker is the only variable. 5.10.229 (boot.nix's k4-x86_64 cell) still boots under the override, so the other half of the band does not regress. The override applies band-wide, which is wrong in principle: 5.x does not need pre-2.31 binutils. matrix.nix now documents that, and the related gap that eras declare binutilsVer but only the musl-cross-make path honours it -- Bootlin cells ship whatever Buildroot bundled, unrecorded. Both want a finer band keyed nearer the 4.16 boundary.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
binutils2.31 began emittingR_X86_64_PLT32where it previously emittedR_X86_64_PC32. Linux only learned that relocation in 4.16 (b21ebf2fb4cd, "x86: Treat R_X86_64_PLT32 as R_X86_64_PC32").So an x86_64 kernel older than 4.16, built with binutils ≥ 2.31, compiles, links, packages, and has the correct ELF class, byte order, machine and size — and does not boot. It decompresses, prints
Booting the kernel., and goes silent before console init.Bootlin's k4 x86_64 cell is 2021.11-5: gcc 10.3, binutils 2.36.1.
How it escaped
linux_buildershipped exactly this innixdev_0.1.0's 4.10/x86_64. Every gate passed it:shape-checkpassed — a bzImage's shape says nothing about whether it runsboot.nixpassed — but its k4 cell boots 5.10.229, and the k4 band spans 4.x and 5.x, so the 4.x half had never been booted by anythingIt surfaced three repos downstream, in penguin's integration tests (rehosting/penguin#932).
It was known here before
rehosting/embedded-toolchains— the Docker image kernelsmith replaces — hand-built anx86_64-legacytoolchain for precisely this, pinning binutils 2.30, the last release before 2.31:FROM base AS x86_64_legacy_builder wget .../binutils-2.30.tar.xz && ../configure --target=x86_64-linux-musl ... wget .../gcc-6.5.0.tar.xz && ../configure --target=x86_64-linux-musl ...and
_in_container_build.shselected it for(x86_64, 4.10)alone. The reason was never written down, so it did not survive the port to a version-keyed resolver.The fix
k3 is already that toolchain — gcc 6.5.0 (the same version embedded-toolchains chose) and binutils 2.27, on the same
x86_64-linux-musltriple. No new cell; one resolver entry, with the reason attached:Verification
linux_builder4.10/x86_64ok 4.10/x86_64— reaches root-fs stageboot.nix tests.k4-x86_64(5.10.229)gcc was held constant at 6.5.0 across both 4.10 runs (a native gcc sweep at 6.5/7.5/9.5/10.5 all produced dead kernels at binutils 2.41), so the linker is the only variable that moved. 5.10's banner records the result directly:
Known limitation
This pins the whole k4 band for x86_64, and k4 spans 4.x and 5.x — 5.10 does not need pre-2.31 binutils and would rather have the newer toolchain. The resolver is keyed
(era, arch)and cannot express "4.x needs this, 5.x needs that".boot.nix's k4-x86_64 cell is what proves this does not regress the other half; the correct answer is a finer band.matrix.nixdocuments that and a related gap it exposed: eras declarebinutilsVer, but only the musl-cross-make path honours it. Bootlin cells ship whatever Buildroot bundled, unrecorded — k4 declares 2.33.1 while its Bootlin x86_64 cell ships 2.36.1. For most cells that field is documentation, not a constraint. The failure mode is asymmetric: too-new gcc errors loudly at compile time, too-new binutils is silent until boot.