5.5.17 · D3 · HinglishEmbedded Systems & Real-Time Software

Worked examplesLinker scripts — memory regions, sections (.text, .data, .bss)

3,001 words14 min read↑ Read in English

5.5.17 · D3 · Coding › Embedded Systems & Real-Time Software › Linker scripts — memory regions, sections (.text, .data, .bs


Scenario matrix

Is topic mein jo bhi situation aa sakti hai woh in cells mein se ek mein fit hoti hai. Neeche diye examples mein se har ek ek ya zyada cells ko cover karta hai, aur milake sabhi cells hit ho jaate hain.

# Cell class Tricky cheez jo yeh test karta hai
C1 Pure .text, koi variables nahi LMA = VMA (code in-place run hota hai)
C2 .data present hai do addresses; Flash image ≠ RAM run
C3 .bss present hai size record hoti hai, zero Flash bytes
C4 .data aur .bss dono saath RAM dono stack karta hai; Flash sirf .data copy rakhta hai
C5 Zero / degenerate: empty .data ya empty .bss _sdata == _edata; copy loop 0 baar chalta hai
C6 Limiting: region bilkul full / ek byte over overflow detection, <= L boundary
C7 Alignment se gap force hota hai . aage jump karta hai; sizes "sirf sum" nahi rehti
C8 Word-problem: "X add karne se kitna Flash lagega?" .bss vs .data growth ke baare mein reasoning
C9 Exam twist: copy loop bhool gaye / KEEP drop kar diya runtime symptom predict karo

Do constant facts jo hum har jagah use karte hain (parent ke formula callout se):

Sabhi examples ke liye humara chip hai: (1K = 1024 bytes, toh 256K = 262144 bytes, 64K = 65536 bytes.)


Example 1 — Sirf code (cell C1)


Example 2 — Ek initialized global (cell C2)


Example 3 — Zero-init global (cell C3)


Example 4 — .data aur .bss stacked (cell C4)


Example 5 — Degenerate: empty .data (cell C5)


Example 6 — Limiting: RAM bilkul full, phir ek byte over (cell C6)


Example 7 — Alignment gap (cell C7)


Example 8 — Word problem: "ek aur variable ka kya cost aata hai?" (cell C8)


Example 9 — Exam twist: runtime symptom predict karo (cell C9)


Recall Quick self-test

Example 4 mein _ebss kya hai? ::: 0x2000008C = 0x20000000 + 140. Example 5 mein .data copy loop kitni baar chalaega? ::: Zero baar — _sdata == _edata. Example 6 mein RAM kitne bytes overflow karta hai jab .bss = 40500 ho? ::: 84 bytes. Example 7 mein ALIGN(4) ek 4002-byte .text ke baad kitne padding bytes insert karta hai? ::: 2 bytes. Example 8 mein kaun sa option Flash headroom bachata hai? ::: (b), zeroed .bss buffer — 0 Flash cost.


  • Parent: Linker scripts — memory regions, sections (.text, .data, .bss)
  • Boot copy/zero loops: Startup code & Reset_Handler
  • .isr_vector GC se kyun bachna chahiye: Vector table & interrupt handling
  • .data/.bss kahan se aate hain: Compilation pipeline — object files & relocation
  • Do memories ke peeche physical tradeoff: Flash vs RAM tradeoffs
  • RAM budget ke doosre tenants: Stack vs Heap in embedded systems
  • .bin mein actually kya hota hai: ELF file format & sections