Include binary file with GNU ld linker script

后端 未结 3 1607
时光说笑
时光说笑 2020-11-29 04:54

I have a working linker script. I want to add another data section whose contents is pulled directly from a file (ld shouldn\'t parse it and extract the sections and so on).

3条回答
  •  孤城傲影
    2020-11-29 05:29

    You can put raw file to separate section in assembly, and then include this section in linker script.

    First you need to create template .S file, eg.

    .section .rawdata
    .incbin "blob1.raw"
    

    ... and modify linker script to include this section as you like it:

    .data : {
    
        *(.rawdata*)
    
    }
    

    You can also take a look here here for a bit more detailed information about .S template.

提交回复
热议问题