huge binary files with objcopy

后端 未结 2 1081
旧时难觅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: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 
    }
    

提交回复
热议问题