我正在将一些软件从
gcc-toolchain移植到armcc-toolchain(处理器保持不变(Cortex-A9)).在C代码中使用memcpy. armcc通过调用__aeabi_memcpy替换对memcpy的调用.常见问题解答如下关于__aeabi_memcpy(
How do the ARM Compilers handle memcpy()?):
In many cases,when compiling calls to memcpy(),the ARM C compiler will generate calls to specialized,optimised,library functions instead. Since RVCT 2.1,these specialized functions are part of the ABI for the ARM architecture (AEABI),and include:
__aeabi_memcpy This function is the same as ANSI C memcpy,except that the return value is void.
但是与gcc相比,在我的所有情况下对memcpy的调用都可以正常工作,使用armcc对memcpy的调用__aeabi_memcpy会连续产生对齐异常.同时我发现,对memcpy的调用可以处理源和目标地址不是4字节对齐的调用,但前提是它们都不是4字节对齐的.例如:
将工作.但是例如:
volatile uint32_t len = 10; uint8_t* src = (uint8_t*)0x会导致对齐异常.我正在使用uint8_t类型的指针*我明确告诉编译器地址可以有任何对齐.但显然这个__aeabi_memcpy无法处理每个路线组合.如何解决此问题(最好不使用用户特定版本的memcpy更改现有代码中对memcpy的所有调用)?感谢帮助.
__aeabi_memcpy This function is the same as ANSI C memcpy,except that the return value is void.
002; // 2-byte aligned
uint8_t* dst = (uint8_t*)(0x__aeabi_memcpy This function is the same as ANSI C memcpy,except that the return value is void.__aeabi_memcpy This function is the same as ANSI C memcpy,except that the return value is void.002 + 20); // 2-byte aligned__aeabi_memcpy This function is the same as ANSI C memcpy,except that the return value is void.
memcpy(dst,src,len);
volatile uint32_t len = 10; uint8_t* src = (uint8_t*)0x__aeabi_memcpy This function is the same as ANSI C memcpy,except that the return value is void.002 + 22); // 4-byte aligned
memcpy(dst,len);