Controlling the Runtime Model

The following options can be used to dictate compiler behavior with regards to how code and data is organized in compiler generated object files, generating code to monitor stack usage at run-time, constraints on pointer alignment when generating code to access memory, and enabling a link-time dead-code removal optimization.

armcl Option tiarmclang Option
–common=on (default) –common=off -fcommon (default) -fno-common

The tiarmclang compiler’s -fcommon and -fno-common options mirror the armcl’s –common option. The tiarmclang compiler’s -fcommon option indicates to the compiler that variables without initializers will get common linkage. This can be disabled with tiarmclang’s -fno-common option.

By default, the armcl –common option is on. Likewise, the default behavior for tiarmclang is -fcommon.

armcl Option tiarmclang Option
–embedded_constants=on (default) –embedded_constants=off not supported

The armcl compiler embeds constant definitions in functions by default. One consequence of this is that the compiler may generate accesses to data that is defined in code sections that will conflict with attempts to put the code section in an execute-only region of memory.

Whether or not the tiarmclang compiler will embed constant definitions in code may vary depending on the optimization level specified on the tiarmclang command-line. When optimizing for code size in preference to performance with the -Oz or -Oz option, the tiarmclang compiler is more likely to generated embedded constants in code.

armcl Option tiarmclang Option
–gen_func_subsections=on (default) –gen_func_subsections=off -ffunction-sections (default) -fno-function-sections

The armcl compiler’s –gen_func_subsections option, which is on by default, places each function definition into a separate subsection.

The analogous tiarmclang option is -ffunction-sections, also on by default, which generates each function definition into its own section. You can further control section placement with the section function attribute, __attribute__((section(“<section name>”))), which can be added to the definition of a function to place it in a particular section.

Placing every function definition in its own section will enable the linker to remove unreferenced functions from the linked output file. As this can prove to have a significant impact on reducing the code size of a program without any impact on run-time performance, it is recommended that the default setting of -ffunction-sections be left intact.

armcl Option tiarmclang Option
–gen_data_subsections=on (default) –gen_data_subsections=off -fdata-sections (default) -fno-data-sections

The armcl compiler’s –gen_data_subsections option, which is on by default, places aggregate data (arrays, structs, and unions) into separate subsections.

The analogous tiarmclang option is -fdata-sections, also on by default, which generates a separate section for each variable, including non-aggregate variables. You can further control section placement with the section variable attribute, __attribute__((section(“<section name>”))), which can be added to the definition of a particular data object to place it in a particular section.

Placing every variable definition in its own section will enable the linker to remove unreferenced data objects from the linked output file. As this can prove to have a significant impact on reducing the amount of space allocated for variables in a program without impacting run-time performance, it is recommended that the default setting of -fdata-sections be left intact.

armcl Option tiarmclang Option
–global_register=<r5|r6|r9> not supported

The armcl compiler allows you to prohibit the compiler from using a register indicated by the –global_register option.

The tiarmclang compiler does not provide an analogous option.

armcl Option tiarmclang Option
–printf_support=<nofloat|full|minimal> not supported

The armcl’s –printf_support option allows you to limit the printf and scanf support required in the standard C runtime library. For example, if the you know that an application will never pass a floating-point value to be formatted by a printf- or scanf-family function, then using the –printf_support=nofloat option instructs the compiler to use a customized version of the printf- or scanf-family C/C++ runtime function that does not support floating-point and is therefore much smaller than a printf- or scanf-family function that provides full support for floating-point.

The tiarmclang compiler does not provide an analogous option.

armcl Option tiarmclang Option
–ramfunc=off (default) –ramfunc=on not supported

The armcl compiler’s –ramfunc option, when it is on (default behavior is off), instructs the compiler to generate the code for the functions defined in a compilation unit into a special “.TI.ramfunc” section, which can then be placed in RAM memory at link time.

The tiarmclang compiler does not provide an analogous option. However, the code generated for a function can be directed into a specific section using a section function attribute, such as __attribute__((section(“<section name>”))), attached to the function definition in the C/C++ source file where it is defined.

armcl Option (and alias) tiarmclang Option
–stack_overflow_check (-mo) not supported

The armcl compiler’s –stack_overflow_check option enables dynamic stack overflow checking.

The tiarmclang compiler does not provide an analogous option. However, future versions of the tiarmclang compiler may provide some support for statically detecting stack vulnerabilities. For example, the compiler may be updated to warn about potential stack vulnerabilities when it encounters particular situations in the source code, including:

  • A local array whose space is allocated on the stack
  • A call to alloca() which allocates space on the stack at run-time
  • A local variable that has its address taken

Control over this compiler behavior will likely be provided via a new command-line option.

Another useful feature that is planned for the next tiarmclang compiler tools release is support for statically estimating a program’s stack usage.

armcl Option tiarmclang Option
–unaligned_access=on –unaligned_access=off -munaligned-access (default) -mno-unaligned-access

When the armcl compiler’s –unaligned_access option is on (the default behavior for all Cortex processor variants), the compiler assumes that it is safe to generate load and store instructions that access data that falls on an unaligned boundary (i.e. 32-bit data on a 16-bit boundary).

Since the tiarmclang compiler only supports generating code for Cortex processor variants, the default behavior for the tiarmclang compiler is -munaligned-access. The tiarmclang compiler’s -mno-unaligned-access option can be specified to disable unaligned accesses.

armcl Option tiarmclang Option
–generate_dead_funcs_list=<filename> –use_dead_funcs_list=<filename> not supported

The armcl tools package provides the –generate_dead_funcs_list and –use_dead_funcs_list options, which allow you to first generate a list of dead functions at link-time, and then use that list as input to a subsequent compile to remove the definition of the dead function from the compilation unit.

The tiarmclang compiler does not provide an analogous pair of options. However, the tiarmclang compiler generates the definition of a given function into its own subsection by default, which enables the linker to remove the function definition from the application if it is not referenced.