You copied the Doc URL to your clipboard.

Building a Non-secure image that can call a Secure image

If you are building a Non-secure image that is to call a Secure image, the Non-secure code must be written in C. You must also obtain the import library package that was created for that Secure image.


The following procedure assumes that you have the import library package that is created in  Building a Secure image using the Arm®v8‑M Security Extensions. The package provides the C linkage that allows you to compile your Non-secure code as C or C++.

The import library package identifies the entry points for the Secure image.


  1. Include the interface header file in the C program for your Non-secure code, nonsecure.c, and use the entry functions as required, for example:
    #include <stdio.h>
    #include "myinterface_v1.h"
    int main(void) {
        int val1, val2, x;
        val1 = entry1(x);
        val2 = entry2(x);
        if (val1 == val2) {
            printf("val2 is equal to val1\n");
        } else {
            printf("val2 is different from val1\n");
        return 0;
  2. Create an object file, nonsecure.o:
    $ armclang -c --target arm-arm-none-eabi -march=armv8-m.main nonsecure.c -o nonsecure.o
  3. Create a scatter file for the Non-secure image, but without the Non-Secure Callable (NSC) memory region, for example:
    LOAD_REGION 0x8000 0x3000
        ER 0x8000
        ARM_LIB_STACK 0x800000 EMPTY -0x10000
        ARM_LIB_HEAP  +0 EMPTY 0x10000
  4. Link the object file using the import library, importlib_v1.o, and the scatter file to create the Non-secure image:
    $ armlink nonsecure.o importlib_v1.o -o nonsecure.axf --cpu=8-M.Main --scatter nonsecure.scat