embeded/Cortex-M4 Ti2017. 12. 28. 15:01

항상 만만한(?) qs-rgb 예제에서

Linker를 보다 보니... scatter 아래 Misc Control의

--entry Reset_Handler

가 보인다...?



startup_rvmdk.S에

해당 함수가 그럼 entry 포인트로 잡히고

얘는 적절한 초기화 이후 __main 을 호출하게 된다.

;******************************************************************************

;

; This is the code that gets called when the processor first starts execution

; following a reset event.

;

;******************************************************************************

        EXPORT  Reset_Handler

Reset_Handler

        ;

        ; Enable the floating-point unit.  This must be done here to handle the

        ; case where main() uses floating-point and the function prologue saves

        ; floating-point registers (which will fault if floating-point is not

        ; enabled).  Any configuration of the floating-point unit using

        ; DriverLib APIs must be done here prior to the floating-point unit

        ; being enabled.

        ;

        ; Note that this does not use DriverLib since it might not be included

        ; in this project.

        ;

        MOVW    R0, #0xED88

        MOVT    R0, #0xE000

        LDR     R1, [R0]

        ORR     R1, #0x00F00000

        STR     R1, [R0]


        ;

        ; Call the C library enty point that handles startup.  This will copy

        ; the .data section initializers from flash to SRAM and zero fill the

        ; .bss section.

        ;

        IMPORT  __main

        B       __main 


그럼.. main()이 __main 으로 맹글링 되는건가?

[링크 : https://en.wikipedia.org/wiki/Name_mangling]

[링크 : http://spikez.tistory.com/19]

[링크 : http://infocenter.arm.com/help/topic/com.arm.doc.dui0205d/RVCT_Compiler_and_Libraries_D.pdf]

Posted by 구차니