ldls: the loader, and what it measured
docs/plan/ldls.md milestone L0. ldls/ko.c indexes the sections of an ELF64
relocatable object, places the allocatable ones, resolves undefined symbols
against a caller's table and applies the relocations. Nothing is executed.
It is freestanding -- no libc, no allocation, no I/O -- so the same source
builds as a host tool now and as the SchOS-side host later. That is the
arrangement mkschfs and the kernel already share, and for the same reason:
the failures at this layer are format failures, and one found on the host
costs a second instead of a boot.
$ ldls-inspect 8139too.ko
module 8139too
license GPL
loads to 33988 bytes
relocations: 1980
R_X86_64_64 363, PC32 991, PLT32 428, 32S 169, PC64 29
undefined symbols: 94
stops at: unresolved: __fentry__
The licence is printed before anything is loaded, because it is the one
property that decides whether the object may be on the machine at all and it
is a plain string in .modinfo. Rule 1 is easier to keep when the answer is on
screen.
94 symbols is the measured API surface of 8139too on 6.18.46 -- the list,
exactly, rather than an estimate -- and it is L1's work queue. It is smaller
than it looks: __fentry__, __stack_chk_fail, __ref_stack_chk_guard,
__x86_return_thunk and __fortify_panic are compiler and instrumentation
artefacts that stub out in a line each.
Swept over every module in a stock 6.18.46 tree: 2,440 objects, all of them
laid out and relocated to completion, none with a relocation type the loader
does not handle. That sweep is also what retired the fixed section table --
nvidia-modeset has 7,069 sections and 74,305 relocations, against a median of
50 -- so the caller supplies the table and there is no limit to run into
rather than a generous one that fails later.
Loading is not running, and the doc says so: not one symbol is implemented,
and the distance between "relocates" and "transmits a packet" is the rest of
the plan.
No .ko is in this tree and .gitignore now refuses one outright. make
ldls-check runs 18 checks against ldls/test/refmod.c, which is ours, written
to contain one of each thing the loader has to get right.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQ7Qx8E1q1M1bbCq8QLHS2
This commit is contained in:
parent
5263150d3d
commit
1be5f3a704
9 changed files with 1296 additions and 2 deletions
32
Makefile
32
Makefile
|
|
@ -916,6 +916,38 @@ crashshot:
|
|||
crashqr:
|
||||
$(PYTHON) tools/python/crashqr.py
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# LDLS -- the Linux Driver Layer. docs/plan/ldls.md.
|
||||
#
|
||||
# ldls/ko.c is freestanding and builds on both sides: here as part of a host
|
||||
# tool, and later as part of the SchOS-side host. Same discipline as SchFS,
|
||||
# and for the same reason -- the failures at this layer are format failures,
|
||||
# and one found on the host costs a second instead of a boot.
|
||||
# -----------------------------------------------------------------------
|
||||
LDLS_INSPECT = $(BUILD)/tools/ldls-inspect$(EXE)
|
||||
LDLS_REFMOD = $(BUILD)/ldls/refmod.o
|
||||
|
||||
$(LDLS_INSPECT): ldls/host/inspect.c ldls/ko.c ldls/ko.h
|
||||
@mkdir -p $(BUILD)/tools
|
||||
$(HOSTCC) $(HOSTWARN) -O1 -o $@ ldls/host/inspect.c ldls/ko.c
|
||||
|
||||
# The test object, compiled and never linked. Ours, because docs/plan/ldls.md
|
||||
# rule 1 means no .ko is committed here -- see the header of refmod.c.
|
||||
#
|
||||
# -fno-pic matters: a PIC object routes its data through the GOT, and a GOT is
|
||||
# a thing the loader would have to build. A module is built -fno-pic for the
|
||||
# same reason, so this matches what the real input looks like.
|
||||
$(LDLS_REFMOD): ldls/test/refmod.c
|
||||
@mkdir -p $(BUILD)/ldls
|
||||
$(HOSTCC) -c -O1 -fno-pic -fno-asynchronous-unwind-tables -o $@ $<
|
||||
|
||||
ldls: $(LDLS_INSPECT)
|
||||
|
||||
# Load our own object and check the loader got it right. No network, no QEMU,
|
||||
# no module from anywhere.
|
||||
ldls-check: $(LDLS_INSPECT) $(LDLS_REFMOD)
|
||||
$(PYTHON) tools/python/ldls_check.py $(LDLS_INSPECT) $(LDLS_REFMOD)
|
||||
|
||||
$(MKFS): tools/mkfs.c include/fs.h include/stat.h include/param.h
|
||||
@mkdir -p $(BUILD)/tools
|
||||
$(HOSTCC) $(HOSTWARN) -I. -o $(MKFS) tools/mkfs.c
|
||||
|
|
|
|||
Loading…
Reference in a new issue