feat(libbboeos): link clang-compiled exports into the shared blob#445
Merged
Conversation
e7a7046 to
0c3378b
Compare
First concrete step toward Phase 3 of the shared-libbboeos design:
wire `user/libbboeos/libbboeos.a` (clang-compiled libc bodies) into
the same `build/libbboeos` blob as the asm vDSO helpers, gated by
`--gc-sections` + `-ffunction-sections` so unreferenced functions
are dropped.
Concretely:
- Makefile gains `-ffunction-sections -fdata-sections` so ld can
drop unreachable per-function sections.
- libbboeos.ld absorbs `*(.text .text.*)` / `*(.rodata .rodata.*)`
into the existing output sections; new `EXTERN(strcmp)` forces
archive resolution. Pointer table grows by one LONG(strcmp)
entry at offset 0x34.
- make_os.sh links the .a alongside the nasm-built vdso.o:
ld -m elf_i386 -T libbboeos.ld --gc-sections \
-o libbboeos.elf libbboeos.o libbboeos.a
- constants.asm exposes FUNCTION_STRCMP_PTR.
- VDSO_SIGRETURN_OFFSET moves 0x460 → 0xFE0 so the helper region
can grow past 1 KB. Sigreturn now sits near the end of page 0,
past the pointer table at 0x800..0x83C. No ABI break — kernel
signal_dispatch_user references the constant symbolically.
`build/libbboeos` grows from 2100 → 4068 bytes (still single-page;
strcmp body is 0x3D bytes, the rest of the growth is the sigreturn
relocation extending the file out to 0xFE4).
cc.py-side wiring — the extern-call fallback that emits
`call [FUNCTION_<name>_PTR]` when a name is unknown — lands in a
follow-up PR. This commit is purely the build-pipeline plumbing
that makes the symbol reachable in the first place.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0c3378b to
aa676c7
Compare
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.
Summary
First concrete step toward Phase 3 of the shared-libbboeos design (spec). Wire `user/libbboeos/libbboeos.a` (clang-compiled libc bodies) into the same `build/libbboeos` blob as the asm vDSO helpers, gated by `--gc-sections` + `-ffunction-sections` so unreferenced functions are dropped.
Concretely:
```
ld -m elf_i386 -T libbboeos.ld --gc-sections -o libbboeos.elf libbboeos.o libbboeos.a
```
`build/libbboeos` grows from 2100 → 4068 bytes (still single-page; strcmp body is 0x3D bytes, the rest of the growth is the sigreturn relocation extending the file out to 0xFE4).
What's NOT in this PR
The cc.py-side wiring — the extern-call fallback that emits `call [FUNCTION__PTR]` for unknown names — lands in a follow-up. This commit is purely the build-pipeline plumbing that makes `strcmp` reachable in the blob.
Test plan
🤖 Generated with Claude Code