AnsweredAssumed Answered

How does linker know the entry point into the program?

Question asked by Amer Naseem on Jun 13, 2019
Latest reply on Jun 14, 2019 by Amer Naseem

My embedded system is based on LPC11E68JBD48E.  I'm using MCUXpresso IDE.  Linker script is auto generated.  The entry point is specified in the beginning of linker script, ENTRY(ResetISR)

How does linker know this is the first instruction to execute?

 

ResetISR is declared, defined, and is entry in vector table in my .cpp file as follows:

void ResetISR(void);

 

ResetISR(void) {

   /* some reset initialization code here */

}

 

//*****************************************************************************

//

// The vector table. Note that the proper constructs must be placed on this to

// ensure that it ends up at physical address 0x0000.0000.

//

//*****************************************************************************

extern void (* const g_pfnVectors[])(void);

__attribute__ ((used,section(".isr_vector")))

void (* const g_pfnVectors[])(void) = {

&_vStackTop, // The initial stack pointer

ResetISR, // The reset handler

NMI_Handler, // The NMI handler

...

….

….

 

When reset is released this microcontroller executes at address 0x0000 0000.  Looking at the vector table  &_vStackTop is at address 0x0000 0000.  What is the result of executing code at address 0x0000 0000?

When I reset microcontroller from the debugger, breakpoint in the function ResetISR is hit. 

How does linker know program entry point is ResetISR?

 

I would expect ResetISR to be the first entry in the vector table but it is second entry?

Outcomes