Project 2: A Practical Study of Symbols and Linking
Not a single tool, but a series of small, targeted C programs that demonstrate specific linker behaviors. You will create experiments to prove how symbol resolution, weak symbols, and static linking work.
Quick Reference
| Attribute | Value |
|---|---|
| Primary Language | C |
| Alternative Languages | N/A |
| Difficulty | Level 1: Beginner |
| Time Estimate | Weekend |
| Knowledge Area | C Programming / Linker Theory |
| Tooling | GCC/Clang, and your tool from Project 1. |
| Prerequisites | Project 1, basic command-line skills. |
What You Will Build
Not a single tool, but a series of small, targeted C programs that demonstrate specific linker behaviors. You will create experiments to prove how symbol resolution, weak symbols, and static linking work.
Why It Matters
This project builds core skills that appear repeatedly in real-world systems and tooling.
Core Challenges
- Causing a “multiple definition” error → maps to understanding what a “strong” symbol is
- Using weak symbols to provide default implementations → maps to practical application of weak/strong symbol rules
- Investigating a static library (
.a) file → maps to understanding that a static library is just an archive of.ofiles - Seeing how the linker pulls only needed objects from a library → maps to understanding efficient linking
Key Concepts
- Symbol Resolution Rules: “Computer Systems: A Programmer’s Perspective” Ch. 7
- Weak and Strong Symbols: The
__attribute__((weak))GCC extension. - Static Libraries: The
arcommand (ar t my_library.alists objects).
Real-World Outcome
Deliver a working demo with observable output that proves the feature is correct.
Implementation Guide
- Reproduce the simplest happy-path scenario.
- Build the smallest working version of the core feature.
- Add input validation and error handling.
- Add instrumentation/logging to confirm behavior.
- Refactor into clean modules with tests.
Milestones
- Milestone 1: Minimal working program that runs end-to-end.
- Milestone 2: Correct outputs for typical inputs.
- Milestone 3: Robust handling of edge cases.
- Milestone 4: Clean structure and documented usage.
Validation Checklist
- Output matches the real-world outcome example
- Handles invalid inputs safely
- Provides clear errors and exit codes
- Repeatable results across runs
References
- Main guide:
LEARN_C_LINKING_DEEP_DIVE.md - “Linkers and Loaders” by John R. Levine