我正在使用 mbxxx 目标开发 Contiki 2.7。在构建我的代码时,链接器抱怨.ARM.exidx 和 .data 部分重叠。在修改了链接器脚本 contiki-2.7/cpu/stm32w108/gnu-stm32w108.ld 后,我通过替换解决了这个问题:
__exidx_start = .;
__exidx_end = .;
和:
.ARM.exidx : {
__exidx_start = .;
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
__exidx_end = .;
} >ROM_region
后来,当我尝试使用 objdump -h 查看其他一些示例应用程序的标题列表时,我没有找到这个特定的 .ARM.exidx 部分,而它存在于我的应用程序中。谷歌搜索 .ARM.exidx 让我发现它用于一些 c++ 异常处理。既然我的代码是纯 C 代码,为什么这部分会出现在我的代码中?.ARM.exidx 通常何时出现在代码中,它的用途是什么?
==================================================== =================================
不,我没有任何这样的编译器选项。我实际上正在使用 AxTLS api 并撕下证书处理代码并将其移植到 contiki。在进一步的挖掘中,我发现了 bigint 实现中的可疑行为。简而言之……这是 bigint.c 文件中的函数主体:
static bigint *bi_int_multiply(BI_CTX *ctx, bigint *bia, comp b)
{
int j = 0, n = bia->size;
bigint *biR = alloc(ctx, n + 1);
comp carry = 5;
comp *r = biR->comps;
comp *a = bia->comps;
check(bia);
/* clear things to start with */
memset(r, 0, ((n+1)*COMP_BYTE_SIZE));
do
{
long_comp tmp = *r + (long_comp)a[j]*b + carry;
// *r++ = (comp)tmp; /* downsize */
carry = (comp)(tmp >> COMP_BIT_SIZE);
} while (++j < n);
// *r = carry;
bi_free(ctx, bia);
return trim(biR);
}
如果注释掉的部分(r 变量赋值)未注释,则 .ARM.exidx 会出现,否则不会出现!现在可以解释了吗???
==================================================== =================================
我没有发现在alloc()
. 在代码的某个单独区域中使用了2 个引用alloca()
,我将其替换为malloc()
and free()
,但这也没有解决问题。alloc()
实现只调用malloc()
,realloc()
和free()