This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Default crt0.o startup for GCC - Cortex M0

I am trying to write a bootloader that fits within a 4Kbyte space and I'm trying to keep the essential code as small as possible.

However, with the standard default setup from the CMSDK Cortex M0 enviroment, even with a empty main(), I notice that it has already taken up almost 2.5Kbytes

Looking further into the compiled code, I noticed that crt0.o uses some functions which are taking up space some of them below ( dumped from *nm)

20000430 00000004 D _impure_ptr
3000022a 00000004 T main
30000438 00000010 T atexit
30000324 00000018 t register_fini
30000230 00000020 T exit
30000448 00000034 T __libc_fini_array
30000198 00000044 T Reset_Handler
30000250 00000048 T __libc_init_array
30000298 0000008c T memset
30000000 000000c0 T __isr_vector
3000047c 000000d4 T __register_exitproc
3000033c 000000fc T __call_exitprocs

What does crt0.o do anyways and I thought all the necessary copy-downs from Flash to RAM are already defined in startup_CMSDK_CM0.s.

Can I exclude calling this file and go straight to startup_CMSDK_CM0.s?

Also looking at the linker script sections.ld there are references to crt and ctors. Can I exclude those as well?

                /* .ctors */
                *crtbegin.o(.ctors)
                *crtbegin?.o(.ctors)
                *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
                *(SORT(.ctors.*))
                *(.ctors)

                /* .dtors */
                *crtbegin.o(.dtors)
                *crtbegin?.o(.dtors)
                *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
                *(SORT(.dtors.*))
                *(.dtors)

                *(.rodata*)

Just starting out with programming on Cortex M0 so any help is appreciated, cheers.