I am a little bit confused with ENTRY and STARTUP commands in GCC linker script.
As stated here: http://wiki.osdev.org/Linker_Scripts
ENTRY() makes any symbol to be linked as first item in .text section. STARTUP() on the other hand makes whole compiled file to be placed as first item in .text section.
In my project however it behaves strange.
I am using gnu-arm-none-eabi toolchain and in my linker script command ENTRY(asm_start) makes no effect. Linker script:
ENTRY(asm_start)
MEMORY
{
RAM : ORIGIN = 0x10000, LENGTH = 0x1000000
PIC_BUFF : ORIGIN = 0x10000 + LENGTH(RAM), LENGTH = 200M
}
SECTIONS
{
.text : {*(.text)} > RAM
.data : {*(.data)} > PIC_BUFF
// etc.
assembly function:
.text
.global asm_start
.global exc_stack
.global supervisor_sp
asm_start:
# initialize Stack pointer for exception modes
mrs r4, cpsr
bic r4, r4, #0x1f
#FIQ Mode
orr r3, r4, #0x11
msr cpsr_c, r3
ldr sp, =exc_stack
#IRQ Mode
orr r3, r4, #0x12
msr cpsr_c, r3
// etc.
and asm_start finishes in some random place in memory.
On the other hand STARTUP() function works fine and desired file ends in proper place in .text section.
Could some please explain what exactly is happening in this case?