You copied the Doc URL to your clipboard.

Using the C and C++ libraries with an application in a semihosting environment

If you are developing an application to run in a semihosted environment for debugging, you must have an execution environment that supports A32 or T32 semihosting trap instructions for AArch32 state or A64 semihosting trap instruction for AArch64 state.

The execution environment can be provided by either:

  • Using the standard semihosting functionality that is present by default in, for example, the Arm® DSTREAM debug and trace unit.
  • Implementing your own handler for the semihosting calls.

It is not necessary to write any new functions or include files if you are using the default semihosting functionality of the C and C++ libraries.

The Arm debug agents support semihosting, but the memory map assumed by the C library might require tailoring to match the hardware being debugged.

Arm Compiler supports semihosting by generating trap instructions such as HLT, SVC, or BKPT depending on the architecture or profile. Debug agents can trap these instructions to perform semihosting operations on the host.


The HLT instruction is architecturally UNDEFINED for Armv7‑A and Armv7‑R architectures, in both A32 and T32 state.

Table 1-2 Semihosting trap instructions

Architecture Instruction Set Trap Instruction
Armv8‑A and Armv8‑R A64 HLT 0xF000
Armv8‑A and Armv8‑R A32 HLT 0xF000
SVC 0x123456
Armv8‑A and Armv8‑R T32 HLT 0x3C
Armv7‑A and Armv7‑R A32 HLT 0xF000
SVC 0x123456
Armv7‑A and Armv7‑R T32 HLT 0x3C
Any architecture with M-profile T32 BKPT 0xAB

For AArch32 in architectures with A-profile or R-profile, Arm Compiler supports two different semihosting implementations:

  • Semihosting using the SVC instruction. This is the default and legacy implementation.
  • Semihosting using the HLT instruction. This implementation is required for semihosting in hardware debug environments with mixed AArch32 and AArch64 states.

There are separate libraries for SVC-based and HLT-based semihosting. Arm Compiler uses the HLT-based semihosting library if your code references the symbol __use_hlt_semihosting. To do this, either:

  • IMPORT __use_hlt_semihosting from assembly language.
  • __asm(".global __use_hlt_semihosting\n\t") from C.

If you do not use the symbol __use_hlt_semihosting, then by default, Arm Compiler emits SVC instructions for semihosting calls. This symbol does not have an effect on M-profile architectures, or in AArch64 state.

Arm strongly discourages mixing HLT and SVC semihosting mechanisms within the same executable. The library only uses either SVC or HLT instructions, rather than a mixture. However, you must ensure that you do not mix SVC and HLT instructions when using:

  • inline assembly.
  • <arm_compat.h> header file.