arm-none-eabi-gcc编译错误

arm-none-eabi-gcc编译错误

  1. undefined reference to `end' in sbrk.c in library libnosys.a

    The symbol end needs to be defined in the .lds linker script, which is used to set the location of the heap.

    Looking at the .lds linker script generated in a ARM GNU example created in CCSv6 showed the following which defines end:

    .heap : {

    __heap_start__ = .;

    end = __heap_start__;

    _end = end;

    __end = end;

    KEEP(*(.heap))

    __heap_end__ = .;

    __HeapLimit = __heap_end__;

    } > REGION_HEAP

  2. tools/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.6.2\libc.a(lib_a-exit.o): In function `exit': exit.c:(.text+0x18): undefined reference to `_exit

    arm-none-eabi-gcc --specs=nosys.specs $(OTHER_LINK_OPTIONS)。 https://stackoverflow.com/questions/19419782/exit-c-text0x18-undefined-reference-to-exit-when-using-arm-none-eabi-gcc

  3. 依赖的多个库出现依赖时的链接问题

    在使用arm-none-eabi-gcc进行编译链接时,makefile中指定如下链接顺序:

    -lliba -llibb

    1、 liba库包含a.o

    2、 libb库中代码依赖于liba库中的a.o

    3、 链接时打开编译优化选项

    4、我们自己的代码中并没有使用liba库中a.o中的代码

    5、进行编译时,报了找不到a.o中定义接口的错误

    修改办法,先链接-llibb, 再链接-lliba即可解决问题

  4. 将lib中的特定的源文件对应的可执行程序输出到特定位置,liba.so中包含很多可执行程序,我们要求将其中的flash.o放到ram中,而不是在flash中,可按照如下方式编写链接脚本:

    SECTIONS

    {

    ...

    falsh :

    {

    . = ALIGN(0x80)

    *flash.o (.text)

    . = ALIGN(4)

    }>ram AT >flash

    }

    *flash.o 是为了让链接器可以找到flash.o,只要在给定的路径上能找到的方式都是正确的,比如*liba.so:flash.o /home/xxx/a/liba.so:flash.o均能唯一的索引到我们要的flash.o,因此都是正确的

猜你喜欢

转载自blog.csdn.net/goodluckwhh/article/details/86650794