placing static library answer in the beginning of flash section

独自空忆成欢 提交于 2019-12-01 06:34:25

问题


I'm using atmelstudio to compile a firmware image and want to place the functions from static libraries (including the gnu's libc.a & libgcc.a) in the beginning of the .text section followed .text belong to my project source code. Right now what happen is the other way around.

This is my linker script

    . = ALIGN(4);
    _sfixed = .;
    KEEP(*(.vectors .vectors.*))
    *(.text .text.* .gnu.linkonce.t.*)    <-- my functions and functions from static libraries are within this rule
    *(.glue_7t) *(.glue_7)
    *(.rodata .rodata* .gnu.linkonce.r.*)
    *(.ARM.extab* .gnu.linkonce.armextab.*)

回答1:


The star in *(.text), means to match any object file. You need to give the name for the libc and put it first. These are called input sections in the gnu ld manual. The syntax according to the manual is libc.a:(.text), you may order specific objects within a library, with libc.a:strcmp.o(.text).

See: Gnu Ld section 3.6.4.1 Input Section Basics for detailed information.


A solutions might be,

KEEP(*(.vectors .vectors.)) 
.a:(.text .text. .rodata .rodata*) <-- this line 
*(.text .text. .gnu.linkonce.t.*) 
*(.glue_7t) *(.glue_7) 
*(.rodata .rodata .gnu.linkonce.r.*)


来源:https://stackoverflow.com/questions/22497953/placing-static-library-answer-in-the-beginning-of-flash-section

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!