L6200E: __semihosting_swi_guard multiply defined的解决方法

2011-11-06 08:47

MSTAR终端编译时提示错误:Error: L6200E: Symbol __semihosting_swi_guard multiply defined (by use_semi.o and use_no_semi.o).
这个问题的原因可能是程序里调用了一些标准C的函数,但这些函数在嵌入式C语言里没有定义,那就需要对调用的这些函数进行重新定义。
举个例子,例如调用了标准C里面的printf函数,就会出现上述所说的错误,那就需要在程序里对这个函数进行重定义或者直接删除。
(MSTAR的link命令后默认加了-verbose)直接查找link.info中的__I_use_semihosting_swi,可以看到哪些函数导致了该编译错误。

比如,编译链接时提示:<TNG>Error: L6200E: Symbol __semihosting_swi_guard multiply defined (by use_semi.o and use_no_semi.o).
在link.info中查找,发现了如下的线索:
    sys_exit.o(.text) refers to use_semi.o(.text) for __I_use_semihosting_swi   
    -abort.o(.text) refers to sys_exit.o(.text) for _sys_exit
    --h1_alloc.o(.text) refers to abort.o(.text) for abort
    ---malloc.o(.text) refers to h1_alloc.o(.text) for __Heap_DescSize
    ----zutil.o(.text) refers to malloc.o(.text) for malloc
    -h1_free.o(.text) refers to abort.o(.text) for abort
    --free.o(.text) refers to h1_free.o(.text) for __Heap_Free
    ---zutil.o(.text) refers to free.o(.text) for free
    sys_stackheap.o(.text) refers to use_semi.o(.text) for __I_use_semihosting_swi
    -stkheap1.o(.text) refers to sys_stackheap.o(.text) for __user_initial_stackheap
    --heapext.o(.text) refers to stkheap1.o(.text) for __rt_heap_extend
    ---malloc.o(.text) refers to heapext.o(.text) for __heap_extend
    ----zutil.o(.text) refers to malloc.o(.text) for malloc
即包含“__I_use_semihosting_swi”的有两条记录,根据它们往上追查,最后都归到zutil.o,它调用了标准C的接口malloc和free
用armar.exe和objdump.exe的命令,去分析zutil.o里的信息,也能印证zutil确实调用了malloc和free,见下图:
L6200E: __semihosting_swi_guard multiply defined的解决方法_第1张图片

你可能感兴趣的:(c,user,嵌入式,语言,终端)