0.3.5 — the forwarder for an optional interface must not demand it - #8
Merged
Merged
Conversation
`openkal.random` is optional, and clause 6.1 expresses an implementation
that does not provide it as the absence of a link-time definition. This
dispatcher is linked into every program, so a strong reference to
`kal_random_fill` turned that absence into a failure for programs that
never ask for a random byte:
ld.lld: error: undefined symbol: kal_random_fill
>>> referenced by okm_syscall.c:409
>>> obj/…/okm_syscall.o:(__okm_syscall)
measured on a bare-metal program over openkal-opensbi, which provides
eight interfaces and not this one. A whole class of programs — every
freestanding one — could not link because one optional interface was
referenced unconditionally.
⚠️ THE WEAK REFERENCE IS NOT THE RUN-TIME REFUSAL CLAUSE 6.1 FORBIDS.
That clause governs an implementation of openkal: one shall not offer an
interface whose operations report a lack of support while running. This
is on the other side of the layer — the file implements Linux's system
call ABI, where `ENOSYS` is that ABI's answer for a call the kernel does
not have, and musl's own `getrandom` is written against that answer.
Both the idiom and the convention were already here and neither was
reached for: `okm_phdr.c` declares `__ehdr_start` weak, and this file's
opening comment says calls that can be told they do not exist return
`-ENOSYS`.
Proved by removing it again rather than by reasoning:
weak examples/same-source --target riscv64-none-elf → text 2490664
strong the same build → the error above
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.
A strong reference to
kal_random_fillin the syscall dispatcher made an optional interface mandatory: every freestanding program failed to link, whether or not it wanted a random byte.The weak reference is on the other side of the layer from clause 6.1 — this file implements Linux's syscall ABI, where
ENOSYSis the defined answer for a call the kernel does not have.Proved by removing it again: strong → the link error, weak → text 2490664.