Thank you very much for your help.
I checked the assembly code for memset
and it seems there is an issue. Here is the content:
(gdb) info address memset
Symbol "memset" is at 0x18fa4 in a file compiled without debugging.
(gdb) disassemble memset
Dump of assembler code for function memset:
0x00018fa4 <+0>: movs r3, r0
0x00018fa6 <+2>: b.n 0x195ca
0x00018fa8 <+4>: lsls r0, r0, #1
0x00018faa <+6>: lsrs r0, r0, #8
0x00018fac <+8>: movs r0, r0
0x00018fae <+10>: b.n 0x19656
0x00018fb0 <+12>: movs r0, #1
0x00018fb2 <+14>: b.n 0x1943a
0x00018fb4 <+16>: vrhadd.u16 d0, d14, d31
0x00018fb8 <+20>: adds r0, #0
0x00018fba <+22>: b.n 0x192fe
0x00018fbc <+24>: stmia r0!, {r0, r1, r2, r3, r4, r5, r6, r7}
0x00018fbe <+26>: b.n 0x193c4
0x00018fc0 <+28>: movs r2, r0
0x00018fc2 <+30>: and.w r0, r0, r1, lsl #8
0x00018fc6 <+34>: b.n 0x1944e
0x00018fc8 <+36>: movs r1, r0
--Type <RET> for more, q to quit, c to continue without paging--c
0x00018fca <+38>: b.n 0x196b2
0x00018fcc <+40>: vrhadd.u16 d0, d14, d31
0x00018fd0 <+44>: stmia r0!, {r0}
0x00018fd2 <+46>: b.n 0x1895c <_fclose_r+356>
0x00018fd4 <+48>: movs r3, r0
0x00018fd6 <+50>: b.n 0x19600
0x00018fd8 <+52>: ; <UNDEFINED> instruction: 0xfff91aff
0x00018fdc <+56>: movs r3, r0
0x00018fde <+58>: b.n 0x19686
0x00018fe0 <+60>: movs r0, r5
0x00018fe2 <+62>: ldr r2, [sp, #0]
0x00018fe4 <+64>: ands r0, r6
0x00018fe6 <+66>: stmdb sp!, {r0, r1, r2, r3, r4, r5, r6, r7, sp, lr, pc}
0x00018fea <+70>: b.n 0x193f0
0x00018fec <+72>: b.n 0x1880c <_fclose_r+20>
0x00018fee <+74>: b.n 0x1930e
0x00018ff0 <+76>: movs r7, r1
0x00018ff2 <+78>: b.n 0x1969a
0x00018ff4 <+80>: ; <UNDEFINED> instruction: 0xe80ee18e
0x00018ff8 <+84>: movs r6, r5
0x00018ffa <+86>: ldr r2, [sp, #0]
0x00018ffc <+88>: stmia r0!, {r4}
0x00018ffe <+90>: b.n 0x19486
0x00019000 <+92>: ands r7, r1
0x00019002 <+94>: b.n 0x1979e
0x00019004 <+96>: str r0, [r4, r0]
0x00019006 <+98>: b.n 0x19510
0x00019008 <+100>: str r4, [r0, r0]
0x0001900a <+102>: b.n 0x19118 <__sread+40>
0x0001900c <+104>: tst r4, r5
0x0001900e <+106>: b.n 0x19352
0x00019010 <+108>: stmia r0!, {r4}
0x00019012 <+110>: b.n 0x1951c
0x00019014 <+112>: b.n 0x19038 <memset+148>
0x00019016 <+114>: b.n 0x18a32 <_malloc_trim_r+206>
0x00019018 <+116>: b.n 0x19034 <memset+144>
0x0001901a <+118>: b.n 0x18a36 <_malloc_trim_r+210>
0x0001901c <+120>: b.n 0x19030 <memset+140>
0x0001901e <+122>: b.n 0x18a3a <_malloc_trim_r+214>
0x00019020 <+124>: b.n 0x1902c <memset+136>
0x00019022 <+126>: b.n 0x18a3e <_malloc_trim_r+218>
0x00019024 <+128>: stmia r0!, {r4}
0x00019026 <+130>: b.n 0x19542
0x00019028 <+132>: movs r5, r0
0x0001902a <+134>: b.n 0x192e6
0x0001902c <+136>: ; <UNDEFINED> instruction: 0xfff81aff
0x00019030 <+140>: stmia r0!, {r0}
0x00019032 <+142>: b.n 0x1953e
0x00019034 <+144>: movs r4, r1
0x00019036 <+146>: b.n 0x1965e
0x00019038 <+148>: stmia r2!, {r2, r3}
0x0001903a <+150>: b.n 0x19144 <__swrite+32>
0x0001903c <+152>: movs r0, #15
0x0001903e <+154>: b.n 0x19446
0x00019040 <+156>: movs r0, r3
0x00019042 <+158>: lsrs r0, r0, #8
0x00019044 <+160>: adds r0, #4
0x00019046 <+162>: b.n 0x194ce
0x00019048 <+164>: adds r0, #3
0x0001904a <+166>: b.n 0x197d4
0x0001904c <+168>: adds r0, #4
0x0001904e <+170>: b.n 0x19558
0x00019050 <+172>: adds r0, #3
0x00019052 <+174>: b.n 0x1916e <__swrite+74>
0x00019054 <+176>: b.n 0x19060 <memset+188>
0x00019056 <+178>: b.n 0x18972 <_malloc_trim_r+14>
0x00019058 <+180>: movs r4, r1
0x0001905a <+182>: b.n 0x19304
0x0001905c <+184>: ; <UNDEFINED> instruction: 0xfffc1aff
0x00019060 <+188>: movs r0, #3
0x00019062 <+190>: b.n 0x1946a
0x00019064 <+192>: movs r0, r0
0x00019066 <+194>: b.n 0x1970e
0x00019068 <+196>: movs r4, r0
0x0001906a <+198>: lsrs r0, r0, #8
0x0001906c <+200>: asrs r7, r7, #3
0x0001906e <+202>: b.n 0x19474
0x00019070 <+204>: movs r0, #2
0x00019072 <+206>: b.n 0x1917c <__swrite+88>
0x00019074 <+208>: asrs r1, r0, #32
0x00019076 <+210>: b.n 0x18a00 <_malloc_trim_r+156>
0x00019078 <+212>: movs r3, r0
0x0001907a <+214>: b.n 0x19322
0x0001907c <+216>: ; <UNDEFINED> instruction: 0xfffc1aff
0x00019080 <+220>: ands r0, r6
0x00019082 <+222>: ldmia.w sp!, {r1, r2, r3, r4, r8, r9, r10, r11, r12, sp, lr, pc}
0x00019086 <+226>: b.n 0x192e8
0x00019088 <+228>: movs r0, r0
0x0001908a <+230>: b.n 0x19732
0x0001908c <+232>: vrhadd.u16 d0, d14, d31
0x00019090 <+236>: asrs r7, r7, #3
0x00019092 <+238>: b.n 0x19498
0x00019094 <+240>: movs r0, #2
0x00019096 <+242>: b.n 0x191a0 <__sseek+32>
0x00019098 <+244>: asrs r1, r0, #32
0x0001909a <+246>: b.n 0x18a24 <_malloc_trim_r+192>
0x0001909c <+248>: movs r3, r0
0x0001909e <+250>: b.n 0x19346
0x000190a0 <+252>: ; <UNDEFINED> instruction: 0xfffc1aff
0x000190a4 <+256>: vrhadd.u16 d14, d14, d31
0x000190a8 <+260>: adds r0, #12
0x000190aa <+262>: b.n 0x193ee
0x000190ac <+264>: ; <UNDEFINED> instruction: 0xffeceaff
0x000190b0 <+268>: adds r0, #0
0x000190b2 <+270>: b.n 0x193f6
0x000190b4 <+272>: ; <UNDEFINED> instruction: 0xffc8eaff
0x000190b8 <+276>: stmia r0!, {r0, r1}
0x000190ba <+278>: b.n 0x193fe
0x000190bc <+280>: ; <UNDEFINED> instruction: 0xffe0eaff
End of assembler dump.
This reminded me that initially, to avoid compilation errors, I manually added the following functions in main.c
:
int _write_r(int file, char *ptr, int len) {
return len;
}
int _close_r(int file) {
// return -1;
return 0;
}
int _lseek_r(int file, int ptr, int dir) {
return 0;
}
int _read_r(int file, char *ptr, int len) {
return 0;
}
Without these functions, the compilation error message is as follows:
ld.lld: error: undefined symbol: _read
>>> referenced by readr.c
>>> lib_a-readr.o:(_read_r) in archive /home/mdd/gcc-arm-none-eabi-10.3-2021.10/arm-none-eabi/lib/libc.a
ld.lld: error: undefined symbol: _lseek
>>> referenced by lseekr.c
>>> lib_a-lseekr.o:(_lseek_r) in archive /home/mdd/gcc-arm-none-eabi-10.3-2021.10/arm-none-eabi/lib/libc.a
ld.lld: error: undefined symbol: _close
>>> referenced by closer.c
>>> lib_a-closer.o:(_close_r) in archive /home/mdd/gcc-arm-none-eabi-10.3-2021.10/arm-none-eabi/lib/libc.a
ld.lld: error: undefined symbol: _write
>>> referenced by writer.c
>>> lib_a-writer.o:(_write_r) in archive /home/mdd/gcc-arm-none-eabi-10.3-2021.10/arm-none-eabi/lib/libc.a
clang: error: ld.lld command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:108:output/RTOSDemo.out]
It seems like the issue might be caused by not properly resolving the compilation errors.
How should I address this? Thank you very much for your assistance.