 |
|
 |
RENESAS TOOL NEWS on October 1, 2003: RSO-M3T-NC30WA-031001D
A Note on Using C Compiler M3T-NC30WA V.5.20 Release 1
|
Please take note of the following problem in using the M3T-NC30WA V.5.20 Release 1 C compiler (with an assembler and integrated development environment) for the M16C/60, M16C/30, M16C/20, M16C/10, and R8C/Tiny series MCUs:
- On using the standard library function "strcpy"
- Description
Copying a character string in the far area into the near area or vice versa by using the standard library function "strcpy" may cause the program to be executed improperly.
- Conditions
This problem occurs if the following five functions are satisfied:
| (1) | Any of these optimizing options -O3, -O4, -O5, -OR, and -OS is selected. |
| (2) | The -Ono_stdlib optimizing option is not selected. |
| (3) | The "strcpy" standard library function is used. |
| (4) |
The strcpy function takes its arguments as follows:
- A pointer to the near area as the first argument and a pointer to the far area as the second one, or
- A pointer to the far area as the first argument and a pointer to the near area as the second one.
|
| (5) | A character string consisting of an even number of characters is copied, and the string includes NULL characters. |
- Example
--------------------------------------------------------
#include <string.h>
int a[10];
void func(void)
{
strcpy(a,"abcde"); /* Conditions (3), (4), and (5) */
}
--------------------------------------------------------
- Workaround
This problem can be circumvented in either of the following ways:
| (1) | Select the -Ono_stdlib optimizing option. |
| (2) | Modify the standard library function "strcpy" by editing the library source files nfstrcpy.c and fnstrcpy.c to re-create the standard library file nc30lib.lib in the following steps:
a. Substitute the two lines shown below for the 70th line of the
nfstrcpy.c file.
--------------------------------------------
_asm(" mov.w $$[FB],R0",s1);
_asm(" exitd");
--------------------------------------------
b. Also substitute the three lines shown below for the 71st line of
the fnstrcpy.c file.
--------------------------------------------
_asm(" mov.w $$[FB],R0",s1);
_asm(" mov.w $$+2[FB],R2",s1);
_asm(" exitd");
--------------------------------------------
c. Execute the command shown below at the MS-DOS command line to
re-create the nc30lib.lib file.
make -f makefile.dos<ret>
d. Copy the nc30lib.lib file re-created in item c to the directory
specified by environment variable LIB30.
NOTE:
The nfstrcpy.c and fnstrcpy.c library source files and the
makefile.dos file are found in the /src30/lib directory where
the compiler has been installed.
|
- Schedule of Fixing the Problem
We plan to fix this problem in our next release of the product.
|
 |