huge binary files with objcopy

戏子无情 提交于 2019-11-30 07:38:47

You are creating a file which will starts at address 0x01000000 and will contains at least up to address 0xFFFF0000. No wonder that it is nearly 4GB. What would you like? Try with options -R to remove the data segments if you don't want them (as it is probably the case if you are preparing a ROM initialization file).

I found the problem. The objcopy command will try to create the entire address space described in the linker script, from the lowest address to the highest including everything in between. You can tell it to just generate the ROM code as follows:

objcopy ./main.elf -j ROM --output-target=binary ./main.bin

I also changed the linker script slightly

MEMORY {
  ram(WXAIL) : ORIGIN = 0x01000000, LENGTH = 32K    
  rom(RX)    : ORIGIN = 0xFFFF0000, LENGTH = 32K                    
}

SECTIONS {
  ROM : { 
    *(vectors);
    *(.text);
    *(.rodata);
  } > rom 

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