Course: Computer Architectures
Source: F. Angione, P. Bernardi and R. Ferrero, Politecnico di Torino, 12_toolchain.pdf, 30 PDF pages. The local source is Downloads/Architecture/12_toolchain.pdf. The notes below distinguish source material from added study explanations.
Why this lesson matters
An ARM program becomes executable through several cooperating tools. The compiler translates source code, the linker combines files and assigns final addresses, and the runtime startup code prepares memory before main() begins. Keeping these stages separate explains build errors, map files, Flash/RAM placement and debugging differences.
Learning route
- Start with ARM Toolchain and Memory Images for the three build phases, output files and load/execution addresses.
- Revisit ARM Subroutines and Procedure Calls to connect symbol resolution and startup calls with AAPCS.
- Review ARM Assembly Directives and Tables and ARM Memory Access and Addressing for sections, data and runtime placement.
Source coverage by PDF page
| PDF pages | Material |
|---|---|
| 1-4 | Toolchain overview, cross-compilers and the three phases |
| 5-9 | Compile phase, armclang, armasm, language standards and optimization |
| 10-14 | Link phase, armlink, symbols, unused sections and memory layout |
| 15-17 | Execute phase, fromelf and image conversion |
| 18-24 | Executable, load view, execution view and Flash/RAM initialization |
| 25-28 | Listing, dependency, map, call-graph and build-log files |
| 29-30 | Startup on a system-on-chip, __main and __rt_entry |
The build path
C/C++ and assembly source
↓
compile and assemble
↓
object files
↓
link
↓
executable image
↓
load, debug or convertA cross-compiler runs on one platform and creates code for another platform. In this course, the compiler runs on a development computer and produces code for an ARM processor.
Three phases
armclangcompiles C/C++ and can assemble GNU-style assembly or inline assembly.armasmassembles legacy ARM assembly syntax.armlinkcombines object files, resolves symbols, removes unused sections and assigns addresses using memory information or a scatter file.fromelfinspects images and converts ELF images into formats such as binary, Motorola S-record and Intel HEX.
Memory images
The linker creates both a storage plan and a runtime plan. The load view describes where bytes are stored in the image, commonly Flash or ROM. The execution view describes where sections are used while the program runs.
Read-only code and constants can execute directly from Flash. Initialized read-write data has initial bytes in Flash, then startup code copies those bytes to RAM. Zero-initialized data has no useful initial payload in Flash. Startup code reserves its RAM region and clears it to zero.
Added clarification from the study discussion: a variable such as int counter = 10 can therefore have a Flash load address and a different RAM execution address. The value is copied before main().
Startup sequence
power-on reset → Reset_Handler → C runtime startup → main()The runtime prepares the stack and heap, initializes library data, copies initialized data, clears zero-initialized data and calls top-level constructors where applicable. The lecture identifies __main and __rt_entry as parts of this startup path.
Build outputs
.elfor.axfexecutable images contain code, data, symbols and often debug information.- Listing files show the translation from source to machine code.
.ddependency files record source relationships used by the build system.- Map files report symbols, addresses, memory regions and component sizes.
- Static call-graph files show function-calling relationships.
- Build logs record tools, versions, inputs and outcomes.
Optimization and debugging
O0 keeps the generated code close to the source and is easiest to debug. O1, O2 and O3 apply increasingly strong transformations. Higher levels can remove unused work, inline functions, reorder instructions and make source breakpoints harder to match to machine instructions. Size-focused and speed-focused modes apply different priorities.
Review questions
- What is the difference between compilation and linking?
- Why can a variable have one load address and another execution address?
- Which tool creates an Intel HEX or plain binary file from an ELF image?
- What must happen before
main()can safely use initialized data? - What information would you inspect in a map file?