4.9 C, C++, and assembly language interworking using veneers

When compiling or assembling modules written in C, C++, or assembly language for interworking, you must specify the --apcs=/interwork compiler or assembler option.

C, C++, and assembly language interworking using veneers

This example shows interworking between Thumb code generated from C and ARM code written in assembly language, using veneers.

     /**********************
     *       thumb.c      *
     **********************/
     #include <stdio.h>
     extern int arm_function(int);
     int main(void)
     {
          int i = 1;
          printf("i = %d\n", i);
          printf("And i+4 = %d\n", arm_function(i));
          return (0);
     }
     ; *****
     ; arm.s
     ; *****
     PRESERVE8
     AREA  Arm,CODE,READONLY ; Name this block of code.
     EXPORT arm_function
arm_function
     ADD   R0,R0,#4           ; Add 4 to first parameter.
     BX    lr                 ; Return
     END

Building the example

Follow these steps to build and link the modules:

  1. To compile the Thumb code for interworking, type:

    armcc --thumb --debug -c --apcs=/interwork thumb.c
    
  2. To assemble the ARM code for interworking, type:

    armasm --debug --apcs=/interwork arm.s
    
  3. To link the object files, type:

    armlink arm.o thumb.o -o add.axf
    

    Alternatively, to view the size of the interworking veneers, type:

    armlink arm.o thumb.o -o add.axf --info=veneers
    
  4. Run the image using a compatible debugger with an appropriate debug target.

Non-ConfidentialPDF file icon PDF versionARM DUI0471M
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.