4.2 Language extension compatibility: attributes

Arm® Compiler 6 provides support for some function, variable, and type attributes that were supported in Arm Compiler 5. Other attributes are not supported, or have an alternate implementation.

The following attributes are supported by Arm Compiler 5 and Arm Compiler 6. These attributes do not require modification in your code:

  • __attribute__((aligned(x)))
  • __attribute__((always_inline))
  • __attribute__((const))
  • __attribute__((deprecated))
  • __attribute__((noinline))
  • __declspec(noinline)
  • __attribute__((nonnull))
  • __attribute__((noreturn))
  • __declspec(noreturn)
  • __attribute__((nothrow))
  • __declspec(nothrow)
  • __attribute__((pcs("calling convention")))
  • __attribute__((pure))
  • __attribute__((unused))
  • __attribute__((used))

    Note:

    In Arm Compiler 6, functions marked with __attribute__((used)) can still be removed by linker unused section removal. To prevent the linker from removing these sections, you can use either the --keep=symbol or the --no_remove armlink options. In Arm Compiler 5, functions marked with __attribute__((used)) are not removed by the linker.
  • __attribute__((visibility))
  • __attribute__((weak))
  • __attribute__((weakref))

Though Arm Compiler 6 supports certain __declspec attributes, Arm recommends using __attribute__ where available.

Table 4-3 Support for __declspec attributes

declspec supported by Arm Compiler 5 Recommended Arm Compiler 6 alternative
__declspec(dllimport) None. There is no support for BPABI linking models.
__declspec(dllexport) None. There is no support for BPABI linking models.
__declspec(noinline) __attribute__((noinline))
__declspec(noreturn) __attribute__((noreturn))
__declspec(nothrow) __attribute__((nothrow))
__declspec(notshared) None. There is no support for BPABI linking models.
__declspec(thread) __thread

Section

__attribute__((section("name"))) is supported by Arm Compiler 5 and Arm Compiler 6. However, this attribute might require modification in your code.

When using Arm Compiler 5, section names do not need to be unique. Therefore, you could use the same section name to create different section types.

Arm Compiler 6 supports multiple sections with the same section name only if you specify a unique ID. You must ensure that different section types either:

  • Have a unique section name.
  • Have a unique ID, if they have the same section name.

If you use the same section name, for another section or symbol, without a unique ID, then armclang integrated assembler merges the sections and gives the merged section the flags of the first section with that name.

Migrating __attribute__((at(address))) and zero-initialized __attribute__((section("name"))) from Arm® Compiler 5 to Arm® Compiler 6

Arm Compiler 5 supports the following attributes, which Arm Compiler 6 does not support:

  • __attribute__((at(address))) to specify the absolute address of a function or variable.
  • __attribute__((at(address), zero_init)) to specify the absolute address of a zero-initialized variable.
  • __attribute__((section(name), zero_init)) to place a zero-initialized variable in a zero-initialized section with the given name.
  • __attribute__((zero_init)) to generate an error if the variable has an initializer.

The following table shows migration paths for these features using Arm Compiler 6 supported features:

Table 4-4 Migrating __attribute__((at(address))) and zero-initialized __attribute__((section("name")))

Arm Compiler 5 attribute Arm Compiler 6 attribute Description
__attribute__((at(address))) __attribute__((section(".ARM.__at_address"))) armlink in Arm Compiler 6 still supports the placement of sections in the form of .ARM.__at_address
__attribute__((at(address), zero_init)) __attribute__((section(".bss.ARM.__at_address"))) armlink in Arm Compiler 6 supports the placement of zero-initialized sections in the form of .bss.ARM.__at_address. The .bss prefix is case sensitive and must be all lowercase.
__attribute__((section(name), zero_init)) __attribute__((section(".bss.name"))) name is a name of your choice. The .bss prefix is case sensitive and must be all lowercase.
__attribute__((zero_init)) Arm Compiler 6 by default places zero-initialized variables in a .bss section. However, there is no equivalent to generate an error when you specify an initializer. Arm Compiler 5 generates an error if the variable has an initializer. Otherwise, it places the zero-initialized variable in a .bss section.
Non-ConfidentialPDF file icon PDF versionDUI0742J
Copyright © 2014–2017, 2019 Arm Limited or its affiliates. All rights reserved.