Skip to content

Commit cc74034

Browse files
committed
Fix ARMC6 linker error for the bare metal profile
The ARMC6 compiler inadvertently introduces the `_scanf_mbtowc` symbol to the build. The commit provides a weak definition of the symbol to satisfy the linker whenever the symbol is included. This affects ARM Compiler 6 version 6.12 and earlier. The compiler error was previously observed when the MICROLIB library is used with the uARM toolchain. However, the weak definition was put in `mbed-os/rtos` which is not included when the bare metal profile is used.
1 parent ab857c4 commit cc74034

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

platform/source/mbed_retarget.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,3 +1735,21 @@ MBED_WEAK const ticker_info_t *lp_ticker_get_info()
17351735
};
17361736
return &info;
17371737
}
1738+
1739+
1740+
// The below resolves the linker error generated by a bug in Arm Compiler 6
1741+
// The compiler inadvertently introduces the
1742+
// _scanf_mbtowc symbol to the build. The code below provides a weak reference
1743+
// for the missing symbol.
1744+
// Arm Compiler 6 version 6.12 and earlier versions are affected.
1745+
typedef int ScanfReadRec;
1746+
extern "C" MBED_WEAK long int _scanf_mbtowc(
1747+
int ignored,
1748+
FILE *p,
1749+
ScanfReadRec *sr,
1750+
int *charmap,
1751+
int exact
1752+
)
1753+
{
1754+
return 0;
1755+
}

rtos/source/TARGET_CORTEX/TOOLCHAIN_ARM_MICRO/mbed_boot_arm_micro.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,3 @@ MBED_WEAK void __aeabi_assert(const char *expr, const char *file, int line)
6868
{
6969
mbed_assert_internal(expr, file, line);
7070
}
71-
72-
// The below resolves the linker error generated by a bug in Arm Compiler 6
73-
// When building with MicroLib, the compiler inadvertently introduces the
74-
// _scanf_mbtowc symbol to the build. The code below provides a weak reference
75-
// for the missing symbol.
76-
// Arm Compiler 6 version 6.12 and earlier versions are affected.
77-
#include <stdio.h>
78-
typedef int ScanfReadRec;
79-
MBED_WEAK long int _scanf_mbtowc(
80-
int ignored,
81-
FILE *p,
82-
ScanfReadRec *sr,
83-
int *charmap,
84-
int exact
85-
)
86-
{
87-
return 0;
88-
}

0 commit comments

Comments
 (0)