在我的嵌入式项目中,我amazon-freertos/lib/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.c
以这种方式编译:
/opt/gcc-arm-none-eabi-8-2019-q3-update/bin/arm-none-eabi-gcc \
-std=gnu11 \
-mcpu=cortex-m7 \
-mthumb \
-mapcs \
-mfloat-abi=hard \
-mfpu=fpv5-d16 \
-fno-common \
-fno-math-errno \
-fsingle-precision-constant \
-fno-trapping-math \
-fno-signaling-nans \
-fno-builtin \
-fstrict-aliasing \
-fstack-usage \
-Wstack-usage=300 \
-DCPU_MIMXRT1051DVL6B \
-D__FREERTOS__=1 \
-DFSL_RTOS_FREE_RTOS \
-DFSL_FEATURE_PHYKSZ8081_USE_RMII50M_MODE \
-D__MCUXPRESSO \
-D__USE_CMSIS \
-DARM_MATH_CM7 \
-D__NEWLIB__ \
-DDEBUG=0 \
-IDSP/source/ \
-Iamazon-freertos/lib/FreeRTOS-Plus-TCP/ \
-Iamazon-freertos/lib/FreeRTOS-Plus-TCP/portable/BufferManagement/ \
-Iamazon-freertos/lib/FreeRTOS-Plus-TCP/portable/NetworkInterface/imxrt105x/ \
-Iamazon-freertos/lib/FreeRTOS/ \
-Iamazon-freertos/lib/include/ \
-Iamazon-freertos/lib/FreeRTOS/portable/GCC/ARM_CM4F/ \
-Iamazon-freertos/lib/FreeRTOS/portable/MemMang/ \
-Og \
-g3 \
-Wall \
-ffunction-sections \
-fdata-sections \
-c \
-MMD \
-MP \
-Werror \
-D"ARCPRINTF( ... )=(void)0" \
--specs=nano.specs \
-Wa,-anhlmsd=build/DSP/amazon-freertos/lib/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.lst \
-o build/DSP/amazon-freertos/lib/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.o amazon-freertos/lib/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.c
我已经ipconfigUSE_TCP
设置为 1 inamazon-freertos/lib/FreeRTOS-Plus-TCP/include/FreeRTOSIPConfig.h
FreeRTOS_Sockets.c
声明xBoundUDPSocketsList
并xBoundTCPSocketsList
/* The list that contains mappings between sockets and port numbers. Accesses
to this list must be protected by critical sections of one kind or another. */
List_t xBoundUDPSocketsList;
#if ipconfigUSE_TCP == 1
List_t xBoundTCPSocketsList;
#endif /* ipconfigUSE_TCP == 1 */
链接我的 elf 可执行文件后,运行以下命令:
$ /opt/gcc-arm-none-eabi-8-2019-q3-update/bin/arm-none-eabi-nm -a -l -n -t x --print-size image/DSP.elf | grep -E '^[[:xdigit:]]{8} [[:xdigit:]]{8} B' | grep SocketsList
2001ac7c 00000014 B xBoundTCPSocketsList
2001ac90 00000014 B xBoundUDPSocketsList /home/max/Lavori/4202/src/repos/toremove/FW/amazon-freertos/lib/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.c:162
这两个符号都存在于可执行文件中,但一个 ( xBoundTCPSocketsList
) 似乎不属于任何 .c 源。两者都出现在地图文件中:
$ grep -n -A 1 -E 'xBoundTCPSocketsList|xBoundUDPSocketsList' image/DSP.map
61974: .bss.xBoundTCPSocketsList
61975- 0x000000002001ac7c 0x14 ./build/DSP/amazon-freertos/lib/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.o
61976: 0x000000002001ac7c xBoundTCPSocketsList
61977: .bss.xBoundUDPSocketsList
61978- 0x000000002001ac90 0x14 ./build/DSP/amazon-freertos/lib/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.o
61979: 0x000000002001ac90 xBoundUDPSocketsList
即使 addr2line 失败:
$ arm-none-eabi-addr2line -a -e image/DSP.elf 2001ac7c 2001ac90
0x2001ac7c
??:0
0x2001ac90
/home/max/Lavori/4202/src/repos/toremove/FW/amazon-freertos/lib/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.c:162
甚至FreeRTOS_Sockets.lst
没有告诉我更多信息:
7337 .global xBoundTCPSocketsList
7338 .global xBoundUDPSocketsList
7339 .section .bss.xBoundTCPSocketsList,"aw",%nobits
7340 .align 2
7341 .set .LANCHOR2,. + 0
7344 xBoundTCPSocketsList:
7345 0000 00000000 .space 20
7345 00000000
7345 00000000
7345 00000000
7345 00000000
7346 .section .bss.xBoundUDPSocketsList,"aw",%nobits
7347 .align 2
7348 .set .LANCHOR1,. + 0
7351 xBoundUDPSocketsList:
7352 0000 00000000 .space 20
7352 00000000
7352 00000000
7352 00000000
7352 00000000
可执行文件中还有许多其他符号,但它们似乎与任何 .c 源文件无关。
为什么会有这种行为?两个符号xBoundTCPSocketsList
和之间有什么变化xBoundUDPSocketsList
?编译时是我弄错了还是省略了一些调试参数?如何获取 nm 或其他方式来获取声明符号的 .c 源?
编辑:
我认为问题不在于链接
事实上,即使我分析,我也会得到相同的 arm-none-eabi-nm 输出./build/DSP/amazon-freertos/lib/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.o
:
$ arm-none-eabi-nm -a -l -n -t x --print-size build/DSP/amazon-freertos/lib/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.o | grep -E '^[[:xdigit:]]{8} [[:xdigit:]]{8} B' | grep SocketsList
00000000 00000014 B xBoundTCPSocketsList
00000000 00000014 B xBoundUDPSocketsList /home/max/Lavori/4202/src/repos/toremove/FW/amazon-freertos/lib/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.c:162