linking arbitrary data using GCC ARM toolchain

后端 未结 3 1026
北荒
北荒 2020-12-02 23:59

I want to link in raw binary data. I\'d like to either put it at a particular address, or have it link to a symbol (char* mydata, for instance) I have defined in code. Sinc

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-03 00:46

    Another approach might be to use xxd.

    xxd -i your_data your_data.c
    

    In the file you'll get two symbols unsigned char your_data[] and unsigned int your_data_len. First one will be a huge array containing your data, second one will be the lenght of that array.

    Compilation of created C file might be time taking, so if you are using a build system / Makefile handle it properly avoiding unnecessary recompilations.

    xxd should be part of vim (vim-common) package for your Linux distribution.

提交回复
热议问题