huge binary files with objcopy

后端 未结 2 1076
旧时难觅i
旧时难觅i 2020-12-30 15:32

Im having problems when I define global variables in a basic C program for an ARM9 processor. I\'m using EABI GNU compiler and the binary generated from a 12KB elf is 4GB! I

相关标签:
2条回答
  • 2020-12-30 15:40

    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).

    0 讨论(0)
  • 2020-12-30 15:42

    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 
    }
    
    0 讨论(0)
提交回复
热议问题