AnsweredAssumed Answered

ARM GCC -- First 64KB of application code

Question asked by Ice Lake on Jul 3, 2019
Latest reply on Jul 3, 2019 by Mark Butcher

Hi

 

Does anybody know where is the ASM code for first 64KB of compiled ELF

I'm looking for the code which define magic ELF 0x7F454C46 signature

 

 

Linker sets memory:

 

MEMORY
{
    ROM_VECTORS (rx) : ORIGIN = 0x00000000, LENGTH = 0x00000400
    ROM_FLASH_CFG (rx) : ORIGIN = 0x00000400, LENGTH = 0x00000010
    ROM_TEXT (rx) : ORIGIN = 0x00000410, LENGTH = 512K
    RAM (rw) : ORIGIN = 0x20000000, LENGTH = 192K
}

 

When I read the ELF file the ROM vectors are located one byte over 64KB

 

Startup code is:

 

.cpu cortex-m4
.thumb

 

.section .vectors, "a"
    .word __stack
    .word _reset
    .word _hang /* NMI */
    .word _hang /* HardFault */
    .word _hang /* MemManage */
    .word _hang /* BusFault */
    .word _hang /* UsageFault */
    .word _hang /* Reserved */
    .word _hang /* Reserved */
    .word _hang /* Reserved */
    .word _hang /* Reserved */
    .word vPortSVCHandler
    .word _hang /* DebugMonitor */
    .word _hang /* Reserved */
    .word xPortPendSVHandler
    .word xPortSysTickHandler

 

.section .flash_config, "a"
    .long 0xFFFFFFFF
    .long 0xFFFFFFFF
    .long 0xFFFFFFFF
    .long 0xFFFFFFFE

 

.section .text
.thumb_func
.global _reset
_reset:
    bl disable_wdog
    bl init_data_and_bss
    bl main

 

.global _exit
_exit:
    b .
 
.global _hang
_hang:
    b .

 

 

And the ELF binary:

 

1:    7f45 4c46 0101 0100 0000 0000 0000 0000           CODE ???
2:   0200 2800 0100 0000 1004 0000 3400 0000           CODE ???
3:   14ec 0200 0002 0005 3400 2000 0400 2800           CODE ???
4:   1100 1000 0100 0000 0000 0100 0000 0000           CODE ???
5:   0000 0000 4000 0000 4000 0000 0400 0000           CODE ???
6:   0000 0100 0100 0000 0004 0100 0004 0000           CODE ???
7:   0004 0000 1000 0000 1000 0000 0400 0000           CODE ???
8:   0000 0100 0100 0000 1004 0100 1004 0000           CODE ???
9:   1004 0000 d82f 0000 d82f 0000 0500 0000             CODE ???
10: 0000 0100 0100 0000 0000 0200 0000 0020           CODE ???
11: e833 0000 0400 0000 d480 0000 0600 0000           CODE ???
12: 0000 0100 0000 0000 0000 0000 0000 0000
13: 0000 0000 0000 0000 0000 0000 0000 0000
14: 0000 0000 0000 0000 0000 0000 0000 0000
15: 0000 0000 0000 0000 0000 0000 0000 0000
16: 0000 0000 0000 0000 0000 0000 0000 0000

...

...

...
4095: 0000 0000 0000 0000 0000 0000 0000 0000
4096: 0000 0000 0000 0000 0000 0000 0000 0000
4097: 0000 0320 1104 0000 1e04 0000 1e04 0000   ROM VECTORS
4098: 1e04 0000 1e04 0000 1e04 0000 1e04 0000   ROM VECTORS
4099: 1e04 0000 1e04 0000 1e04 0000 5105 0000   ROM VECTORS
4100: 1e04 0000 1e04 0000 8907 0000 eb07 0000   ROM VECTORS
4101: 0000 0000 0000 0000 0000 0000 0000 0000

4102: 0000 0000 0000 0000 0000 0000 0000 0000

 

Does anybody know where I could find a code for first 64KB of compiled ELF ???

 

Thanks

Ice

Outcomes