Keil Logo

ARMCLANG: L6218E: Undefined Symbol __aeabi_assert


Information in this knowledgebase article applies to:

  • Keil MDK 5
  • Arm Compiler 5 + 6
  • Arm MicroLIB C library

SYMPTOM

Building a project using Arm Compiler 6 (or Arm Compiler 5 ) produces this linker error:

Error: L6218E: Undefined symbol __aeabi_assert (referred from *.o)

CAUSE

The "Error: L6218E: Undefined symbol __aeabi_assert..." could occur if under Project -> Options for Target -> on the Target tab - Use MicroLIB is selected.

microlib

Microlib is a separate smaller library than the ARM standard C library. 

To save size the Arm MicroLIB C library does not support or implement almost all functions that interact with an operating system, e.g., functions such as abort(), exit(), or assert().

RESOLUTION

There are several options to resolve this issue:

  • Use the Keil::ARM_Compiler Pack: in µVision,
    1. Open the Manage Run-Time Environment dialog and expand Compiler -> I/O.
    2. Next to STDERR, check the box. In the variant column, select ITM .
    3. Click OK to close the dialog.
    Enabling this software component includes the retarget_io.c file in the Compiler section of the Project Window. This retarget_io.c file includes an __aeabi_assert() function similar to this:
    __attribute__((weak,noreturn))
    void __aeabi_assert (const char *expr, const char *file, int line) {
      char str[12], *p;
    
      fputs("*** assertion failed: ", stderr);
      fputs(expr, stderr);
      fputs(", file ", stderr);
      fputs(file, stderr);
      fputs(", line ", stderr);
    
      p = str + sizeof(str);
      *--p = '\0';
      *--p = '\n';
      while (line > 0) {
        *--p = '0' + (line % 10);
        line /= 10;
      }
      fputs(p, stderr);
    
      abort();
    }
    
    __attribute__((weak))
    void abort(void) {
      for (;;);
    }
    
  • Make your own: While using the Arm MicroLIB C library, implement a self-defined __aeabi_assert() function. Use the above code as a template.
  • Disable assert(): On Project -> Options For Target -> on the C/C++ tab, for Define type "NDEBUG." - this causes calls to the assert() function to have no effect.
  • Disable MicroLIB: Under Project -> Options For Target -> in the top-right of the Target dialog, uncheck Use MicroLIB to disable the Arm MicroLIB C library.

After modifying, rebuild the project to have it take effect.

STATUS

A future release of Arm MicroLIB C library might add support for assert().

MORE INFORMATION

SEE ALSO

Last Reviewed: Thursday, October 29, 2020


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.