What is a linker script and why is it important in embedded development?
Answer
A linker script (linker command file) tells the linker how to organize program sections in memory. Key elements: MEMORY block defines available memory regions (Flash, RAM, addresses, sizes). SECTIONS block places program sections (.text, .data, .bss, .rodata) into memory regions. Symbols for stack and heap boundaries. Entry point specification. Importance in embedded: Maps code to specific Flash addresses. Ensures variables are in RAM. Places critical code in fast memory. Defines stack location and size. Supports bootloader/application separation. Handles vendor-specific memory (CCM, DTCM). Common sections: .text (code), .rodata (constants), .data (initialized variables, copied from Flash), .bss (uninitialized variables, zeroed), .stack, .heap. Startup code uses linker symbols to initialize .data and zero .bss.
Master These Concepts with IIT Certification
175+ hours of industry projects. Get placed at Bosch, Tata Motors, L&T and 500+ companies.