我正在开发一个使用动态重定位的项目,它适用于Cortex-M4,但我在使用Cortex-M0 +时遇到了一些问题。
问题出现在浮点函数的符号上。该核心没有浮点单元。
所以我试图理解两个核心(M4和M0 +)生成的代码之间的差异。
代码是这样的:
#include <stdint.h>
#include <math.h> // <fastmath.h>
float a, b, c; //, d, e;
void ldMain(void)
{
a = 1.100000f + a;
b = 1.100000f - b;
c = 1.100000f * c;
//d = 1.100000f / d;
}
编译和链接的命令如下:
arm-none-eabi-gcc.exe -c TESTE.c -o TESTE.o0 -mthumb -mcpu=cortex-m0plus -O0 -mlong-calls -mword-relocations -mabi=atpcs -mfloat-abi=soft -mcaller-super-interworking
arm-none-eabi-ld.exe -o TESTE.o TESTE.o0 --relocatable --strip-all --discard-all --embedded-relocs
生成的符号是(使用arm-none-eabi-readelf获取):
Relocation section '.rel.text' at offset 0x2e4 contains 6 entries:
Offset Info Type Sym.Value Sym. Name
00000028 00000b02 R_ARM_ABS32 00000004 a
0000002c 00000c02 R_ARM_ABS32 00000000 __addsf3
00000034 00000602 R_ARM_ABS32 00000004 b
00000038 00000802 R_ARM_ABS32 00000000 __subsf3
0000003c 00000902 R_ARM_ABS32 00000004 c
00000040 00000a02 R_ARM_ABS32 00000000 __mulsf3
与gcc命令中使用的标志-mcpu = cortex-m0plus或-mcpu = cortex-m4无关,生成的符号是相同的。
问题是cortex-m0plus上不存在这些符号。
位于C:\ Program Files(x86)\ GNU Tools ARM Embedded \ 4.9 2015q2 \ lib \ gcc \ arm-none-eabi \ 4.9.3 \ armv6-m的cortex-m0plus(armv6-m)的libgcc没有这些符号。用arm-none-eabi-nm命令验证了它。
有没有人知道为什么这些符号如果不存在于cortex-m0plus中使用?
我使用的是GCC ARM Embedded版本4.9 2015q2。
这些函数在GCC glibc(newlib或nanolib)中定义。这篇文章差不多4年了,我没有2015年海湾合作委员会的经验。然而,最近(例如2018等)GCC肯定在库中具有这些FP软件例程。