Files
imple b008b37d49 Add phase-by-phase tutorial notes
Add a Tutorial tree that mirrors the roadmap from Phase 0 through Linux bring-up.
Each phase and subphase gets a short learning note with consistent sections for
context, goals, new concepts, mental model, learning tasks, pitfalls, tooling,
testing, and references.

The tutorial material is intentionally explanatory rather than implementation
code. It gives a systems-oriented learner enough FPGA, SystemVerilog, RISC-V,
firmware, and Linux bring-up context to approach each roadmap phase without
turning the notes into copy-paste RTL.
2026-04-28 12:11:23 +02:00

1.6 KiB

Phase 8.1 - Linker Script + Startup Code

Context

C programs assume a runtime environment. Bare metal provides none unless you create it: memory layout, stack pointer, zeroed globals, and entry point.

Goals

  • Place code and read-only data in instruction memory.
  • Place writable data, BSS, and stack in data memory.
  • Understand what startup code must do before calling main.

New Concepts

  • Section: named region of an object file, such as .text or .bss.
  • Load address: where bytes are stored in the image.
  • Virtual/runtime address: where code expects them at execution.
  • Stack pointer: register pointing to top of current stack frame.

How To Think About It

The linker script is the contract between memory hardware and compiled software. If it lies, the CPU may be correct and the program will still fail.

Learning Tasks

  • Draw the memory layout from reset PC through stack top.
  • Identify which sections need initial contents and which are zero-filled.
  • Understand why .bss must be cleared.

Pitfalls

  • Placing stack where it collides with .bss or data.
  • Forgetting alignment requirements.
  • Using library code that expects syscalls or a full C runtime.

Tooling And Testing

  • Inspect ELF sections and symbols with binutils.
  • Disassemble startup code and confirm the first instructions are supported.
  • Create a C program with global initialized and uninitialized variables.

References