Building an image from C source
This example shows how to build an image from C code with armclang and armlink.
To compile a C source file
Compile the C source with
the following command:
armclang --target=aarch64-arm-none-eabi -c -O1 -o hello_world.o -xc -std=c90 -g hello_world.c
The following options are commonly used:
- Targets the AArch64 state of the ARMv8-A architecture profile.
Tells the compiler to compile only, and not link.
Tells the compiler that the source is C code.
NoteThe compiler infers the source code language from the filename extension. The
-xoption overrides the inferred language setting. The
-xoption is not required for this example, it is provided for illustrative purposes only.
Tells the compiler that the source is ISO C90 C code.
Tells the compiler to generate code with restricted optimizations applied to give a satisfactory debug view with good code density and performance.
Tells the compiler to add debug tables for source-level debugging.
Tells the compiler to create an object file with the specified
Link the file:
armlink hello_world.o --force_scanlib --info totals -o hello_world.axf
armlinkto link with the ARM libraries. The compiler does not include
$$Lib$Requestsymbols when building objects, so by default (that is, if you do not specify
armlinkdoes not automatically link with the ARM libraries, resulting in an
- Use an ELF and DWARF 4 compatible debugger to load and run the image.