I generated the .bin file for a very simple .s .c and .ld files for cortex m4 (STM32). The .c file has 3 lines of code:
int c_entry() {
return 0;
}
Assembler file is as below:
.section isr_vector, "x"
.syntax unified
.global _Reset
_Reset:
.word 0
.word Reset_Handler /* Reset */
.word NMI_handler
.word HardFault
.word MemManage
.word BusFault
.word UsageFault
.word 0 /* Reserved */
.word 0/* Reserved */
.word 0/* Reserved */
.word 0/* Reserved */
.word SVCall
.word DebugMonitor
.word 0/* Reserved */
.word PendSV
.word SysTick
Reset_Handler:
LDR sp, =stack_top
BL c_entry
B .
NMI_handler:
B . /*NMI_handler*/
HardFault:
B .
MemManage:
B .
BusFault:
B .
UsageFault:
B .
SVCall:
B .
DebugMonitor:
B .
PendSV:
B .
SysTick:
B .
And linker file is :
ENTRY(_Reset)
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K
PERIPHERALS(rw) : ORIGIN = 0x40000000, LENGTH = 128K
}
SECTIONS
{
.startup . : { stm32.o(.text) } >FLASH
.text : { *(.text) }
.data : { *(.data) } >RAM AT> FLASH
.bss : { *(.bss COMMON) } >RAM
. = ALIGN(4);
. = . + 0x400; /* required amount of stack */
stack_top = 0x20020000;
}
I generate the .elf using the command below:
arm-none-eabi-ld -T stm32.ld stm32src.o stm32.o -o stm32.elf
And then .bin file by running:
arm-none-eabi-objcopy -O binary stm32.elf stm32.bin
The generated .bin file is 131MB which is not accepted by QEMU and generates error in the image below:
Why such a simple program generating such a huge bin file?
EDIT: I have removed the canberra-gtk error (showed in the image)
User contributions licensed under CC BY-SA 3.0