You copied the Doc URL to your clipboard.

-mcmodel

Selects the generated code model.

Note

This topic includes descriptions of [ALPHA] features. See Support level definitions.

Default

The default is -mcmodel=small.

Syntax

-mcmodel=model

Parameters

model specifies the model type for code generation.

When specifying the model type, it can be one of:

tiny
Generate code for the tiny code model. The program and its statically defined symbols must be within 1MB of each other.
small
Generate code for the small code model. The program and its statically defined symbols must be within 4GB of each other. This is the default code model.
large
[ALPHA] Generate code for the large code model. The compiler makes no assumptions about addresses and sizes of sections.

Operation

The compiler generates instructions that refer to global data through relative offset addresses. The model type specifies the maximum offset range, and therefore the size of the offset address. The actual required range of an offset is only known when the program is linked with other object files and libraries. If you know the final size of your program, you can specify the appropriate model so that the compiler generates optimal code for offsets.

If you specify a larger model than is required, then your code is unnecessarily larger.

If the model you choose is too small and the image does not fit in the bounds, then the linker reports an error.

Examples

[ALPHA] This example enables code generation for the large model:

armclang --target=aarch64-arm-none-eabi -march=armv8.5-a -mcmodel=large -c foo.c

This example generates code for the default (small) code model:

armclang --target=aarch64-arm-none-eabi -march=armv8.5-a -c foo.c