ARM Technical Support Knowledge Articles

Can AArch32 and AArch64 objects be linked together?

Applies to: DS-5

Answer

Objects built for AArch32 and AArch64 cannot be linked together.  This is because the two execution states use different ABIs, and different address widths.  The error message you will get from the ARM linker (armlink) will be similar to this:

Error: L6831E: Mixing machine types EM_ARM and EM_AARCH64 is not permitted.

This is not expected to be a common use case, as execution state (AArch32/AArch64) can only change when taking or returning from an exception.  So AArch32 code cannot directly call AArch64 code (or vice verse).

However there are some cases where it is useful to build a mixed image.  In such cases there are a number of options:

DCI

The ARM assembler (armasm) provides the DCI directive.  This allows an instruction to be specified as hex value.  DCIs are not checked for validity against the target processor/instruction set.  Using DCIs would allow you to include A64 opcodes in an A32/T32 image, or A32/T32 opcodes in an A64 image.

This approach is useful when you only wish to include a short sequence in the other instruction set.  For example, a basic A64 boot strap which set up EL1 as AArch32 and switched to that exception level.

More information on the DCI directive can be found here.

INCBIN

The INCBIN directive allows a file to be included within an object as binary data.  This directive can be used to insert one image within another.  For example, an AArch64 boot loader program could include an AArch32 OS image as a binary.

More information on INCBIN can be found here.

Symdef File

In some cases you may only need address information to be shared between two images.  For example, the address of shared data.  The ARM linker (armlink) can generate a symbols definition file (symdef file) listing the global symbols defined by the image, and their addresses.  This file can be used as an input to other link steps, with the linker using the file to resolve references to those symbols.

NOTE: You may need to trim to the generated symdef file so that it only includes the symbols you wish shared.

More information on generating and using symdef files can be found here.

Attachments: INCBIN_example.zip

Article last edited on: 2014-12-08 17:10:12

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential