Undefined symbol in inline assembly

Technical Note 47972

Architectures:

AVR32

Component:

compiler

Updated:

11/6/2015 12:28 PM

Introduction

After migration to IAR Embedded Workbench for AVR32 version 4.2x, the error...

Error[As011]: Undefined symbol: XXXXXX

.. is triggered for source code that uses inline assembly.

(There is no error for the same source in IAR Embedded Workbench for AVR32 version 4.10 or older).

Background

There is 3rd party source code that relies on a corrected bug in IAR Embedded Workbench for AVR32 version 4.2x.

The bug...

...was that a label in one inline assembly statement, could be used for a jump for another inline assembly statement.
The IAR C/C++ Compiler for AVR32 is not made to handle registers etc. for such a jump.

The correction...

...was to block jumps between different inline assembly statements.

Correction breaks 3rd party...

...source code that uses the described type of jump.

Solutions

Primary solution...

...is to rewrite the source so it doesn't need jumps between different inline assembly statements.

An a workaround...

...is to use the following construction. Please Note - IMPORTANT: This workaround Breaks the security system in the Compiler, i.e. You take responsibility for the effects of using this workaround.

The workaround is to use --disable_inline_asm_label_replacement which is documented in <installation directory>\avr32\doc\infocenter\iccavr32.ENU.html

The following option has been added:
--disable_inline_asm_label_replacement

Explanation:
Use this option to disable label replacement in
inline assembler statements. Disabling label
replacement will make labels shared between inline
assembler statements within a function meaning
that one inline assembler statement may refer to a
label in another inline assembler statement.

IMPORTANT:
IMPORTANT: The compiler leaves no guarantees on
the content of any register nor of the layout of
the stack frame upon entry of an inline assembler
statement unless explicitly requested through the
use of the extended inline assembler. Branching
between two inline assembler statement results in
"undefined behavior". 

 

All product names are trademarks or registered trademarks of their respective owners.

We do no longer support Internet Explorer. To get the best experience of iar.com, we recommend upgrading to a modern browser such as Chrome or Edge.