Injecting sections into GNU ld script; script compatibility between versions of binutils.

后端 未结 1 1809
感情败类
感情败类 2021-02-05 14:07

I\'m building something like in the question How to collect data from different .a files into one array? How to keep sections in .a files with ld script?, i.e. arrays composed d

相关标签:
1条回答
  • 2021-02-05 14:27

    I found a satisfying solution for that problem. GNU ld has the INSERT option which makes the externally supported script not override the default script, but simply add new section at position relative to some section that exists in the default script.

    So in my case, the script passed to the linker may be as simple as:

    SECTIONS
    {
      .rodata.ld_comp_array :
      {
        *(SORT_BY_NAME(.ld_comp_array*))
      }
    }
    INSERT AFTER .rodata;
    

    More on the INSERT option: http://sourceware.org/binutils/docs/ld/Miscellaneous-Commands.html#Miscellaneous-Commands

    0 讨论(0)
提交回复
热议问题