Technical Support

CARM: REPLACING LIBRARY FUNCTIONS


Information in this article applies to:

  • CARM All Versions

QUESTION

I have defined my own putchar function. In THUMB mode everything runs fine, but when I switch to ARM mode I receive the following linker error:

*** ERROR L128: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  putchar?T
    ADDRESS: 0000040AH

or:

*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
    SYMBOL:  putchar?A

Is it possible to re-define a library function? Do I need to modify the run-time library?

ANSWER

You don't have to modify the compiler run-time library when you need a specially-configured version of the putchar function.

  • In THUMB mode, you only need to add the library routine (since most of the CARM run-time library is also written in THUMB mode).
  • In ARM mode, you need to translate the library module using the INTERWORK compiler directive. Functions translated with INTERWORK may be accessed from both CPU modes: THUMB and native ARM.

For example:

#pragma INTERWORK

#include <LPC21XX.H>          /* LPC21xx definitions */

#define CR     0x0D

int putchar (int ch)  {         /* Write to Serial Port */

  if (ch == '\n')  {
    while (!(U1LSR & 0x20));
    U1THR = CR;                 /* output CR */
  }
  while (!(U1LSR & 0x20));
  return (U1THR = ch);
}

MORE INFORMATION

SEE ALSO

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Tuesday, August 09, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure