fix(amd64): the image runs wherever the firmware loads it -- -fpie, every symbol hidden; qemu-stick-high in acceptance
The SER5 stopped at the loader's "Loading kernel from ESP...": built -fno-pic -fno-pie with
ImageBase 0, the image carried ~9,000 32-bit absolute addresses, and the firmware loaded it above
2 GiB, where the sign-extended ones (R_X86_64_32S) point into unmapped memory -- a page fault in
debug_checkpoint() before [CKPT 001]. Reproduced on QEMU's pc machine at 3 GiB (#PF, CR2 =
FFFFFFFFBD316542, the right address sign-extended); q35 always loads it below 2 GiB, so no QEMU
boot ever showed it.
amd64 now builds -fpie with kernel/include/starkernel/pie_hidden.h force-included (#pragma GCC
visibility push(hidden)), so globals are RIP-relative and none is reached through a GOT -- the
2026-08-06 bug that put -fno-pic there. The link refuses any object carrying a 32-bit absolute or
GOT relocation (4,531 on the old objects, none now). test_runner.c's visibility("default") on
global_test_stats is kept for the -fPIC ISAs only. make -f kernel/Makefile ARCH=amd64
qemu-stick-high boots the PC stick on pc with 3 GiB and is part of acceptance (.claude/CLAUDE.md).
Captain Bob, 2026-10-29; FABRIC-3.md XLIV.
Verified: qemu-stick-high with Zuse's pair, ok> and 7 ok, RIP sampled inside .text at base
0xBD297000 (logs/20261029-070253); acceptance amd64 -070508, aarch64 -070715, riscv64 -071138,
PARITY:V4_POST tests=538 pass=538 fail=0, POST: PASSED, dict_hash=0xfec8c47cfc6f437f on all;
make -C v4 test-32, 39 suites, 0 failures. Not yet booted on the SER5.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
0a31e558be
commit
d6ea592c08
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* pie_hidden.h -- every symbol in the amd64 image is the image's own.
|
||||
*
|
||||
* Force-included (-include) ahead of every amd64 kernel and loader source by
|
||||
* kernel/Makefile's ARCH_CFLAGS, together with -fpie. The image is one PE file,
|
||||
* linked by ld -m i386pep, loaded by the firmware wherever it chooses: a PC's
|
||||
* firmware puts it above 2 GiB (the Beelink SER5 did), where the 32-bit absolute
|
||||
* addresses of -fno-pic code are sign-extended into unmapped memory and the
|
||||
* loader page-faults before its first checkpoint (FABRIC-3.md XLIV). -fpie
|
||||
* addresses every global relative to RIP, which is right at any load address.
|
||||
*
|
||||
* -fpie alone is not enough: GCC treats an extern declaration of default
|
||||
* visibility as possibly defined in another module and reaches it through the
|
||||
* GOT. This image has no dynamic linker and ld -m i386pep builds no GOT, so
|
||||
* such a read returns zero -- the 2026-08-06 bug (FABRIC-0.md). -fvisibility=
|
||||
* hidden covers definitions only; this pragma covers declarations too, so GCC
|
||||
* never uses the GOT. (EDK2's GCC X64 ProcessorBind.h does the same.)
|
||||
*
|
||||
* The Makefile checks the result: the link fails if any object still carries
|
||||
* a GOT or 32-bit absolute relocation.
|
||||
*/
|
||||
#ifndef STARKERNEL_PIE_HIDDEN_H
|
||||
#define STARKERNEL_PIE_HIDDEN_H
|
||||
|
||||
#pragma GCC visibility push(hidden)
|
||||
|
||||
#endif /* STARKERNEL_PIE_HIDDEN_H */
|
||||
Reference in New Issue
Block a user